1

encode part of a file and at the same time add the subtitles for that part. I am using:

ffmpeg -ss 00:02:00 -t 00:00:30 -i "path/to/input" -c:v libvpx -crf 5 -b:v 3M -c:a libvorbis -vf "ass=path/ass" "output.webm"

it shows that it loads the subtitles but in the output they don't exist (subtitle:0kB). As far as I could tell the subtitles part doesn't work with -ss ? (Or it ignores -ss and tries to add the whole subs beginning with 00:00:00 of the .ass on 00:02:00 of the video stream).

Only way I could do it was to re-encode the whole file and then use:

ffmpeg -ss 00:02:00 -i "output.webm" -t 00:00:30 -c:v copy -c:a copy "new_output.webm"

to keep what I wanted. Am I missing something or it's just not possible to do what i want all in one?

Hope what I wrote made some sense and thx.


Output #0, webm, to 'target/test.webm':
  Metadata:
    encoder         : Lavf55.37.101
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2500 kb/s, 1k tbn, 23.81 tbc (default) (forced)
    Stream #0:1: Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp (default) (forced)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libvpx)
  Stream #0:1 -> #0:1 (aac -> libvorbis)
Press [q] to stop, [?] for help
frame=  953 fps= 22 q=0.0 Lsize=    6990kB time=00:00:40.02 bitrate=1430.6kbits/s dup=0 drop=5
video:6499kB audio:464kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 0.376779%
2
  • Pretty sure that it's taking the subtitles from 00:00:00. Maybe it works if you put the -ss option after -i. Also note that -t should always go as an output option, i.e. after -i as well. Can you include the full uncut ffmpeg command line output for the first command as well for us? Note that code formatting is applied by indenting text by 4 spaces or selecting it and pressing Ctrl-K.
    – slhck
    Commented Jun 28, 2014 at 15:12
  • Putting -ss with -t after the -i worked! It's heavier (I think because it's more precise right?) and it takes some pre processing but works fine! Thank you.
    – Loke
    Commented Jun 28, 2014 at 17:01

1 Answer 1

1

If you put -ss after -i, ffmpeg will first encode the entire file up to the point you've specified, and only then will it write to the output.

This means that the subtitles will start at the correct point.

Also, you should consider putting -t after -i because it's used as an output option here, meaning, output only 30 seconds.

ffmpeg -i "path/to/input" -ss 00:02:00 -t 30 -c:v libvpx -crf 5 -b:v 3M -c:a libvorbis -vf "ass=path/ass" "output.webm"
3
  • -t is now also an input option, but this was only recently documented, IIRC.
    – llogan
    Commented Jun 29, 2014 at 15:58
  • @LordNeckbeard Good to know, thanks. Although I guess the effect is exactly the same?
    – slhck
    Commented Jun 29, 2014 at 16:21
  • I think so, unless the total output duration ends up being different than the input(s) or if there is any temporal offset.
    – llogan
    Commented Jun 29, 2014 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .