本地,在我的 Windows 机器上安装了 Zeranoe 的 ffmpeg 3.3.2(与 4.0.2 的结果相同)
ffmpeg 版本 3.2.2 版权所有 (c) 2003-2016 FFmpeg 开发人员使用 gcc 5.4.0 (GCC) 构建配置:--enable-gpl --enable-version3 --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --启用-librtmp --启用-libsnappy --启用-libsoxr --启用-libspeex --启用-libtheora --启用-libtwolame --启用-libvidstab --启用-libvo-amrwbenc --启用-libvorbis --启用-libvpx --启用-libwavpack --启用-libwebp --启用-libx264 --启用-libx265 --启用-libxavs --启用-libxvid --启用-libzimg --启用-lzma --启用-decklink --启用-zlib
服务器端
启动 UDP 多播流。
ffmpeg -re -i video.ts -an -f mpegts -c copy udp://224.1.1.1:5000
客户端
使用 ffplay 播放正确,无任何瑕疵,视频流畅
ffplay udp://224.1.1.1:5000
解码后播放原因伪影,视频损坏
ffmpeg -i udp://224.1.1.1:5000 -pix_fmt gray -f avi - | ffplay -
或者
ffmpeg -f mpegts -i udp://224.1.1.1:5000 -pix_fmt gray -c:v rawvideo -f avi out.avi
有人可以解释一下吗?
以下是 FFmpeg 控制台的输出:
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[h264 @ 0000000000c23f40] Invalid NAL unit 1, skipping.
[h264 @ 0000000000c23f40] cabac decode of qscale diff failed at 52 23
[h264 @ 0000000000c23f40] error while decoding MB 52 22, bytestream -16
[h264 @ 0000000000c23f40] concealing 5517 DC, 5517 AC, 5517 MV errors in P frame
[h264 @ 0000000000c23f40] Invalid NAL unit 1, skipping.
[h264 @ 0000000000c23f40] concealing 6939 DC, 6939 AC, 6939 MV errors in B frame
Input #0, mpegts, from 'udp://224.1.1.1:5000':
Duration: N/A, start: 1.520000, 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(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
File 'out.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'out.avi':
Metadata:
ISFT : Lavf57.56.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0000000000c330e0] Invalid NAL unit 0, skipping.
[h264 @ 0000000003ba8260] Invalid NAL unit 0, skipping.
[h264 @ 0000000003ba8260] concealing 6939 DC, 6939 AC, 6939 MV errors in B frame
[h264 @ 0000000000c330e0] cabac decode of qscale diff failed at 52 23
[h264 @ 0000000000c330e0] error while decoding MB 52 22, bytestream -16
[h264 @ 0000000000c330e0] concealing 5517 DC, 5517 AC, 5517 MV errors in P frame
[h264 @ 0000000005990380] Invalid NAL unit 1, skipping.
[h264 @ 0000000000c32c40] Reference 2 >= 2
[h264 @ 0000000000c32c40] error while decoding MB 56 22, bytestream 503
[h264 @ 0000000000c32c40] concealing 5513 DC, 5513 AC, 5513 MV errors in B frame
[h264 @ 0000000005990380] error while decoding MB 14 64, bytestream -10
[h264 @ 0000000005990380] concealing 515 DC, 515 AC, 515 MV errors in P frame
[h264 @ 0000000003ba8260] Invalid NAL unit 6, skipping.2.68 bitrate=402359.1kbits/s speed=5.31x
[h264 @ 0000000003ba8260] error while decoding MB 81 34, bytestream -10
[h264 @ 0000000003ba8260] concealing 4048 DC, 4048 AC, 4048 MV errors in P frame
[h264 @ 0000000003ba8b00] Reference 2 >= 2
[h264 @ 0000000003ba8b00] error while decoding MB 7 0, bytestream 72352
[h264 @ 0000000003ba8b00] concealing 8160 DC, 8160 AC, 8160 MV errors in P frame
[h264 @ 000000000599a860] Invalid NAL unit 0, skipping.
[h264 @ 000000000599a860] error while decoding MB 68 18, bytestream -25147.9kbits/s speed=4.75x
[h264 @ 000000000599a860] concealing 5981 DC, 5981 AC, 5981 MV errors in I frame
[h264 @ 00000000056c8f00] Reference 2 >= 2
[h264 @ 00000000056c8f00] error while decoding MB 94 10, bytestream 2535
[h264 @ 00000000056c8f00] concealing 6915 DC, 6915 AC, 6915 MV errors in B frame
[h264 @ 0000000000c32c40] Invalid NAL unit 1, skipping.
[h264 @ 0000000000c32c40] error while decoding MB 73 24, bytestream -10
[h264 @ 0000000000c32c40] concealing 5256 DC, 5256 AC, 5256 MV errors in P frame
[h264 @ 0000000000c330e0] Reference 3 >= 2
[h264 @ 0000000000c330e0] error while decoding MB 30 16, bytestream 1562
[h264 @ 0000000000c330e0] concealing 6259 DC, 6259 AC, 6259 MV errors in B frame
[h264 @ 0000000003ba8b00] Invalid NAL unit 0, skipping.8.56 bitrate=267443.2kbits/s speed=5.44x
[h264 @ 0000000003ba8b00] error while decoding MB 1 16, bytestream -15
[h264 @ 0000000003ba8b00] concealing 6288 DC, 6288 AC, 6288 MV errors in I frame
答案1
我也有同样的行为,但我不知道为什么确实会发生这种情况,但我通过编写自定义播放器解决了这个问题。代码包含在我的回答。