简体   繁体   English

使用ffmpeg修剪一部分视频

[英]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 ffmpeg -framerate 30 -i%1d.png -c:v libx264 -profile:v高-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. 我有一个包含一堆png图像的文件夹:0.png,1.png,2.png ...使用上面的代码,我可以将目录中的所有图像转换为一个视频。 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? 有什么方法可以指定ffmpeg仅将图像的前20%转换为视频吗? For example if there is 50 images, ffmpeg in this case would only use the first 10 images to form a video. 例如,如果有50张图像,则ffmpeg在这种情况下将仅使用前10张图像来形成视频。

You could use -start_number and -frames:v . 您可以使用-start_number-frames:v -start_number accepts an expression but -frames:v does not. -start_number接受表达式,但-frames:v不接受。 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. -start_number:从索引帧号开始。
  • -frames:v: number of output frames. -frames:v:输出帧数。

-vframes is depricated according to the manual. -vframes根据手册描述。 https://www.ffmpeg.org/ffmpeg-all.html#toc-Video-Options https://www.ffmpeg.org/ffmpeg-all.html#toc-Video-Options

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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