简体   繁体   中英

Using ffmpeg to trim a percentage of video

ffmpeg -framerate 30 -i %1d.png -c:v libx264 -profile:v high -crf 10 -pix_fmt yuv420p test.mp4

Hi,

I have a folder with a bunch of png images: 0.png, 1.png, 2.png ... Using the above code, I can convert all the images in the directory into one video. What I want to do is only convert a percentage of all the images into a video. Is there any way I can specify to ffmpeg to only convert the first 20% of images into a video? For example if there is 50 images, ffmpeg in this case would only use the first 10 images to form a video.

You could use -start_number and -frames:v . -start_number accepts an expression but -frames:v does not. So you could use some scripting to calculate frames from percentage.

ffmpeg -framerate 30 -start_number <frame_number> -i %1d.png -frames:v <frames> -c:v libx264 -profile:v high -crf 10 -pix_fmt yuv420p test.mp4
  • -start_number: Start at index frame number.
  • -frames:v: number of output frames.

-vframes is depricated according to the manual. https://www.ffmpeg.org/ffmpeg-all.html#toc-Video-Options

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM