FFMPEG:将输入拆分为 NAL 单元时出错/从 avi 更改为 mp4 时,数据包中的流 0 的时间戳未设置

FFMPEG:将输入拆分为 NAL 单元时出错/从 avi 更改为 mp4 时,数据包中的流 0 的时间戳未设置

我正在尝试使用 更改从 NVR 获取的视频的容器ffmpeg,但输出视频无法通过 VLC 或 QuickTime 播放。输出视频保持静止。具体来说,使用以下命令:

ffmpeg -i input.avi -c:v copy output.mp4

我收到以下错误和警告消息:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[h264 @ 0x7fc5aa810e00] missing picture in access unit with size 16
[h264 @ 0x7fc5aa810e00] No start code is found.
[h264 @ 0x7fc5aa810e00] Error splitting the input into NAL units.
[h264 @ 0x7fc5aa810e00] missing picture in access unit with size 16
[h264 @ 0x7fc5aa810e00] No start code is found.
[h264 @ 0x7fc5aa810e00] Error splitting the input into NAL units.
[h264 @ 0x7fc5aa810e00] missing picture in access unit with size 16
[h264 @ 0x7fc5aa810e00] No start code is found.
[h264 @ 0x7fc5aa810e00] Error splitting the input into NAL units.
[h264 @ 0x7fc5aa810e00] missing picture in access unit with size 16
...
    Last message repeated 13 times
Input #0, avi, from 'input.avi':
  Duration: 01:00:09.43, start: 0.000000, bitrate: 423 kb/s
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuvj420p(pc, bt709, progressive), 1280x720, 418 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc

Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 1280x720, q=2-31, 418 kb/s, 30 fps, 30 tbr, 1000k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x7fb18580a600] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[NULL @ 0x7fb185000600] missing picture in access unit with size 16
    Last message repeated 14 times
[NULL @ 0x7fb185000600] missing picture in access unit with size 8
[NULL @ 0x7fb185000600] missing picture in access unit with size 16
    Last message repeated 35943 times
[NULL @ 0x7fb185000600] missing picture in access unit with size 16= 431.7kbits/s speed=3.99e+03x
    Last message repeated 29061 times
frame=108284 fps=0.0 q=-1.0 Lsize=  183632kB time=01:00:09.39 bitrate= 416.8kbits/s speed=4.05e+03x
video:184216kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

输入视频使用细节ffprobe如下:

{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_time_base": "33333/2000000",
            "codec_tag_string": "H264",
            "codec_tag": "0x34363248",
            "width": 1280,
            "height": 720,
            "coded_width": 1280,
            "coded_height": 720,
            "has_b_frames": 0,
            "pix_fmt": "yuvj420p",
            "level": 31,
            "color_range": "pc",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "false",
            "nal_length_size": "0",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "1000000/33333",
            "time_base": "33333/1000000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 108284,
            "duration": "3609.430572",
            "bit_rate": "418103",
            "bits_per_raw_sample": "8",
            "nb_frames": "108284",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            }
        }
    ],
    "format": {
        "filename": "input.avi",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "avi",
        "format_long_name": "AVI (Audio Video Interleaved)",
        "start_time": "0.000000",
        "duration": "3609.430572",
        "size": "191260108",
        "bit_rate": "423911",
        "probe_score": 100
    }
}

输出视频详情

{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_time_base": "33333/2000000",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1280,
            "height": 720,
            "coded_width": 1280,
            "coded_height": 720,
            "has_b_frames": 0,
            "pix_fmt": "yuvj420p",
            "level": 31,
            "color_range": "pc",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "1000000/33333",
            "avg_frame_rate": "1000000/33333",
            "time_base": "1/1000000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 3609430572,
            "duration": "3609.430572",
            "bit_rate": "415792",
            "bits_per_raw_sample": "8",
            "nb_frames": "108284",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler"
            }
        }
    ],
    "format": {
        "filename": "cam4_03-14-20.mp4",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "3609.431000",
        "size": "188039397",
        "bit_rate": "416773",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2avc1mp41",
            "encoder": "Lavf58.29.100"
        }
    }
}

关于如何在不重新编码的情况下更改容器有什么建议吗?

答案1

您使用选项-c:v。它通常用于重新编码视频。
使用方法如下:

ffmpeg -i input.avi output.mp4

相关内容