我想生成一个黑色或白色背景(甚至根本没有)的视频,持续特定的持续时间(例如2小时)。
能否请您以编程方式快速建议(例如命令行,OpenCV)?谢谢。
您可以使用ffmpeg:
ffmpeg -t 7200 -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero empty.mpeg
更新:
-t: length of the video (in H:m:s format 00:00:00 or in seconds 0.000)
-s: frame size
-f: video format
-pix_fmt: pixel format
-r: fps
-i: input
对于MP4容器中的h264输出,请使用:
ffmpeg -t 7200 -f lavfi -i color=c=black:s=640x480 -c:v libx264 -tune stillimage -pix_fmt yuv420p output.mp4
如果要包含音轨,只需添加音频输入和编码的参数(如有必要)。输出的持续时间将由最短输入,即音频确定。例如:
ffmpeg -f lavfi -i color=c=black:s=640x480 -i audio.ogg -c:v libx264 -tune stillimage -pix_fmt yuv420p -shortest -c:a aac -b:a 128k output-with-audio.mp4