h264 提取帧仅适用于某些操作系统/ffmpeg 版本
h264 extracting frames works only on certain operating system / ffmpeg version
我从 phone 收到了经过解析的 h264 数据,我正在尝试从数据中提取帧。
我使用了以下 ffmpeg 命令行:
ffmpeg -i temp.h264 -ss 5 -pix_fmt yuv420p -vframes 1 foo.yuv
ffmpeg -s 1280:720 -pix_fmt yuv420p -i foo.yuv output.jpg
这会在 Ubuntu(KDE neon 用户版 5.12)和 ffmpeg 版本 2.8.14 上生成正确的输出图像。
但是,它在 macOS High Sierra (10.13.4) 和 ffmpeg 版本 4.0 上不起作用,而是显示一条输出消息:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
我不确定这是否仅仅是 ffmpeg 版本相关的问题,因为作为实验,当我将 h264 数据转换为 mp4 格式并在 macOS High Sierra 上播放时,视频有时显示一系列黑色失真图像 (screenshot),有时显示正常视频。
如果我在 Ubuntu(KDE neon 用户版 5.12)上播放那个 相同 视频,视频播放效果很好。
我不明白为什么会出现这个问题,是否与OS或ffmpeg库版本有关。
有什么好的方法可以解决这个问题?谢谢。
编辑:
第一个 ffmpeg 命令行的完整日志 (ubuntu):
ffmpeg version 2.8.14-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[h264 @ 0x11ae2a0] error while decoding MB 54 2, bytestream -16
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 2 9
[h264 @ 0x11ae2a0] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x11ae2a0] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 27 0
[h264 @ 0x11ae2a0] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x11ae2a0] deblocking filter parameters 7 13 out of range
[h264 @ 0x11ae2a0] decode_slice_header error
[h264 @ 0x11ae2a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ae2a0] deblocking filter parameters 7 -14 out of range
[h264 @ 0x11ae2a0] decode_slice_header error
[h264 @ 0x11ae2a0] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
[h264 @ 0x11ae2a0] deblocking filter parameters -7 0 out of range
[h264 @ 0x11ae2a0] decode_slice_header error
[h264 @ 0x11ae2a0] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 9 0
[h264 @ 0x11ae2a0] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x11ae2a0] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x11ae2a0] top block unavailable for requested intra mode at 16 9
[h264 @ 0x11ae2a0] error while decoding MB 16 9, bytestream 6182
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 6 18
[h264 @ 0x11ae2a0] error while decoding MB 6 18, bytestream 7042
[h264 @ 0x11ae2a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ad340] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'temp.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc), 1280x720, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
[swscaler @ 0x1207dc0] deprecated pixel format used, make sure you did set range correctly
Output #0, rawvideo, to 'foo.yuv':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Metadata:
encoder : Lavc56.60.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0x11f98a0] error while decoding MB 54 2, bytestream -16
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 2 9
[h264 @ 0x11f98a0] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x11f98a0] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 27 0
[h264 @ 0x12758e0] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x12758e0] deblocking filter parameters 7 13 out of range
[h264 @ 0x12758e0] decode_slice_header error
[h264 @ 0x12758e0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ffcc0] deblocking filter parameters 7 -14 out of range
[h264 @ 0x11ffcc0] decode_slice_header error
[h264 @ 0x11ffcc0] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
[h264 @ 0x11f98a0] deblocking filter parameters -7 0 out of range
[h264 @ 0x11f98a0] decode_slice_header error
[h264 @ 0x11f98a0] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 9 0
[h264 @ 0x12758e0] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x12758e0] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra mode at 16 9
[h264 @ 0x11ffcc0] error while decoding MB 16 9, bytestream 6182
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 6 18
[h264 @ 0x11ffcc0] error while decoding MB 6 18, bytestream 7042
[h264 @ 0x11ffcc0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 12 9
[h264 @ 0x11f98a0] error while decoding MB 12 9, bytestream 6863
[h264 @ 0x11f98a0] concealing 1342 DC, 1342 AC, 1342 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra mode at 29 18
[h264 @ 0x12758e0] error while decoding MB 29 18, bytestream 6612
[h264 @ 0x12758e0] concealing 1405 DC, 1405 AC, 1405 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra mode at 25 9
[h264 @ 0x11ffcc0] error while decoding MB 25 9, bytestream 6051
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 70 18
[h264 @ 0x11ffcc0] error while decoding MB 70 18, bytestream 5089
[h264 @ 0x11ffcc0] concealing 1419 DC, 1419 AC, 1419 MV errors in P frame
[h264 @ 0x11f98a0] top block unavailable for requested intra mode at 14 9
[h264 @ 0x11f98a0] error while decoding MB 14 9, bytestream 6071
[h264 @ 0x11f98a0] deblocking filter parameters -9 0 out of range
[h264 @ 0x11f98a0] decode_slice_header error
[h264 @ 0x11f98a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 54 9
[h264 @ 0x12758e0] error while decoding MB 54 9, bytestream 4423
[h264 @ 0x12758e0] concealing 1256 DC, 1256 AC, 1256 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 22 9
[h264 @ 0x11ffcc0] error while decoding MB 22 9, bytestream 5861
[h264 @ 0x11ffcc0] concealing 1335 DC, 1335 AC, 1335 MV errors in P frame
[h264 @ 0x11f98a0] deblocking filter parameters 7 -4 out of range
[h264 @ 0x11f98a0] decode_slice_header error
[h264 @ 0x11f98a0] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x12758e0] concealing 1319 DC, 1319 AC, 1319 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 16 9
[h264 @ 0x11ffcc0] error while decoding MB 16 9, bytestream 6217
[h264 @ 0x11ffcc0] concealing 1416 DC, 1416 AC, 1416 MV errors in P frame
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 12 0
[h264 @ 0x11f98a0] error while decoding MB 12 0, bytestream 6854
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 2 9
[h264 @ 0x11f98a0] error while decoding MB 2 9, bytestream 7093
[h264 @ 0x11f98a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 59 0
[h264 @ 0x12758e0] error while decoding MB 59 0, bytestream 4955
[h264 @ 0x12758e0] deblocking filter parameters 7 15 out of range
[h264 @ 0x12758e0] decode_slice_header error
[h264 @ 0x12758e0] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 34 0
[h264 @ 0x11ffcc0] error while decoding MB 34 0, bytestream 5338
[h264 @ 0x11ffcc0] deblocking filter parameters 7 13 out of range
[h264 @ 0x11ffcc0] decode_slice_header error
[h264 @ 0x11ffcc0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ffcc0] Reinit context to 1280x720, pix_fmt: yuv420p
[h264 @ 0x11f98a0] concealing 1344 DC, 1344 AC, 1344 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 49 9
[h264 @ 0x12758e0] error while decoding MB 49 9, bytestream 4993
[h264 @ 0x12758e0] concealing 1228 DC, 1228 AC, 1228 MV errors in P frame
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj420p to size:1280x720 fmt:yuv420p
frame= 1 fps=0.6 q=-0.0 Lsize= 1350kB time=00:00:04.93 bitrate=2239.5kbits/s
video:1350kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
第一个ffmpeg命令行的完整日志(macOS):
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
[h264 @ 0x7fcb3880b600] error while decoding MB 54 2, bytestream -14
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x7fcb3880b600] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x7fcb3880b600] deblocking filter parameters 7 13 out of range
[h264 @ 0x7fcb3880b600] decode_slice_header error
[h264 @ 0x7fcb3880b600] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb3880b600] deblocking filter parameters 7 -14 out of range
[h264 @ 0x7fcb3880b600] decode_slice_header error
[h264 @ 0x7fcb3880b600] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
[h264 @ 0x7fcb3880b600] deblocking filter parameters -7 0 out of range
[h264 @ 0x7fcb3880b600] decode_slice_header error
[h264 @ 0x7fcb3880b600] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x7fcb3880b600] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode
[h264 @ 0x7fcb3880b600] error while decoding MB 16 9, bytestream 6183
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 6 18, bytestream 7043
[h264 @ 0x7fcb3880b600] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb39000400] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'temp.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, progressive), 1280x720, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0x7fcb38003800] error while decoding MB 54 2, bytestream -14
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x7fcb38003800] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x7fcb38003e00] deblocking filter parameters 7 13 out of range
[h264 @ 0x7fcb38003e00] decode_slice_header error
[h264 @ 0x7fcb38003e00] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[swscaler @ 0x7fcb3817aa00] deprecated pixel format used, make sure you did set range correctly
[h264 @ 0x7fcb3809c000] deblocking filter parameters 7 -14 out of range
[h264 @ 0x7fcb3809c000] decode_slice_header error
[h264 @ 0x7fcb3809c000] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
Output #0, rawvideo, to 'foo.yuv':
Metadata:
encoder : Lavf58.12.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, q=2-31, 331444 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Metadata:
encoder : Lavc58.18.100 rawvideo
[h264 @ 0x7fcb3809c600] deblocking filter parameters -7 0 out of range
[h264 @ 0x7fcb3809c600] decode_slice_header error
[h264 @ 0x7fcb3809c600] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003200] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x7fcb38003200] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode
[h264 @ 0x7fcb38003800] error while decoding MB 16 9, bytestream 6183
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 6 18, bytestream 7043
[h264 @ 0x7fcb38003800] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 12 9, bytestream 6862
[h264 @ 0x7fcb38003e00] concealing 1342 DC, 1342 AC, 1342 MV errors in P frame
[h264 @ 0x7fcb3809c000] top block unavailable for requested intra mode
[h264 @ 0x7fcb3809c000] error while decoding MB 29 18, bytestream 6612
[h264 @ 0x7fcb3809c000] concealing 1405 DC, 1405 AC, 1405 MV errors in P frame
[h264 @ 0x7fcb3809c600] top block unavailable for requested intra mode
[h264 @ 0x7fcb3809c600] error while decoding MB 25 9, bytestream 6050
[h264 @ 0x7fcb3809c600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3809c600] error while decoding MB 70 18, bytestream 5089
[h264 @ 0x7fcb3809c600] concealing 1419 DC, 1419 AC, 1419 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode
[h264 @ 0x7fcb38003200] error while decoding MB 14 9, bytestream 6071
[h264 @ 0x7fcb38003200] deblocking filter parameters -9 0 out of range
[h264 @ 0x7fcb38003200] decode_slice_header error
[h264 @ 0x7fcb38003200] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 54 9, bytestream 4423
[h264 @ 0x7fcb38003800] concealing 1256 DC, 1256 AC, 1256 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 22 9, bytestream 5862
[h264 @ 0x7fcb38003e00] concealing 1335 DC, 1335 AC, 1335 MV errors in P frame
[h264 @ 0x7fcb3809c000] deblocking filter parameters 7 -4 out of range
[h264 @ 0x7fcb3809c000] decode_slice_header error
[h264 @ 0x7fcb3809c000] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x7fcb3809c600] concealing 1319 DC, 1319 AC, 1319 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003200] error while decoding MB 16 9, bytestream 6217
[h264 @ 0x7fcb38003200] concealing 1416 DC, 1416 AC, 1416 MV errors in P frame
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 12 0, bytestream 6854
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 2 9, bytestream 7093
[h264 @ 0x7fcb38003800] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 59 0, bytestream 4955
[h264 @ 0x7fcb38003e00] deblocking filter parameters 7 15 out of range
[h264 @ 0x7fcb38003e00] decode_slice_header error
[h264 @ 0x7fcb38003e00] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x7fcb3809c000] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3809c000] error while decoding MB 34 0, bytestream 5338
[h264 @ 0x7fcb3809c000] deblocking filter parameters 7 13 out of range
[h264 @ 0x7fcb3809c000] decode_slice_header error
[h264 @ 0x7fcb3809c000] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb3809c600] concealing 1344 DC, 1344 AC, 1344 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003200] error while decoding MB 49 9, bytestream 4992
[h264 @ 0x7fcb38003200] concealing 1228 DC, 1228 AC, 1228 MV errors in P frame
frame= 0 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
我想由于解码错误,不同的 ffmpeg 版本以不同的方式跳过输入数据,所以 4.0 根本无法解码任何有用的东西。
要么你的 temp.h264 损坏了,要么它不是原始的 .h264 文件(我是如何创建的?file 命令报告?),因为 ffmpeg 给出了很多解码错误。
播放的差异可能是由于使用了不同的 h.264 解码器造成的。你用的什么播放器? macos上用的是硬件解码器吗?
我用 https://sourceforge.net/projects/h264bitstream/
查看了示例文件
$ ./h264_analyze temp.h264 |grep "frame_num\|Found NAL"|less
!! Found NAL at offset 4 (0x0004), size 34 (0x0022)
log2_max_frame_num_minus4 : 0
gaps_in_frame_num_value_allowed_flag : 0
!! Found NAL at offset 42 (0x002A), size 4 (0x0004)
!! Found NAL at offset 50 (0x0032), size 63 (0x003F)
frame_num : 0
!! Found NAL at offset 117 (0x0075), size 71 (0x0047)
frame_num : 0
!! Found NAL at offset 192 (0x00C0), size 66 (0x0042)
frame_num : 0
!! Found NAL at offset 262 (0x0106), size 66 (0x0042)
frame_num : 0
!! Found NAL at offset 332 (0x014C), size 66 (0x0042)
frame_num : 0
!! Found NAL at offset 402 (0x0192), size 68 (0x0044)
frame_num : 0
!! Found NAL at offset 474 (0x01DA), size 70 (0x0046)
frame_num : 0
!! Found NAL at offset 548 (0x0224), size 59 (0x003B)
frame_num : 0
!! Found NAL at offset 611 (0x0263), size 6752 (0x1A60)
frame_num : 4
!! Found NAL at offset 7367 (0x1CC7), size 7016 (0x1B68)
frame_num : 4
!! Found NAL at offset 14387 (0x3833), size 7972 (0x1F24)
frame_num : 4
!! Found NAL at offset 22363 (0x575B), size 5939 (0x1733)
frame_num : 4
!! Found NAL at offset 28306 (0x6E92), size 6491 (0x195B)
frame_num : 4
!! Found NAL at offset 34801 (0x87F1), size 6596 (0x19C4)
frame_num : 5
!! Found NAL at offset 41401 (0xA1B9), size 6828 (0x1AAC)
frame_num : 5
!! Found NAL at offset 48233 (0xBC69), size 7800 (0x1E78)
frame_num : 5
你可以看到前几个NALU的大小:它们异常小。还有,frame_num第一组图片少了1和2。您必须仔细检查如何创建 .h264 文件的开头。
我从 phone 收到了经过解析的 h264 数据,我正在尝试从数据中提取帧。
我使用了以下 ffmpeg 命令行:
ffmpeg -i temp.h264 -ss 5 -pix_fmt yuv420p -vframes 1 foo.yuv
ffmpeg -s 1280:720 -pix_fmt yuv420p -i foo.yuv output.jpg
这会在 Ubuntu(KDE neon 用户版 5.12)和 ffmpeg 版本 2.8.14 上生成正确的输出图像。
但是,它在 macOS High Sierra (10.13.4) 和 ffmpeg 版本 4.0 上不起作用,而是显示一条输出消息:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
我不确定这是否仅仅是 ffmpeg 版本相关的问题,因为作为实验,当我将 h264 数据转换为 mp4 格式并在 macOS High Sierra 上播放时,视频有时显示一系列黑色失真图像 (screenshot),有时显示正常视频。
如果我在 Ubuntu(KDE neon 用户版 5.12)上播放那个 相同 视频,视频播放效果很好。
我不明白为什么会出现这个问题,是否与OS或ffmpeg库版本有关。 有什么好的方法可以解决这个问题?谢谢。
编辑:
第一个 ffmpeg 命令行的完整日志 (ubuntu):
ffmpeg version 2.8.14-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[h264 @ 0x11ae2a0] error while decoding MB 54 2, bytestream -16
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 2 9
[h264 @ 0x11ae2a0] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x11ae2a0] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 27 0
[h264 @ 0x11ae2a0] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x11ae2a0] deblocking filter parameters 7 13 out of range
[h264 @ 0x11ae2a0] decode_slice_header error
[h264 @ 0x11ae2a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ae2a0] deblocking filter parameters 7 -14 out of range
[h264 @ 0x11ae2a0] decode_slice_header error
[h264 @ 0x11ae2a0] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
[h264 @ 0x11ae2a0] deblocking filter parameters -7 0 out of range
[h264 @ 0x11ae2a0] decode_slice_header error
[h264 @ 0x11ae2a0] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 9 0
[h264 @ 0x11ae2a0] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x11ae2a0] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x11ae2a0] top block unavailable for requested intra mode at 16 9
[h264 @ 0x11ae2a0] error while decoding MB 16 9, bytestream 6182
[h264 @ 0x11ae2a0] top block unavailable for requested intra4x4 mode -1 at 6 18
[h264 @ 0x11ae2a0] error while decoding MB 6 18, bytestream 7042
[h264 @ 0x11ae2a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ad340] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'temp.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc), 1280x720, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
[swscaler @ 0x1207dc0] deprecated pixel format used, make sure you did set range correctly
Output #0, rawvideo, to 'foo.yuv':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Metadata:
encoder : Lavc56.60.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0x11f98a0] error while decoding MB 54 2, bytestream -16
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 2 9
[h264 @ 0x11f98a0] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x11f98a0] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 27 0
[h264 @ 0x12758e0] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x12758e0] deblocking filter parameters 7 13 out of range
[h264 @ 0x12758e0] decode_slice_header error
[h264 @ 0x12758e0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ffcc0] deblocking filter parameters 7 -14 out of range
[h264 @ 0x11ffcc0] decode_slice_header error
[h264 @ 0x11ffcc0] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
[h264 @ 0x11f98a0] deblocking filter parameters -7 0 out of range
[h264 @ 0x11f98a0] decode_slice_header error
[h264 @ 0x11f98a0] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 9 0
[h264 @ 0x12758e0] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x12758e0] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra mode at 16 9
[h264 @ 0x11ffcc0] error while decoding MB 16 9, bytestream 6182
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 6 18
[h264 @ 0x11ffcc0] error while decoding MB 6 18, bytestream 7042
[h264 @ 0x11ffcc0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 12 9
[h264 @ 0x11f98a0] error while decoding MB 12 9, bytestream 6863
[h264 @ 0x11f98a0] concealing 1342 DC, 1342 AC, 1342 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra mode at 29 18
[h264 @ 0x12758e0] error while decoding MB 29 18, bytestream 6612
[h264 @ 0x12758e0] concealing 1405 DC, 1405 AC, 1405 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra mode at 25 9
[h264 @ 0x11ffcc0] error while decoding MB 25 9, bytestream 6051
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 70 18
[h264 @ 0x11ffcc0] error while decoding MB 70 18, bytestream 5089
[h264 @ 0x11ffcc0] concealing 1419 DC, 1419 AC, 1419 MV errors in P frame
[h264 @ 0x11f98a0] top block unavailable for requested intra mode at 14 9
[h264 @ 0x11f98a0] error while decoding MB 14 9, bytestream 6071
[h264 @ 0x11f98a0] deblocking filter parameters -9 0 out of range
[h264 @ 0x11f98a0] decode_slice_header error
[h264 @ 0x11f98a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 54 9
[h264 @ 0x12758e0] error while decoding MB 54 9, bytestream 4423
[h264 @ 0x12758e0] concealing 1256 DC, 1256 AC, 1256 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 22 9
[h264 @ 0x11ffcc0] error while decoding MB 22 9, bytestream 5861
[h264 @ 0x11ffcc0] concealing 1335 DC, 1335 AC, 1335 MV errors in P frame
[h264 @ 0x11f98a0] deblocking filter parameters 7 -4 out of range
[h264 @ 0x11f98a0] decode_slice_header error
[h264 @ 0x11f98a0] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x12758e0] concealing 1319 DC, 1319 AC, 1319 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 16 9
[h264 @ 0x11ffcc0] error while decoding MB 16 9, bytestream 6217
[h264 @ 0x11ffcc0] concealing 1416 DC, 1416 AC, 1416 MV errors in P frame
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 12 0
[h264 @ 0x11f98a0] error while decoding MB 12 0, bytestream 6854
[h264 @ 0x11f98a0] top block unavailable for requested intra4x4 mode -1 at 2 9
[h264 @ 0x11f98a0] error while decoding MB 2 9, bytestream 7093
[h264 @ 0x11f98a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 59 0
[h264 @ 0x12758e0] error while decoding MB 59 0, bytestream 4955
[h264 @ 0x12758e0] deblocking filter parameters 7 15 out of range
[h264 @ 0x12758e0] decode_slice_header error
[h264 @ 0x12758e0] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x11ffcc0] top block unavailable for requested intra4x4 mode -1 at 34 0
[h264 @ 0x11ffcc0] error while decoding MB 34 0, bytestream 5338
[h264 @ 0x11ffcc0] deblocking filter parameters 7 13 out of range
[h264 @ 0x11ffcc0] decode_slice_header error
[h264 @ 0x11ffcc0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x11ffcc0] Reinit context to 1280x720, pix_fmt: yuv420p
[h264 @ 0x11f98a0] concealing 1344 DC, 1344 AC, 1344 MV errors in P frame
[h264 @ 0x12758e0] top block unavailable for requested intra4x4 mode -1 at 49 9
[h264 @ 0x12758e0] error while decoding MB 49 9, bytestream 4993
[h264 @ 0x12758e0] concealing 1228 DC, 1228 AC, 1228 MV errors in P frame
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj420p to size:1280x720 fmt:yuv420p
frame= 1 fps=0.6 q=-0.0 Lsize= 1350kB time=00:00:04.93 bitrate=2239.5kbits/s
video:1350kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
第一个ffmpeg命令行的完整日志(macOS):
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
[h264 @ 0x7fcb3880b600] error while decoding MB 54 2, bytestream -14
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x7fcb3880b600] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x7fcb3880b600] deblocking filter parameters 7 13 out of range
[h264 @ 0x7fcb3880b600] decode_slice_header error
[h264 @ 0x7fcb3880b600] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb3880b600] deblocking filter parameters 7 -14 out of range
[h264 @ 0x7fcb3880b600] decode_slice_header error
[h264 @ 0x7fcb3880b600] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
[h264 @ 0x7fcb3880b600] deblocking filter parameters -7 0 out of range
[h264 @ 0x7fcb3880b600] decode_slice_header error
[h264 @ 0x7fcb3880b600] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x7fcb3880b600] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode
[h264 @ 0x7fcb3880b600] error while decoding MB 16 9, bytestream 6183
[h264 @ 0x7fcb3880b600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3880b600] error while decoding MB 6 18, bytestream 7043
[h264 @ 0x7fcb3880b600] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb39000400] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'temp.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, progressive), 1280x720, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0x7fcb38003800] error while decoding MB 54 2, bytestream -14
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 2 9, bytestream 6908
[h264 @ 0x7fcb38003800] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 27 0, bytestream 5564
[h264 @ 0x7fcb38003e00] deblocking filter parameters 7 13 out of range
[h264 @ 0x7fcb38003e00] decode_slice_header error
[h264 @ 0x7fcb38003e00] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[swscaler @ 0x7fcb3817aa00] deprecated pixel format used, make sure you did set range correctly
[h264 @ 0x7fcb3809c000] deblocking filter parameters 7 -14 out of range
[h264 @ 0x7fcb3809c000] decode_slice_header error
[h264 @ 0x7fcb3809c000] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
Output #0, rawvideo, to 'foo.yuv':
Metadata:
encoder : Lavf58.12.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, q=2-31, 331444 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Metadata:
encoder : Lavc58.18.100 rawvideo
[h264 @ 0x7fcb3809c600] deblocking filter parameters -7 0 out of range
[h264 @ 0x7fcb3809c600] decode_slice_header error
[h264 @ 0x7fcb3809c600] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003200] error while decoding MB 9 0, bytestream 6647
[h264 @ 0x7fcb38003200] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode
[h264 @ 0x7fcb38003800] error while decoding MB 16 9, bytestream 6183
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 6 18, bytestream 7043
[h264 @ 0x7fcb38003800] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 12 9, bytestream 6862
[h264 @ 0x7fcb38003e00] concealing 1342 DC, 1342 AC, 1342 MV errors in P frame
[h264 @ 0x7fcb3809c000] top block unavailable for requested intra mode
[h264 @ 0x7fcb3809c000] error while decoding MB 29 18, bytestream 6612
[h264 @ 0x7fcb3809c000] concealing 1405 DC, 1405 AC, 1405 MV errors in P frame
[h264 @ 0x7fcb3809c600] top block unavailable for requested intra mode
[h264 @ 0x7fcb3809c600] error while decoding MB 25 9, bytestream 6050
[h264 @ 0x7fcb3809c600] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3809c600] error while decoding MB 70 18, bytestream 5089
[h264 @ 0x7fcb3809c600] concealing 1419 DC, 1419 AC, 1419 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode
[h264 @ 0x7fcb38003200] error while decoding MB 14 9, bytestream 6071
[h264 @ 0x7fcb38003200] deblocking filter parameters -9 0 out of range
[h264 @ 0x7fcb38003200] decode_slice_header error
[h264 @ 0x7fcb38003200] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 54 9, bytestream 4423
[h264 @ 0x7fcb38003800] concealing 1256 DC, 1256 AC, 1256 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 22 9, bytestream 5862
[h264 @ 0x7fcb38003e00] concealing 1335 DC, 1335 AC, 1335 MV errors in P frame
[h264 @ 0x7fcb3809c000] deblocking filter parameters 7 -4 out of range
[h264 @ 0x7fcb3809c000] decode_slice_header error
[h264 @ 0x7fcb3809c000] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x7fcb3809c600] concealing 1319 DC, 1319 AC, 1319 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003200] error while decoding MB 16 9, bytestream 6217
[h264 @ 0x7fcb38003200] concealing 1416 DC, 1416 AC, 1416 MV errors in P frame
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 12 0, bytestream 6854
[h264 @ 0x7fcb38003800] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003800] error while decoding MB 2 9, bytestream 7093
[h264 @ 0x7fcb38003800] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb38003e00] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003e00] error while decoding MB 59 0, bytestream 4955
[h264 @ 0x7fcb38003e00] deblocking filter parameters 7 15 out of range
[h264 @ 0x7fcb38003e00] decode_slice_header error
[h264 @ 0x7fcb38003e00] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
[h264 @ 0x7fcb3809c000] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb3809c000] error while decoding MB 34 0, bytestream 5338
[h264 @ 0x7fcb3809c000] deblocking filter parameters 7 13 out of range
[h264 @ 0x7fcb3809c000] decode_slice_header error
[h264 @ 0x7fcb3809c000] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
[h264 @ 0x7fcb3809c600] concealing 1344 DC, 1344 AC, 1344 MV errors in P frame
[h264 @ 0x7fcb38003200] top block unavailable for requested intra mode -1
[h264 @ 0x7fcb38003200] error while decoding MB 49 9, bytestream 4992
[h264 @ 0x7fcb38003200] concealing 1228 DC, 1228 AC, 1228 MV errors in P frame
frame= 0 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
我想由于解码错误,不同的 ffmpeg 版本以不同的方式跳过输入数据,所以 4.0 根本无法解码任何有用的东西。
要么你的 temp.h264 损坏了,要么它不是原始的 .h264 文件(我是如何创建的?file 命令报告?),因为 ffmpeg 给出了很多解码错误。
播放的差异可能是由于使用了不同的 h.264 解码器造成的。你用的什么播放器? macos上用的是硬件解码器吗?
我用 https://sourceforge.net/projects/h264bitstream/
查看了示例文件$ ./h264_analyze temp.h264 |grep "frame_num\|Found NAL"|less
!! Found NAL at offset 4 (0x0004), size 34 (0x0022)
log2_max_frame_num_minus4 : 0
gaps_in_frame_num_value_allowed_flag : 0
!! Found NAL at offset 42 (0x002A), size 4 (0x0004)
!! Found NAL at offset 50 (0x0032), size 63 (0x003F)
frame_num : 0
!! Found NAL at offset 117 (0x0075), size 71 (0x0047)
frame_num : 0
!! Found NAL at offset 192 (0x00C0), size 66 (0x0042)
frame_num : 0
!! Found NAL at offset 262 (0x0106), size 66 (0x0042)
frame_num : 0
!! Found NAL at offset 332 (0x014C), size 66 (0x0042)
frame_num : 0
!! Found NAL at offset 402 (0x0192), size 68 (0x0044)
frame_num : 0
!! Found NAL at offset 474 (0x01DA), size 70 (0x0046)
frame_num : 0
!! Found NAL at offset 548 (0x0224), size 59 (0x003B)
frame_num : 0
!! Found NAL at offset 611 (0x0263), size 6752 (0x1A60)
frame_num : 4
!! Found NAL at offset 7367 (0x1CC7), size 7016 (0x1B68)
frame_num : 4
!! Found NAL at offset 14387 (0x3833), size 7972 (0x1F24)
frame_num : 4
!! Found NAL at offset 22363 (0x575B), size 5939 (0x1733)
frame_num : 4
!! Found NAL at offset 28306 (0x6E92), size 6491 (0x195B)
frame_num : 4
!! Found NAL at offset 34801 (0x87F1), size 6596 (0x19C4)
frame_num : 5
!! Found NAL at offset 41401 (0xA1B9), size 6828 (0x1AAC)
frame_num : 5
!! Found NAL at offset 48233 (0xBC69), size 7800 (0x1E78)
frame_num : 5
你可以看到前几个NALU的大小:它们异常小。还有,frame_num第一组图片少了1和2。您必须仔细检查如何创建 .h264 文件的开头。