使用ffmpeg获取黑屏将WMV转换为mp4

时间:2014-09-19 00:19:55

标签: video ffmpeg mp4 wmv

将.wmv文件转换为.mp4时,我使用了以下命令:

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

声音很好但我没有图像(使用html5时没有下载到电脑上)。 这是输出:

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%

1 个答案:

答案 0 :(得分:5)

首先升级您的ffmpeg版本,然后将编码器更改为libx264(H.264视频),而不是mpeg4(MPEG-4第2部分视频):

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

如果需要,您可以使用scale video filter调整大小,例如-vf scale=320:-2

另见: