3

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).

The first output against superuser page

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_formatoption doesn't work either.

So... how do you create a pure white background video with ffmpeg?

cdlvcdlv
  • 1,461
  • 1
  • 19
  • 27
  • 1
    With 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 Dec 07 '16 at 12:30
  • My `ffplay` and `ffmpeg` are both `N-81308-g369ed11`, that I compiled in August. Maybe this issue has been corrected? `-color_range 1` does not change anything. – cdlvcdlv Dec 07 '16 at 12:39
  • 2
    What about `ffplay -f lavfi -i color=white:640x480:d=3` – Gyan Dec 07 '16 at 12:47
  • Nada. Same thing. – cdlvcdlv Dec 07 '16 at 15:01
  • 1
    Which OS is this? – Gyan Dec 07 '16 at 15:05
  • Windows XP x64, but the operation of `ffmpeg` should be the same, I think. I compiled it natively. – cdlvcdlv Dec 07 '16 at 15:23
  • 1
    I'm also using a compiled version. Try it with the Zeranoe build, in any case. – Gyan Dec 07 '16 at 15:25
  • 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 Dec 07 '16 at 15:37
  • 1
    Output to PNG. And try the builds [here](https://sourceforge.net/projects/mplayer-win32/files/FFmpeg/git-N-82759-g1f5630a/). – Gyan Dec 07 '16 at 15:51
  • Indeed, these builds work in XP. Since they lack `ffplay`, I created an avi with `ffmpeg -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 Dec 07 '16 at 16:18
  • 1
    It 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 Dec 07 '16 at 16:31
  • 1
    BTW, 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 Dec 07 '16 at 16:32
  • 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 Dec 07 '16 at 21:28
  • 1
    What video card are you using? – Gyan Dec 09 '16 at 10:59
  • Nvidia GeForce FX 5200 Bios 4.34.20.80.02 – cdlvcdlv Dec 09 '16 at 18:30
  • 1
    Ok, 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 Dec 09 '16 at 19:02
  • 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 `ffmpeg`. 1st, it seems you cannot set `pixel_format` in `color` source filter - it's always `yuv420p`. 2nd, `ffplay` always convert to `color_range 1` ([or `2` depending on the documentation](https://trac.ffmpeg.org/ticket/3409#comment:7)). – cdlvcdlv Dec 12 '16 at 19:11
  • To test, I created an avisynth script with the following line: `BlankClip(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](http://turtlewar.org/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). – cdlvcdlv Dec 12 '16 at 19:12
  • 1
    *it 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 Dec 12 '16 at 19:18
  • That 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 Dec 13 '16 at 18:36

1 Answers1

4

As detailed in the comments, converting to a RGB format provides a full-range output.

-f lavfi -i color=white:640x480:d=3,format=rgb24

For other readers, I should note that I get a pure white display when running the OP's original command. I can't diagnose what's happening on OP's setup but there should be no special steps needed to generate a pure white output from ffmpeg other than color=white.

Gyan
  • 34,439
  • 6
  • 56
  • 98