Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a 2hour-long blank video

I'd like to generate a video with a black or white background (or even nothing at all) that lasts for a specific duration (e.g. 2 hour long).

Can you please suggest a fast way to do it programatically (e.g. command line, OpenCV)? Thanks.

like image 656
Son Do Lenh Avatar asked Jul 12 '12 13:07

Son Do Lenh


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
like image 97
fedosov Avatar answered Oct 18 '22 07:10

fedosov


For an h264 output in a 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 include an audio track, simply add the arguments for the audio input and encoding (if necessary). The output's duration will be determined by the shortest input, i.e. the 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
like image 35
Andrzej Avatar answered Oct 18 '22 09:10

Andrzej