So when I look at the original video:

ffprobe -v error -show_entries stream=index,codec_name,codec_type example.mkv 

I see something like this:

[STREAM] index=0 codec_name=h264 codec_type=video [/STREAM] [STREAM] index=1 codec_name=aac codec_type=audio [/STREAM] [STREAM] index=2 codec_name=ass codec_type=subtitle [/STREAM] [STREAM] index=3 codec_name=ttf codec_type=attachment [/STREAM] 

My process involves extracting the ass file via:

ffmpeg -i input.mkv -map 0:s:0 subs.ass 

I edit the subtitle file in vim. Then I try to add the subtitle file back into the mkv file with something like:

ffmpeg -i input.mkv -f ass -i subs.ass \ -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy \ -c:s copy output.mkv 

But when I probe the output.mkv, I only see

[STREAM] index=0 codec_name=h264 codec_type=video [/STREAM] [STREAM] index=1 codec_name=aac codec_type=audio [/STREAM] [STREAM] index=2 codec_name=ass codec_type=subtitle [/STREAM] 

As you can see, I lose the attachment stream, and the subtitles no longer play by default. So I came across other commands:

Make subtitle default:

ffmpeg -i output.mkv -f ass -i subs.ass -c copy -disposition:s:0 default out.mkv 

Dump Font from the original:

ffmpeg -dump_attachment:t "" -i original.mkv 

Attach Font to edited video:

ffmpeg -i out.mkv -attach OpenSans-Semibold.ttf -metadata:s:3 mimetype=application/x-truetype-font final.mkv 

But then somehow along those processes, the audio changes from aac to vorbis, and the video changes from h264 (native) to h264 (libx264). How do I preserve the streams while making simple error changes to the subtitles?

1 Answer

#1 Extract subtitles

ffmpeg -i input.mkv -c copy -map 0:s:0 subs.ass 

#2 Mux edited subs

ffmpeg -i input.mkv -i subs.ass \ -map 0:v -map 0:a -map 1 -map 0:t -c copy -disposition:s:0 default output.mkv 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy