FFmpeg 命令将 M4V 转换为 FLV;视频流非常慢

FFmpeg 命令将 M4V 转换为 FLV;视频流非常慢

我正在使用此命令将视频从 M4V 和 AVI 转换为 FLV:

ffmpeg -i 'video_1355440448.m4v' -s '640x360' -ab '64k' -ar '44100' -q:v '1' -f 'flv' -y video_1355440448.flv

我有两台服务器:

  • 一台服务器的 FFmpeg 版本为 N-48249-g5079568,视频运行良好。
  • 另一台服务器的 FFmpeg 版本为 N-48332-gfe5a2fc,视频无法正常工作。

两个服务器都没有错误,并且两个服务器转换的视频大小相同。如果我点击播放此视频,它会暂停缓冲,大约 30 秒后开始播放。

一台服务器用黑线显示哪部分已加载,但另一台服务器却不显示。

我发现一台服务器有

[root@server ~]# whereis ffmpeg
ffmpeg: /usr/local/bin/ffmpeg
[root@server ~]# whereis mencoder
mencoder: /usr/local/bin/mencoder
[root@server ~]# whereis flvtool2
flvtool2: /usr/bin/flvtool2
[root@server ~]# 

另一台服务器

[email protected] [~]# whereis ffmpeg
ffmpeg: /usr/local/bin/ffmpeg
[email protected] [~]# whereis mencoder
mencoder:
[email protected] [~]# whereis flvtool2
flvtool2:
[email protected] [~]# 

第一台服务器:

[root@server ~]# ffmpeg -i '/home/indus33/public_html/machine_manuals/zindagi.avi' -s '640x360' -ab '64k' -ar '44100' -f 'flv' -q:v '1' -y /home/indus33/public_html/machine_manuals/video_zindagi.flv
ffmpeg version N-48249-g5079568 Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 28 2012 11:45:15 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree
  libavutil 52. 12.100 / 52. 12.100
  libavcodec 54. 81.100 / 54. 81.100
  libavformat 54. 50.104 / 54. 50.104
  libavdevice 54. 3.102 / 54. 3.102
  libavfilter 3. 30.101 / 3. 30.101
  libswscale 2. 1.103 / 2. 1.103
  libswresample 0. 17.102 / 0. 17.102
  libpostproc 52. 2.100 / 52. 2.100
[avi @ 0x27f5900] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from '/home/indus33/public_html/machine_manuals/zindagi.avi':
  Metadata:
    encoder : Lavf54.6.100
  Duration: 00:02:10.44, start: 0.000000, bitrate: 824 kb/s
  Stream #0:0: Video: msmpeg4v2 (MP42 / 0x3234504D), yuv420p, 320x240, 25 tbr, 25 tbn, 25 tbc
  Stream #0:1: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16, 352 kb/s
Output #0, flv, to '/home/indus33/public_html/machine_manuals/video_zindagi.flv':
  Metadata:
    encoder : Lavf54.50.104
  Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 640x360, q=2-31, 200 kb/s, 1k tbn, 25 tbc
  Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16p, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (msmpeg4v2 -> flv)
  Stream #0:1 -> #0:1 (adpcm_ms -> libmp3lame)
Press [q] to stop, [?] for help
frame= 155 fps=0.0 q=1.0 size= 2109kB time=00:00:06.24 bitrate=2768.6kbits/sframe= 291 fps=290 q=1.0 size= 4659kB time=00:00:11.68 bitrate=3267.5kbits/sframe= 419 fps=279 q=1.0 size= 6979kB time=00:00:16.80 bitrate=3403.0kbits/sframe= 561 fps=280 q=1.0 size= 9508kB time=00:00:22.48 bitrate=3464.7kbits/sframe= 711 fps=284 q=1.0 size= 11691kB time=00:00:28.48 bitrate=3362.9kbits/sframe= 857 fps=285 q=1.0 size= 14044kB time=00:00:34.32 bitrate=3352.3kbits/sframe= 1005 fps=287 q=1.0 size= 16310kB time=00:00:40.24 bitrate=3320.4kbits/sframe= 1155 fps=288 q=1.0 size= 18344kB time=00:00:46.24 bitrate=3249.9kbits/sframe= 1303 fps=289 q=1.0 size= 20685kB time=00:00:52.16 bitrate=3248.7kbits/sframe= 1452 fps=290 q=1.0 size= 23081kB time=00:00:58.12 bitrate=3253.3kbits/sframe= 1585 fps=288 q=1.0 size= 25946kB time=00:01:03.44 bitrate=3350.4kbits/sframe= 1725 fps=287 q=1.0 size= 28713kB time=00:01:09.04 bitrate=3406.9kbits/sframe= 1863 fps=286 q=1.0 size= 30890kB time=00:01:14.56 bitrate=3393.9kbits/sframe= 2008 fps=286 q=1.0 size= 33400kB time=00:01:20.36 bitrate=3404.8kbits/sframe= 2150 fps=286 q=1.0 size= 36046kB time=00:01:26.04 bitrate=3432.0kbits/sframe= 2292 fps=286 q=1.0 size= 38434kB time=00:01:31.72 bitrate=3432.8kbits/sframe= 2443 fps=287 q=1.0 size= 40747kB time=00:01:37.76 bitrate=3414.5kbits/sframe= 2590 fps=287 q=1.0 size= 43170kB time=00:01:43.64 bitrate=3412.3kbits/sframe= 2730 fps=287 q=1.0 size= 45488kB time=00:01:49.24 bitrate=3411.2kbits/sframe= 2871 fps=287 q=1.0 size= 48315kB time=00:01:54.88 bitrate=3445.3kbits/sframe= 2988 fps=283 q=1.0 size= 50770kB time=00:01:59.56 bitrate=3478.7kbits/sframe= 3131 fps=283 q=1.0 size= 53303kB time=00:02:05.28 bitrate=3485.4kbits/sframe= 3260 fps=283 q=1.0 Lsize= 55572kB time=00:02:10.45 bitrate=3489.6kbits/s
video:54423kB audio:1019kB subtitle:0 global headers:0kB muxing overhead 0.233212%

其他服务器:

[email protected] [~]# ffmpeg -i '/home/machine/public_html/sterlingadmin/files/zindagi.avi' -s '640x360' -ab '64k' -ar '44100' -f 'flv' -q:v '1' -y /home/machine/public_html/sterlingadmin/files/video_zindagi_old.flv
ffmpeg version N-48332-gfe5a2fc Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 30 2012 23:42:22 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-52)
configuration: --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree --enable-shared --extra-cflags=-fPIC
libavutil 52. 13.100 / 52. 13.100
libavcodec 54. 85.100 / 54. 85.100
libavformat 54. 57.100 / 54. 57.100
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 30.102 / 3. 30.102
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[avi @ 0x16d55900] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from '/home/machine/public_html/sterlingadmin/files/zindagi.avi':
  Metadata:
    encoder : Lavf54.6.100
  Duration: 00:02:10.44, start: 0.000000, bitrate: 824 kb/s
  Stream #0:0: Video: msmpeg4v2 (MP42 / 0x3234504D), yuv420p, 320x240, 25 tbr, 25 tbn, 25 tbc
  Stream #0:1: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16, 352 kb/s
Output #0, flv, to '/home/machine/public_html/sterlingadmin/files/video_zindagi_old.flv':
  Metadata:
    encoder : Lavf54.57.100
  Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 640x360, q=2-31, 200 kb/s, 1k tbn, 25 tbc
  Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16p, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (msmpeg4v2 -> flv)
  Stream #0:1 -> #0:1 (adpcm_ms -> libmp3lame)
Press [q] to stop, [?] for help
frame= 72 fps=0.0 q=1.0 size= 911kB time=00:00:02.92 bitrate=2554.8kbits/sframe= 149 fps=149 q=1.0 size= 2036kB time=00:00:06.00 bitrate=2780.2kbits/sframe= 210 fps=139 q=1.0 size= 3060kB time=00:00:08.44 bitrate=2969.6kbits/sframe= 277 fps=138 q=1.0 size= 4343kB time=00:00:11.12 bitrate=3199.3kbits/sframe= 346 fps=138 q=1.0 size= 5802kB time=00:00:13.88 bitrate=3424.4kbits/sframe= 417 fps=138 q=1.0 size= 6944kB time=00:00:16.72 bitrate=3402.3kbits/sframe= 487 fps=139 q=1.0 size= 8066kB time=00:00:19.52 bitrate=3384.9kbits/sframe= 556 fps=139 q=1.0 size= 9435kB time=00:00:22.28 bitrate=3468.9kbits/sframe= 641 fps=142 q=1.0 size= 10663kB time=00:00:25.68 bitrate=3401.6kbits/sframe= 730 fps=146 q=1.0 size= 11968kB time=00:00:29.24 bitrate=3353.0kbits/sframe= 812 fps=147 q=1.0 size= 13357kB time=00:00:32.52 bitrate=3364.6kbits/sframe= 894 fps=149 q=1.0 size= 14667kB time=00:00:35.80 bitrate=3356.1kbits/sframe= 981 fps=151 q=1.0 size= 15970kB time=00:00:39.28 bitrate=3330.6kbits/sframe= 1072 fps=153 q=1.0 size= 17080kB time=00:00:42.92 bitrate=3259.9kbits/sframe= 1154 fps=153 q=1.0 size= 18341kB time=00:00:46.20 bitrate=3252.2kbits/sframe= 1228 fps=153 q=1.0 size= 19483kB time=00:00:49.16 bitrate=3246.6kbits/sframe= 1310 fps=154 q=1.0 size= 20778kB time=00:00:52.44 bitrate=3245.9kbits/sframe= 1398 fps=155 q=1.0 size= 22162kB time=00:00:55.96 bitrate=3244.3kbits/sframe= 1481 fps=155 q=1.0 size= 23711kB time=00:00:59.28 bitrate=3276.7kbits/sframe= 1560 fps=156 q=1.0 size= 25418kB time=00:01:02.44 bitrate=3334.8kbits/sframe= 1640 fps=156 q=1.0 size= 27078kB time=00:01:05.64 bitrate=3379.4kbits/sframe= 1723 fps=156 q=1.0 size= 28696kB time=00:01:08.96 bitrate=3408.9kbits/sframe= 1805 fps=156 q=1.0 size= 30145kB time=00:01:12.24 bitrate=3418.5kbits/sframe= 1896 fps=158 q=1.0 size= 31242kB time=00:01:15.88 bitrate=3372.8kbits/sframe= 1976 fps=158 q=1.0 size= 32664kB time=00:01:19.08 bitrate=3383.7kbits/sframe= 2042 fps=157 q=1.0 size= 34108kB time=00:01:21.72 bitrate=3419.1kbits/sframe= 2111 fps=156 q=1.0 size= 35313kB time=00:01:24.48 bitrate=3424.3kbits/sframe= 2193 fps=156 q=1.0 size= 36785kB time=00:01:27.76 bitrate=3433.7kbits/sframe= 2263 fps=156 q=1.0 size= 38004kB time=00:01:30.56 bitrate=3437.8kbits/sframe= 2333 fps=155 q=1.0 size= 39097kB time=00:01:33.36 bitrate=3430.7kbits/sframe= 2407 fps=155 q=1.0 size= 40212kB time=00:01:36.32 bitrate=3420.0kbits/sframe= 2480 fps=155 q=1.0 size= 41414kB time=00:01:39.24 bitrate=3418.6kbits/sframe= 2552 fps=154 q=1.0 size= 42702kB time=00:01:42.12 bitrate=3425.5kbits/sframe= 2615 fps=153 q=1.0 size= 43509kB time=00:01:44.64 bitrate=3406.2kbits/sframe= 2674 fps=152 q=1.0 size= 44482kB time=00:01:47.00 bitrate=3405.6kbits/sframe= 2724 fps=151 q=1.0 size= 45356kB time=00:01:49.00 bitrate=3408.8kbits/sframe= 2784 fps=150 q=1.0 size= 46560kB time=00:01:51.40 bitrate=3423.8kbits/sframe= 2848 fps=149 q=1.0 size= 47857kB time=00:01:53.96 bitrate=3440.2kbits/sframe= 2912 fps=149 q=1.0 size= 49173kB time=00:01:56.52 bitrate=3457.2kbits/sframe= 2972 fps=148 q=1.0 size= 50434kB time=00:01:58.92 bitrate=3474.3kbits/sframe= 3033 fps=147 q=1.0 size= 51545kB time=00:02:01.36 bitrate=3479.4kbits/sframe= 3101 fps=147 q=1.0 size= 52729kB time=00:02:04.08 bitrate=3481.3kbits/sframe= 3184 fps=148 q=1.0 size= 54209kB time=00:02:07.40 bitrate=3485.7kbits/sframe= 3260 fps=148 q=1.0 Lsize= 55572kB time=00:02:10.45 bitrate=3489.6kbits/s
video:54423kB audio:1019kB subtitle:0 global headers:0kB muxing overhead 0.233212%

答案1

不使用-sameq。这并不意味着相同的质量,可能会产生一个巨大的输出文件(因此加载时间很长),并且最近已从 FFmpeg 中删除。

m4v 容器中的视频可能是 H.264,FLV 容器可以轻松处理,因此考虑简单地复制视频而不是重新编码:

ffmpeg -i input.m4v -vcodec copy -acodec libmp3lame -aq 4 -ar 44100 output.flv

如果您想要重新编码以制作比输入文件更小的输出文件,请参阅FFmpeg 和 x264 编码指南。如果您的目标是特定的输出文件大小,请使用两遍。否则使用 CRF。所有这些都在指南中进行了解释。

如果你的 FFmpeg 版本没有libmp3lame编码器,你应该下载最新的 Git 快照并自行编译(请参阅UbuntuCentOS编译指南),或者从FFmpeg 下载页面

相关内容