[FFmpeg-user] Add subtitles to trimmed mp4
adam smith
adamsmith79 at icloud.com
Sat Feb 13 01:24:05 EET 2021
Hi people, I have a subtitle question; yay.
I have a 2 minute mp4 that I am going to trim using -ss and -to .
I have a SRT subtitle file with timings that will line up with the trimmed mp4.
If I try and trim the mp4 and add the subtitles at the same time, the trim is ignored and the whole media file is encoded.
ffmpeg -y -i /data/disposable/localised_20210212-1147-u81zpu/full_mp4.mp4 -ss 10 -to 40 -i https://somewhere/source/subtitles/subtitles.srt -filter_complex "[0:1]fifo[vout];[0:0]afifo[01_afifo]" -map "[vout]" -map "[01_afifo]" -map 1 -pix_fmt yuv420p -c:v libx264 -s 1920x1080 -profile:v high -level:v 4.1 -refs:v 2 -keyint_min 50 -b:v 15000k -r 25 -ac 2 -bsf:a aac_adtstoasc -c:a libfdk_aac -ar 48000 -b:a 192k -c:s:0 mov_text -metadata:s:s:0 language=eng -flags +global_header -f tee "[f=mp4:movflags=+faststart]/data/disposable/transcode_20210212-1147-znbqck/edit_2805.mp4"
If I add the -ss and -to command to the subtitle input file too, the output file has been trimmed, but the subtitles are out of sync. The subtitles stay locked to the time of the source media.
ffmpeg -y -i /data/disposable/localised_20210212-1147-u81zpu/full_mp4.mp4 -ss 10 -to 40 -i https://somewhere/source/subtitles/subtitles.srt -ss 10 -to 40 -filter_complex "[0:1]fifo[vout];[0:0]afifo[01_afifo]" -map "[vout]" -map "[01_afifo]" -map 1 -pix_fmt yuv420p -c:v libx264 -s 1920x1080 -profile:v high -level:v 4.1 -refs:v 2 -keyint_min 50 -b:v 15000k -r 25 -ac 2 -bsf:a aac_adtstoasc -c:a libfdk_aac -ar 48000 -b:a 192k -c:s:0 mov_text -metadata:s:s:0 language=eng -flags +global_header -f tee "[f=mp4:movflags=+faststart]/data/disposable/transcode_20210212-1147-znbqck/edit_2805.mp4"
Is there any way to force the subtitles in the SRT to be mapped to the time of the output?
I would prefer not to do it in two passes if possible.
I can include console output if it helps but I am pretty sure I am just putting the command together incorrectly and nothing untoward is happening.
Thanks in advance for your advice.
Adam
Sent from my iPhone
More information about the ffmpeg-user
mailing list