eladg / ffmpeg-by-example

Creative Commons Attribution 4.0 International
8 stars 5 forks source link

Generate a solid color H.264 video with the color video source filter (color Hex code) - FFmpeg By Example #46

Open eladg opened 2 years ago

eladg commented 2 years ago

https://www.ffmpegbyexample.com/examples/6gzhzpjp/generate_solid_color_264_video_with_the_color_video_source_filter_color_hex_code/

The following uses a video source generator and the color filter to generate a solid color video.

The generated video frames are then scaled using -s 1280x720 and a 30 fps h.264 video is generated using -r 30 -c:v libx264 -crf 31.

Since this generated creates unlimited frames, the -t 5 parameter limits the output to 5 seconds.

hunterhogan commented 1 year ago

I suggest moving the time limit option, -t, from the output to the input. Therefore:

ffmpeg -t 5 -f lavfi -i "color=c=0x4d1a7f" -s 1280x720 -r 30 -c:v libx264 -crf 31 solid.mp4

I have two reasons for the suggestion. First, this example is about generating the input, and putting the time limit with the generation makes the generation a complete unit. Second, when limiting streams by time, FFmpeg performs better when the limit are placed on the inputs rather than the outputs.