2.06.2013

mp4 video in chrome

I was having a really hard time getting mp4 video to render in Chrome with the html 5 <video> tag.  After screwing around with ffmpeg for a day I think I found the correct settings.  I used the following command line to transcode a wmv to the proper mp4:

$ ffmpeg -i movie.wmv -pix_fmt yuv420p -vf setsar='1/1' vid.mp4

The key difference from the default .wmv -> .mp4 conversion is specifying the pixel format as yuv420p and setting the storage aspect ratio (SAR) to 1:1 (or 1/1). The default using a rgb pixel format and inherites the storage aspect ratio from the source... which may or may not be one to one. The resulting video looks like this:



$ ffprobe -show_format vid.mp4 
ffprobe version 1.1.git Copyright (c) 2007-2013 the FFmpeg developers
  built on Feb  5 2013 07:56:01 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.100 / 54. 91.100
  libavformat    54. 61.104 / 54. 61.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 35.101 /  3. 35.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.61.104
  Duration: 00:00:17.07, start: 0.000000, bitrate: 1817 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 880x646 [SAR 1:1 DAR 440:323], 1814 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandler
[FORMAT]
filename=vid.mp4
nb_streams=1
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=17.067000
size=3877456
bit_rate=1817522
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:encoder=Lavf54.61.104
[/FORMAT]

No comments:

Post a Comment