1
I want to create with ffmpeg a pure white video to use it as background. I mean a video that, played in a computer, you see as white. (In the examples I will pipe the output to ffplay so you don't need to delete the video later.)
To create a 3s 640x480 video (25 fps by default):
ffmpeg -f lavfi -i color=white:640x480:d=3 -f matroska - | ffplay -autoexit -
This is a small rectangle of the output against superuser page (which in my browser shows as white).
Looking for an answer, I came to this question. The explanation is provided by Mulvya:
The padding is RGB 235, which is the upper limit in conventional video. So, a video player will expand 235 to show white. – Mulvya Oct 23 '15 at 17:44
But I found no player that show it as white. I tried with ffplay, MPC-HC and VLC both piping and creating an intermediate file.
With images as in the question, the solution seems to be adding the -format rgb32
option. But I get the same result with
ffmpeg -f lavfi -i color=white:640x480:d=3 -format rgb32 -f matroska - | ffplay -autoexit -
The -pixel_format
option doesn't work either.
So... how do you create a pure white background video with ffmpeg?
1With your first command, I get pure white (#FF) as confirmed by Photoshop. I also get white when I output to a webm and play in Firefox. Try adding
-color_range 1
just before-f matroska
. Also, upgrade your ffmpeg, in case you're using an old version. – Gyan – 2016-12-07T12:30:54.190My
ffplay
andffmpeg
are bothN-81308-g369ed11
, that I compiled in August. Maybe this issue has been corrected?-color_range 1
does not change anything. – cdlvcdlv – 2016-12-07T12:39:44.0801What about
ffplay -f lavfi -i color=white:640x480:d=3
– Gyan – 2016-12-07T12:47:22.100Nada. Same thing. – cdlvcdlv – 2016-12-07T15:01:47.967
1Which OS is this? – Gyan – 2016-12-07T15:05:50.790
Windows XP x64, but the operation of
ffmpeg
should be the same, I think. I compiled it natively. – cdlvcdlv – 2016-12-07T15:23:56.8131I'm also using a compiled version. Try it with the Zeranoe build, in any case. – Gyan – 2016-12-07T15:25:29.257
I'll need a W7 or later to try (Zeranoe's builds are XP incompatible since months). In the mean time, another ideas are welcome. – cdlvcdlv – 2016-12-07T15:37:15.733
1
Output to PNG. And try the builds here.
– Gyan – 2016-12-07T15:51:11.930Indeed, these builds work in XP. Since they lack
ffplay
, I created an avi withffmpeg -f lavfi -i color=white:640x480:d=3 -color_range 1 -format rgb32 -c:v huffyuv o.h.avi
and played later, but the output keeps being 235/255. Generated PNG is real white, but I need a variable duration source video because my idea is adding some other inputs to the command and use several filters to add content on the background to generate the output video. But I never thought I wouldn't be able to give this first step. I thought it would be trivial. – cdlvcdlv – 2016-12-07T16:18:06.3071It is trivial.Don't know why it's not working for you :( You can output to PNG in MOV to get a video e.g.
ffmpeg -f lavfi -i color=white:640x480:d=3 -color_range 2 -c:v png video.mov
– Gyan – 2016-12-07T16:31:06.5831BTW, if the idea is to add content on top. You don't need to save the white canvas to file. Just feed it directly to filters. – Gyan – 2016-12-07T16:32:44.133
Exactly. My intention is not to save the white video (the 3 s duration is arbitrary, just to test), but to use it as a source background with some other content and generate a final x264 video all in one command. I didn't include the additional filters I intend to use just to isolate the problem. – cdlvcdlv – 2016-12-07T21:28:59.650
1What video card are you using? – Gyan – 2016-12-09T10:59:05.410
Nvidia GeForce FX 5200 Bios 4.34.20.80.02 – cdlvcdlv – 2016-12-09T18:30:41.373
1Ok, I remember in the Nvidia Control Panel, there being a 'Adjust video color setting'. Which if you allow Nvidia to control instead of the video player lets you set what the input range is. See what that says. – Gyan – 2016-12-09T19:02:39.760
I've been fiddling around with the controls of the NCP but I could see no difference in any player. I managed to test latest Zeranoe build in a W7 with the same results as XP. I think I'll do this thing with avisynth because I've found out several issues with my original command using
– cdlvcdlv – 2016-12-12T19:11:33.367ffmpeg
. 1st, it seems you cannot setpixel_format
incolor
source filter - it's alwaysyuv420p
. 2nd,ffplay
always convert tocolor_range 1
(or2
depending on the documentation).To test, I created an avisynth script with the following line:
– cdlvcdlv – 2016-12-12T19:12:57.690BlankClip(length=75, width=640, height=480, fps=25, color=$FFFFFF, pixel_type="RGB24").KillAudio
, "ffplayed" it and got grey (color_range
does nothing here, no matter before-i
or after it). Both MPC-HC and VLC (through AVFS) play it as white. So I think my source will be and .avs and will compress the final product with ffmpeg (being very careful and double-cheking).1it seems you cannot set pixel_format in color source filter --> you add a format filter afterwards.
-f lavfi -i color=white:640x480:d=3,format=rgb24
– Gyan – 2016-12-12T19:18:53.097That did work! I found the
format
option but I thought I should use a colon, not a comma, as separator and got an error. You cannot use ffplay to check the result though; no matter the option you try, ffplay always shows grey. But I can use MPC-HC like this:ffmpeg -hide_banner -f lavfi -i color=white:640x480:d=3,format=rgb24 -c:v rawvideo -f nut - | mpc-hc.exe -
. It's a valid answer to my question so, if you write it as answer, I'll accept it. – cdlvcdlv – 2016-12-13T18:36:40.047