问题
I have 40 videos that I need to trim, so they would start at the 6th second and then combine them into a single video.
I also have a list_of_movies.txt
that contains the name of all the files I need to trim.
This is my problem:
When concatenating the videos to a single file, ffmpeg accepts:
ffmpeg -f concat -i list_of_movies.txt -c copy output.mp4
but when trimming, it would not accept:
ffmpeg -ss 00:00:06 -i list_of_movies.txt trimmed .mp4
What am I doing wrong?
回答1:
If you want to trim each video to start from its 6th second, you'll have to specify it for each file within the text file, so
file first.mp4
inpoint 5
file second.mp4
inpoint 5
file third.mp4
inpoint 5
[...]
and then run
ffmpeg -f concat -i list_of_movies.txt -c copy output.mp4
However, in copy
mode, ffmpeg can only extract, starting at a video keyframe, so expect extra frames and maybe broken audio sync.
It's best to re-encode,
ffmpeg -f concat -segment_time_metadata 1 -i list_of_movies.txt -vf select=concatdec_select,setpts=N/FRAME_RATE/TB -af aselect=concatdec_select,asetpts=N/SR/TB output.mp4
来源:https://stackoverflow.com/questions/50987864/ffmpeg-seeking-using-a-txt-file