我使用 ffmpeg static。我有两台服务器。当我在第一个服务器上编码时,字幕可以工作;但在第二个服务器上却不行。
我安装了 fontconfig、fontconfig-devel、freetype、freetype-devel。
FFmpeg 命令:
ffmpeg -y -i 'test.mkv' -c:v libx264 -preset slow -c:a mp3 -b:a 100k -threads 0 -b:v 2000k -filter_complex "subtitles=sub.srt" -t 10 output.mp4
第一个服务器的ffmpeg输出:
ffmpeg version N-56828-gb5f219c Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 3 2013 05:27:30 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 46.100 / 52. 46.100
libavcodec 55. 33.101 / 55. 33.101
libavformat 55. 19.100 / 55. 19.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 88.100 / 3. 88.100
libswscale 2. 5.100 / 2. 5.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, matroska,webm, from 'test.mkv':
Duration: 00:41:31.92, start: 0.000000, bitrate: 7525 kb/s
Chapter #0.0: start 0.000000, end 269.680000
Metadata:
title : 00:00:00.000
Chapter #0.1: start 269.680000, end 725.120000
Metadata:
title : 00:04:29.680
Chapter #0.2: start 725.120000, end 1182.640000
Metadata:
title : 00:12:05.120
Chapter #0.3: start 1182.640000, end 1617.880000
Metadata:
title : 00:19:42.640
Chapter #0.4: start 1617.880000, end 2048.520000
Metadata:
title : 00:26:57.880
Chapter #0.5: start 2048.520000, end 2460.200000
Metadata:
title : 00:34:08.520
Chapter #0.6: start 2460.200000, end 2491.920000
Metadata:
title : 00:41:00.200
Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Stream #0:2(eng): Subtitle: subrip
Metadata:
title : SDH
Stream #0:3(eng): Subtitle: subrip
[libx264 @ 0x26ff380] using SAR=1/1
[libx264 @ 0x26ff380] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x26ff380] profile High, level 3.1
[libx264 @ 0x26ff380] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=abr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf55.19.100
Chapter #0.0: start 0.000000, end 10.000000
Metadata:
title : 00:00:00.000
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 12800 tbn, 25 tbc
Stream #0:1(eng): Audio: mp3 (libmp3lame) (i[0][0][0] / 0x0069), 48000 Hz, stereo, fltp, 100 kb/s (default)
Stream mapping:
Stream #0:0 (h264) -> subtitles (graph 0)
subtitles (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (dca -> libmp3lame)
Press [q] to stop, [?] for help
[Parsed_subtitles_0 @ 0x26aea00] Neither PlayResX nor PlayResY defined. Assuming 384x288
[Parsed_subtitles_0 @ 0x26aea00] fontconfig: Selected font is not the requested one: 'Nimbus Sans L' != 'Arial'
[Parsed_subtitles_0 @ 0x26aea00] fontconfig: Selected font is not the requested one: 'Nimbus Sans L' != 'Arial'
frame= 250 fps= 35 q=-1.0 Lsize= 6439kB time=00:00:10.00 bitrate=5270.6kbits/s
video:6311kB audio:118kB subtitle:0 global headers:0kB muxing overhead 0.163586%
[libx264 @ 0x26ff380] frame I:1 Avg QP: 8.00 size: 215
[libx264 @ 0x26ff380] frame P:81 Avg QP:17.42 size: 30915
[libx264 @ 0x26ff380] frame B:168 Avg QP:16.52 size: 23557
[libx264 @ 0x26ff380] consecutive B-frames: 0.4% 5.6% 73.2% 20.8%
[libx264 @ 0x26ff380] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x26ff380] mb P I16..4: 8.1% 9.9% 2.4% P16..4: 26.7% 2.7% 4.5% 0.0% 0.0% skip:45.8%
[libx264 @ 0x26ff380] mb B I16..4: 1.7% 4.6% 1.1% B16..8: 30.2% 3.0% 1.0% direct: 3.1% skip:55.4% L0:43.1% L1:54.1% BI: 2.8%
[libx264 @ 0x26ff380] final ratefactor: 18.24
[libx264 @ 0x26ff380] 8x8 transform intra:52.7% inter:84.1%
[libx264 @ 0x26ff380] direct mvs spatial:92.9% temporal:7.1%
[libx264 @ 0x26ff380] coded y,uvDC,uvAC intra: 66.5% 75.0% 58.2% inter: 10.8% 15.5% 4.4%
[libx264 @ 0x26ff380] i16 v,h,dc,p: 41% 13% 24% 22%
[libx264 @ 0x26ff380] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 9% 31% 9% 8% 7% 8% 8% 10%
[libx264 @ 0x26ff380] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 16% 23% 8% 8% 6% 7% 7% 8%
[libx264 @ 0x26ff380] i8c dc,h,v,p: 67% 15% 12% 5%
[libx264 @ 0x26ff380] Weighted P-Frames: Y:8.6% UV:4.9%
[libx264 @ 0x26ff380] ref P L0: 47.6% 7.1% 23.1% 9.2% 7.7% 5.3%
[libx264 @ 0x26ff380] ref B L0: 67.2% 20.0% 10.1% 2.7%
[libx264 @ 0x26ff380] ref B L1: 87.4% 12.6%
[libx264 @ 0x26ff380] kb/s:5169.56
第二台服务器的ffmpeg输出:
built on May 1 2014 05:35:16 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 80.100 / 52. 80.100
libavcodec 55. 60.100 / 55. 60.100
libavformat 55. 37.101 / 55. 37.101
libavdevice 55. 13.100 / 55. 13.100
libavfilter 4. 4.100 / 4. 4.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, matroska,webm, from 'test.mkv':
Metadata:
encoder : libebml v1.0.0 + libmatroska v1.0
Duration: 00:41:31.92, start: 0.000000, bitrate: 7525 kb/s
Chapter #0.0: start 0.000000, end 269.680000
Metadata:
title : 00:00:00.000
Chapter #0.1: start 269.680000, end 725.120000
Metadata:
title : 00:04:29.680
Chapter #0.2: start 725.120000, end 1182.640000
Metadata:
title : 00:12:05.120
Chapter #0.3: start 1182.640000, end 1617.880000
Metadata:
title : 00:19:42.640
Chapter #0.4: start 1617.880000, end 2048.520000
Metadata:
title : 00:26:57.880
Chapter #0.5: start 2048.520000, end 2460.200000
Metadata:
title : 00:34:08.520
Chapter #0.6: start 2460.200000, end 2491.920000
Metadata:
title : 00:41:00.200
Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Stream #0:2(eng): Subtitle: subrip
Metadata:
title : SDH
Stream #0:3(eng): Subtitle: subrip
[libx264 @ 0x2f05280] using SAR=1/1
[libx264 @ 0x2f05280] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x2f05280] profile High, level 3.1
[libx264 @ 0x2f05280] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=abr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/home/converted/output.mp4':
Metadata:
encoder : Lavf55.37.101
Chapter #0.0: start 0.000000, end 10.000000
Metadata:
title : 00:00:00.000
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 12800 tbn, 25 tbc (default)
Stream #0:1(eng): Audio: mp3 (libmp3lame) (i[0][0][0] / 0x0069), 48000 Hz, stereo, fltp, 100 kb/s (default)
Stream mapping:
Stream #0:0 (h264) -> subtitles (graph 0)
subtitles (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (dca -> libmp3lame)
Press [q] to stop, [?] for help
[Parsed_subtitles_0 @ 0x2e6fa00] Neither PlayResX nor PlayResY defined. Assuming 384x288
frame= 250 fps= 33 q=-1.0 Lsize= 6529kB time=00:00:10.00 bitrate=5343.9kbits/s
video:6401kB audio:118kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.161925%
[libx264 @ 0x2f05280] frame I:1 Avg QP: 8.00 size: 215
[libx264 @ 0x2f05280] frame P:81 Avg QP:17.34 size: 31290
[libx264 @ 0x2f05280] frame B:168 Avg QP:16.49 size: 23922
[libx264 @ 0x2f05280] consecutive B-frames: 0.4% 5.6% 73.2% 20.8%
[libx264 @ 0x2f05280] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x2f05280] mb P I16..4: 8.2% 10.0% 2.4% P16..4: 26.6% 2.7% 4.6% 0.0% 0.0% skip:45.6%
[libx264 @ 0x2f05280] mb B I16..4: 1.7% 4.7% 1.1% B16..8: 30.7% 3.0% 1.0% direct: 2.9% skip:54.9% L0:43.8% L1:53.3% BI: 3.0%
[libx264 @ 0x2f05280] final ratefactor: 18.25
[libx264 @ 0x2f05280] 8x8 transform intra:52.5% inter:84.0%
[libx264 @ 0x2f05280] direct mvs spatial:81.0% temporal:19.0%
[libx264 @ 0x2f05280] coded y,uvDC,uvAC intra: 66.7% 75.2% 58.6% inter: 10.8% 15.5% 4.4%
[libx264 @ 0x2f05280] i16 v,h,dc,p: 40% 13% 24% 23%
[libx264 @ 0x2f05280] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 9% 31% 9% 8% 7% 8% 8% 10%
[libx264 @ 0x2f05280] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 16% 23% 8% 8% 6% 7% 6% 8%
[libx264 @ 0x2f05280] i8c dc,h,v,p: 67% 15% 12% 5%
[libx264 @ 0x2f05280] Weighted P-Frames: Y:7.4% UV:4.9%
[libx264 @ 0x2f05280] ref P L0: 47.2% 7.2% 23.1% 9.4% 7.8% 5.4% 0.0%
[libx264 @ 0x2f05280] ref B L0: 68.4% 19.3% 9.7% 2.6%
[libx264 @ 0x2f05280] ref B L1: 87.4% 12.6%
[libx264 @ 0x2f05280] kb/s:5242.89
//编辑解决了问题 http://ahmetkapikiran.com/attach/fonts.zip解压到 /usr/share/fonts/