我的服务器有:
- 8x3,4 (Sandy Bridge CPU)
- 10GB 内存
我尝试了不同的组合来转换视频,也就是将 avi 转换为 mp4,但这需要很长时间:- ~20 分钟 = ~200mb
也许有一些 ffmpeg 命令可以更快地完成此操作?
使用超快速编辑:
root@1tb:~/test# ffmpeg -i video.avi -c:v libx264 -preset ultrafast out.mp4
ffmpeg version git-2013-10-28-f1f0b01 Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 29 2013 02:05:45 with gcc 4.4.5 (Debian 4.4.5-8)
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, avi, from 'video.avi':
Duration: 00:29:00.28, start: 0.000000, bitrate: 1120 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
Metadata:
title : Hello.Ladies.S01E06.HDTV.XviD-AFG_360p.audio
[libx264 @ 0x2e08e40] using SAR=1/1
[libx264 @ 0x2e08e40] using cpu capabilities: none!
[libx264 @ 0x2e08e40] profile Constrained Baseline, level 3.0
[libx264 @ 0x2e08e40] 264 - core 138 r2358 9e941d1 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=23 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf55.19.104
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 10000k tbn, 23.98 tbc
Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
Metadata:
title : Hello.Ladies.S01E06.HDTV.XviD-AFG_360p.audio
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> libx264)
Stream #0:1 -> #0:1 (mp3 -> libfaac)
Press [q] to stop, [?] for help
frame=41726 fps=326 q=-1.0 Lsize= 312916kB time=00:29:00.32 bitrate=1473.0kbits/s dup=1 drop=0
video:284876kB audio:27186kB subtitle:0 global headers:0kB muxing overhead 0.273494%
[libx264 @ 0x2e08e40] frame I:167 Avg QP:18.69 size: 30492
[libx264 @ 0x2e08e40] frame P:41559 Avg QP:21.68 size: 6897
[libx264 @ 0x2e08e40] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x2e08e40] mb P I16..4: 6.3% 0.0% 0.0% P16..4: 51.2% 0.0% 0.0% 0.0% 0.0% skip:42.5%
[libx264 @ 0x2e08e40] coded y,uvDC,uvAC intra: 44.9% 54.5% 19.0% inter: 28.1% 20.3% 2.2%
[libx264 @ 0x2e08e40] i16 v,h,dc,p: 43% 23% 21% 13%
[libx264 @ 0x2e08e40] i8c dc,h,v,p: 36% 22% 32% 11%
[libx264 @ 0x2e08e40] kb/s:1340.96
root@1tb:~/test# qt-faststart out.mp4 labas1.mp4
ftyp 0 32
free 32 8
mdat 40 319552104
moov 319552144 873943
patching stco atom...
patching stco atom...
writing ftyp atom...
writing moov atom...
copying rest of file...
root@1tb:~/test#
答案1
我在 ffmpeg 输出中没有看到“-enable-pthread”。使用该选项(+ asm 支持)构建 ffmpeg 和 x264,您将能够运行得更快。
请注意,如果你添加
-threads 0
在您的 ffmpeg 命令行中,该过程将工作负载分散到您的所有核心上(检查运行期间的 CPU 使用率以查看差异......)