I am trying to convert a series of pngs into an mp4 video. I am using ffmpeg, and want to encode the video with the H.264 codec. Using the command

ffmpeg -y -r 30 -b 1800k -i _tmp%04d.png -vcodec libx264 out.mp4

I get the following warning message

Incompatible pixel format 'bgra' for codec 'libx264', auto-selecting format 'yuv420p'

My understanding is that there is an alpha channel in the pngs, which the x264 encoder cannot handle. Is there a way to get around this problem? Is there, for example, a way to get the encoder to ignore the alpha channel (my pngs don't actually have any transparent elements)?

I'm aware that I could batch convert the pngs beforehand to strip the alpha channel, but the sequence of images is produced by another program, and having to preprocess the images each time I make a video would be less than optimal.

Edit: After stripping the alpha channel from each frame using the command

convert in.png -background white -flatten +matte out.png

ffmpeg gives the warning message

Incompatible pixel format 'pal8' for codec 'libx264', auto-selecting format 'yuv420p'

so still no dice.

  • 1
    The Incompatible pixel format is just a warning, not an error. Does your output actually work, or are there artifacts? Also, please include the full, uncut command line output from FFmpeg dor debugging purposes. // @Louis The OP wants x264, not H.264. – slhck Dec 3 '12 at 7:38
  • @slhck but x264 is a program not a codec. – Louis Dec 3 '12 at 7:45

I was thinking of using AVISynth and frame serving to get around the problem, but it looks like ffmpeg now has native support for AVISynth. Meaning you can use AVISynth scripts as input.

So with a script, sequence.avs, you could do:
ffmpeg -i sequence.avs -vcodec libx264 out.mp4

Where sequence.avs is:
ImageSource("_tmp%04d.png", start=0, end=1, fps=30).ConvertToYV12()

Note: The optional start and end parameters reflect that I tested with two images, _tmp0000.png and _tmp0001.png.

See also: More color formats. The ImageSource documentation.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.