不使用ffmpeg将flv文件转换为mp4文件

时间:2015-10-03 10:39:00

标签: php ffmpeg centos

我为我的centos server安装了ffmpeg。然后我使用ffmpeg将我的flv文件转换为mp4。但是它创建了0字节错误的mp4文件。 转换代码

shell_exec('/usr/local/bin/ffmpeg -i ffmpeg/test1.flv-c copy -copyts ffmpeg/test.mp4');

ffmpeg版本是

ffmpeg version N-75682-g5fa5e73 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
  configuration:
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  3.100 / 57.  3.100
  libavformat    57.  2.102 / 57.  2.102
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  9.101 /  6.  9.101
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfi     
le}...

运行后我得到以下输出

ffmpeg version N-75682-g5fa5e73 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
  configuration:
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  3.100 / 57.  3.100
  libavformat    57.  2.102 / 57.  2.102
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  9.101 /  6.  9.101
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
Input #0, flv, from 'ffmpeg/test1.flv':
  Metadata:
    starttime       : 0
    totalduration   : 67
    totaldatarate   : 354
    bytelength      : 2954448
    canseekontime   : true
    sourcedata      : BD075F34AHM1443878448533564
    purl            :
    pmsg            :
    httphostheader  : r7---sn-xupn5a5u-4wge7.googlevideo.com
  Duration: 00:01:06.63, start: 0.000000, bitrate: 354 kb/s
    Stream #0:0: Video: flv1, yuv420p, 426x240, 288 kb/s, 30 fps, 30 tbr, 1k tbn                                                                                                                                                             , 1k tbc
    Stream #0:1: Audio: mp3, 22050 Hz, mono, s16p, 65 kb/s
[aac @ 0x2b4b640] The encoder 'aac' is experimental but experimental codecs are                                                                                                                                                              not enabled, add '-strict -2' if you want to use it.

1 个答案:

答案 0 :(得分:0)

请试试这个

/usr/local/bin/ffmpeg -i ffmpeg/test1.flv -strict -2 ffmpeg/test1.mp4

它会起作用。