FFMPEG: seeking using a txt file

我是研究僧i 提交于 2020-12-08 00:28:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!