How to create a two-hour blank video

I would like to create a video with a black or white background (or even nothing at all) that lasts for a certain duration (for example, 2 hours).

Can you suggest a quick way to do this programmatically (e.g. command line, OpenCV)? Thanks.

+7
source share
2 answers

You can use ffmpeg for this:

ffmpeg -t 7200 -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero empty.mpeg 

UPDATE :

 -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 
+29
source

To exit h264 in an MP4 container, use:

 ffmpeg -t 7200 -f lavfi -i color=c=black:s=640x480 -c:v libx264 -tune stillimage -pix_fmt yuv420p output.mp4 

If you want to enable the soundtrack, just add arguments for audio input and encoding (if necessary). The output duration is determined by the shortest input, i.e. audio. For example:

 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 
+1
source

All Articles