3

I'm trying to find the optimum settings for creating a .mp4 file that will load easilly both on Mac and Windows.

Right now with these settings

f image2 -pattern_type glob -i '*.png' -vcodec libx264 -preset ultrafast -qp 0 out.mp4

the resulting .mp4 can not be launched in OSX. ie Quicktime says the file is damaged and I can only view if I drag to an empty browser window.

Here is my complete output

Administrators-iMac:anim foo$ ffmpeg -f image2 -pattern_type glob -i '*.png' -vcodec libx264 -preset ultrafast -qp 0 out.mp4
ffmpeg version 2.5.3 Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 17 2015 12:08:40 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, image2, from '*.png':
  Duration: 00:00:05.76, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba, 1080x720, 25 fps, 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x7fc9e2801800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fc9e2801800] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x7fc9e2801800] 264 - core 142 r2455 021c0dc - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf56.15.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 1080x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.13.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=  144 fps=0.0 q=-1.0 Lsize=     606kB time=00:00:05.76 bitrate= 862.5kbits/s    
video:605kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.225304%
[libx264 @ 0x7fc9e2801800] frame I:1     Avg QP: 0.00  size:181499
[libx264 @ 0x7fc9e2801800] frame P:143   Avg QP: 0.00  size:  3060
[libx264 @ 0x7fc9e2801800] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x7fc9e2801800] mb P  I16..4: 77.8%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:22.2%
[libx264 @ 0x7fc9e2801800] coded y,u,v intra: 0.2% 0.1% 0.1% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7fc9e2801800] i16 v,h,dc,p: 100%  0%  0%  0%
[libx264 @ 0x7fc9e2801800] kb/s:859.84
2
  • Full, uncut command line output is missing. OS X and recent Windows can play regular H.264 video in MP4 just fine, so it must be something else, which we cannot troubleshoot without seeing the log.
    – slhck
    Commented Feb 6, 2015 at 15:59
  • have edited the question to provide full output! Please help...
    – Bachalo
    Commented Feb 6, 2015 at 16:19

1 Answer 1

6

There are two problems:

  • You're using PNG images as input. When converting images to video, the ffmpeg tries to preserve the image colorspace by choosing the yuv444p pixel format, which uses no chroma subsampling. Like it says:

    No pixel format specified, yuv444p for H.264 encoding chosen.
    Use -pix_fmt yuv420p for compatibility with outdated media players.
    

    QuickTime and Windows Media Player are such "outdated" media players. Most FFmpeg-based players such as VLC can handle this kind of video though.

  • -qp 0 (much like -crf 0) enables the lossless mode in x264, which makes the file use the High 4:4:4 Predictive Profile. This profile is not supported in QuickTime. It may very well be unsupported in Windows Media Player as well (but I couldn't check).

To ensure compatibility, you should always therefore add the option -pix_fmt yuv420p and choose a lossy encoding method, ideally by using CRF encoding, and setting -crf to a reasonable value. CRF default is 23, but anything from 18–28 is fine, where lower means better quality.

Note that older versions of Windows do not support H.264 at all. Here you'd have to fall back to MPEG-2 or even MPEG-1. See also:

Read the H.264 encoding guide for more encoding strategies.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .