ffmpeg 转码几秒后停止

ffmpeg 转码几秒后停止

我尝试了一周的时间都没有成功,我尝试做的是从直播源转码视频并使用 FFmpeg 缩小它,但每次我开始转码时它都会广播约 11 秒然后停止。

我尝试的最后一个命令:

ffmpeg  -re  -i 'http://source.com/1034.ts' -preset ultrafast http://localhost:2052/feed1.ffm

我尝试使用 IDM 下载 .ts 文件,它在 FFmpeg 停止转码的准确约 12 秒内完成文件下载。

这是否意味着 FFmpeg 将该文件作为一个片段下载,而不是像视频播放器通常所做的那样继续阅读源视频。顺便说一句,我尝试使用 VLC 播放器播放源,但它并没有停止播放相同的源视频。

我决定通过 FFserver 配置文件传递 FFmpeg 命令ffserver.conf

Launch ffmpeg -i 'http://source.com/1.ts' -copyinkf -codec copy   

该流媒体运行良好,但测试了几个源之后,我注意到它在转码高清视频时很困难。

我猜问题出在我的 VPS KVM 服务器 CPU 和 RAM 非常有限(仅 128MB)!由于我尝试使用ultrafast预设但未能解决问题,另一件事,我注意到当我AVOptionVideo crf启用转码设置时ffserver.conf,运行起来很顺畅,帧率没有下降。我的服务器使用的Xeon L5520CPU 是过时的 CPU,特别是我消耗了 V 单核的 1/4 功率(如果算上 HT,它将是真实核心的 1/8):(

==更新==

看起来问题出在我使用的视频源上,他们的服务器负载很重,几秒钟后就丢失了连接,我的命令或 FFmpeg 也没有问题。

# vlc -I dummy 'https://source.com/1034.ts' --sout '#standard{access=http,mux=flv,dst=localhost:2052}'
VLC media player 2.2.8 Weatherwax (revision 2.2.7-14-g3cc1d8cba9)
[09d3fdf0] pulse audio output error: PulseAudio server connection failure: Connection refused
[09d279c0] core interface error: no suitable interface module
[09c9b8f8] core libvlc error: interface "globalhotkeys,none" initialization failed
[09d279c0] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[09d279c0] core interface error: no suitable interface module
[09c9b8f8] core libvlc error: interface "dbus,none" initialization failed
[09d279c0] dummy interface: using the dummy interface module...
[b5e04ae0] access_output_http access out: Consider passing --http-host=IP on the command line instead.
[b5e38ab8] ts demux: MPEG-4 descriptor not found for pid 0x101 type 0xf
[b5e90ae0] packetizer_mpeg4audio decoder: AAC channels: 2 samplerate: 48000
[flv @ 0xb5e33b40] dimensions not set
[b5e06360] avformat mux error: could not write header: Invalid argument
[b5e88ef0] core decoder error: cannot continue streaming due to errors
[b5e90ae0] core decoder error: cannot continue streaming due to errors

这里输出-loglevel verbose

:~# ffmpeg -i http://source.com/1.ts -copyinkf -codec copy  -loglevel verbose  http://127.0.0.1:8090/feed1.ffm
ffmpeg version 2.6.9 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/i386-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-vaapi --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/i386-linux-gnu
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Invalid UE golomb code
    Last message repeated 2 times
Input #0, mpegts, from 'http://source.com/1.ts':
  Duration: N/A, start: 30472.768167, bitrate: N/A
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 960x540 (960x544) [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 105 kb/s
[graph 0 input from stream 0:1 @ 0x971f2c0] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
[audio format for output stream 0:0 @ 0x9844de0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[auto-inserted resampler 0 @ 0x97115e0] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:1 chl:mono fmt:fltp r:22050Hz
[graph 1 input from stream 0:0 @ 0x96f5d00] w:960 h:540 pixfmt:yuv420p tb:1/90000 fr:50/1 sar:1/1 sws_param:flags=2
[scaler for output stream 0:1 @ 0x96f5e80] w:352 h:240 flags:'0x4' interl:0
[scaler for output stream 0:1 @ 0x96f5e80] w:960 h:540 fmt:yuv420p sar:1/1 -> w:352 h:240 fmt:yuv420p sar:40/33 flags:0x4
Output #0, ffm, to 'http://127.0.0.1:8090/feed1.ffm':
  Metadata:
    creation_time   : now
    encoder         : Lavf56.25.101
    Stream #0:0: Audio: wmav2, 22050 Hz, mono, fltp, 64 kb/s
    Metadata:
      encoder         : Lavc56.26.100 wmav2
    Stream #0:1: Video: msmpeg4v3 (msmpeg4), yuv420p, 352x240 [SAR 40:33 DAR 16:9], q=2-31, 256 kb/s, 50 fps, 1000k tbn, 15 tbc
    Metadata:
      encoder         : Lavc56.26.100 msmpeg4
Stream mapping:
  Stream #0:1 -> #0:0 (aac (native) -> wmav2 (native))
  Stream #0:0 -> #0:1 (h264 (native) -> msmpeg4v3 (msmpeg4))
Press [q] to stop, [?] for help
Invalid UE golomb code
*** dropping frame 3 from stream 1 at ts 1
    Last message repeated 1 times
[msmpeg4 @ 0x970f060] warning, clipping 1 dct coefficients to -127..127
*** dropping frame 41 from stream 1 at ts 39me=00:00:02.73 bitrate= 311.7kbits/s dup=0 drop=88
    Last message repeated 1 times
[h264 @ 0x9844a00] error while decoding MB 58 12, bytestream -5
[h264 @ 0x9844a00] concealing 1311 DC, 1311 AC, 1311 MV errors in B frame
*** dropping frame 53 from stream 1 at ts 52
No more output streams to write to, finishing.
frame=   55 fps= 42 q=4.3 Lsize=     152kB time=00:00:03.66 bitrate= 339.6kbits/s dup=0 drop=119
video:116kB audio:26kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.760316%
Input file #0 (http://source.com/1.ts):
  Input stream #0:0 (video): 174 packets read (220322 bytes); 174 frames decoded;
  Input stream #0:1 (audio): 156 packets read (36657 bytes); 156 frames decoded (159744 samples);
  Total: 330 packets (256979 bytes) demuxed
Output file #0 (http://127.0.0.1:8090/feed1.ffm):
  Output stream #0:0 (audio): 72 frames encoded (73383 samples); 72 packets muxed (26712 bytes);
  Output stream #0:1 (video): 55 frames encoded; 55 packets muxed (119080 bytes);
  Total: 127 packets (145792 bytes) muxed

在这里输入 URL 文件信息 使用 IDM 下载到我的电脑后

General
ID                             : 1 (0x1)
Complete name                  : D:\1.ts
Format                         : MPEG-TS
File size                      : 256 KiB
Duration                       : 2 s 520 ms
Overall bit rate mode          : Variable
Overall bit rate               : 788 kb/s

Video
ID                             : 256 (0x100)
Menu ID                        : 1 (0x1)
Format                         : AVC
Format/Info                    : Advanced Video Codec
Format profile                 : [email protected]
Format settings, CABAC         : Yes
Format settings, RefFrames     : 2 frames
Codec ID                       : 27
Duration                       : 2 s 680 ms
Width                          : 960 pixels
Height                         : 540 pixels
Display aspect ratio           : 16:9
Frame rate                     : 50.000 FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0
Bit depth                      : 8 bits
Scan type                      : Progressive

Audio
ID                             : 257 (0x101)
Menu ID                        : 1 (0x1)
Format                         : AAC
Format/Info                    : Advanced Audio Codec
Format version                 : Version 4
Format profile                 : LC
Muxing mode                    : ADTS
Codec ID                       : 15
Duration                       : 2 s 69 ms
Bit rate mode                  : Variable
Channel(s)                     : 2 channels
Channel positions              : Front: L R
Sampling rate                  : 48.0 kHz
Frame rate                     : 46.875 FPS (1024 SPF)
Compression mode               : Lossy
Delay relative to video        : -12 ms

Menu
ID                             : 4096 (0x1000)
Menu ID                        : 1 (0x1)
Duration                       : 2 s 520 ms
List                           : 256 (0x100) (AVC) / 257 (0x101) (AAC)
Service name                   : Service01
Service provider               : FFmpeg
Service type                   : digital television

相关内容