Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

FFMPEG: How to limit infinite looping video duration inside filtergraph?

This is the smallest example that results in never ending transcoding:

ffmpeg -y -filter_complex movie=filename='./frames/image0.png':loop=0,trim=duration=2 ./frames/test.mp4

All frames after t=2 are dropped, but transcoding never stops, contrary to what would happen with -t 2 flag. However, my filtergraph is very complex, and I need to trim multiple streams to different length, so I would love to do this inside the filtergraph.

Any tips?

question from:https://stackoverflow.com/questions/66057105/ffmpeg-how-to-limit-infinite-looping-video-duration-inside-filtergraph

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the -loop option to loop each image then use the trim filter. No need for the movie filter. Example:

ffmpeg -loop 1 -i input0.png -loop 1 -i input1.png -filter_complex "[0]trim=duration=2,setpts=PTS-STARTPTS[v0];[1]trim=duration=4,setpts=PTS-STARTPTS[v1];[0]trim=duration=1,setpts=PTS-STARTPTS[v2];[1]trim=duration=5,setpts=PTS-STARTPTS[v3];[v0][v1][v2][v3]concat=n=3:v=0:a=0,format=yuv420p" output.mp4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...