Convert WMV to mp4 using ffmpeg get Black screen

HawkEye000 picture HawkEye000 · Sep 19, 2014 · Viewed 7.9k times · Source

When converting an .wmv file to .mp4 i used this command:

exec("ffmpeg -i file.wmv -vcodec mpeg4 -acodec libfaac -b 1200 -r 15 -s 320x240 -pix_fmt yuv420p file.mp4");

Sound is fine but i have no image (using html5 not when downloaded to pc) . this is the outputs :

FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[wmv3 @ 0xc2daa0]Extra data: 8 bits left, value: 20

Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 30.00 (30/1)
Input #0, asf, from '/home/xxx/public_html/new/zawmju.wmv':
  Metadata:
    Application     : Windows Movie Maker 2.6.4037.0
    WM/ParentalRating: 
    WMFSDKVersion   : 12.0.9200.16384
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    title           : 
    author          : SahlaTube
    copyright       : 
    comment         : 
  Duration: 00:00:04.03, start: 2.000000, bitrate: 740 kb/s
    Stream #0.0: Audio: wmav2, 44100 Hz, 2 channels, s16, 64 kb/s
    Stream #0.1: Video: wmv3, yuv420p, 640x480, 30 tbr, 1k tbn, 1k tbc
[wmv3 @ 0xc2daa0]Extra data: 8 bits left, value: 20
Output #0, mp4, to '/home/xxx/public_html/new/zawmju.wmv.mp4':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 1 kb/s, 15 tbn, 15 tbc
    Stream #0.1: Audio: libfaac, 44100 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop encoding
frame=   61 fps=  0 q=24.8 Lsize=      82kB time=4.02 bitrate= 166.4kbits/s dup=0 drop=59    

video:55kB audio:24kB global headers:0kB muxing overhead 3.828952%

Answer

user2452253 picture user2452253 · Sep 19, 2014

First upgrade your ffmpeg version and then change the encoder to libx264 (H.264 video) instead of mpeg4 (MPEG-4 Part 2 video):

ffmpeg -i file.wmv -vcodec libx264 -pix_fmt yuv420p -profile:v baseline \
-preset slow -crf 22 -movflags +faststart output.mp4

You can use the scale video filter to resize if desired, such as -vf scale=320:-2.

Also see: