ffmpeg:格式“null”意味着什么?

ffmpeg:格式“null”意味着什么?

我试图准确理解“null”格式的含义。我确实阅读了以下文档:

但我无法理解以下场景。考虑一下:

$ ffmpeg -y -hide_banner -i input.mkv -ss 0 -t 1 -an -sn -c:v mpeg4 -f mp4 /dev/null
[mpeg4 @ 0x562dc220aa00] Failed to parse extradata
Input #0, matroska,webm, from 'input.mkv':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 01:07:47.92, start: 0.000000, bitrate: 1433 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 688x512 [SAR 1:1 DAR 43:32], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
    Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 80 kb/s (default)
    Metadata:
      DURATION        : 01:07:47.880000000
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, mp4, to '/dev/null':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 688x512 [SAR 1:1 DAR 43:32], q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
      encoder         : Lavc58.35.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=   25 fps=0.0 q=1.6 Lsize=      16kB time=00:00:00.96 bitrate= 140.1kbits/s dup=2 drop=0 speed=32.3x    
video:15kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.221970%

而使用空格式:

$ ffmpeg -y -hide_banner -i input.mkv -ss 0 -t 1 -an -sn -c:v mpeg4 -f null /dev/null
[mpeg4 @ 0x5645807d5a00] Failed to parse extradata
Input #0, matroska,webm, from 'input.mkv':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 01:07:47.92, start: 0.000000, bitrate: 1433 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 688x512 [SAR 1:1 DAR 43:32], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
    Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 80 kb/s (default)
    Metadata:
      DURATION        : 01:07:47.880000000
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: mpeg4, yuv420p, 688x512 [SAR 1:1 DAR 43:32], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
      encoder         : Lavc58.35.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[mpeg4 @ 0x564580804380] Invalid pts (2) <= last (3)
Video encoding failed
Conversion failed!

我该如何解释上述错误?重复如下:

[mpeg4 @ 0x564580804380] Invalid pts (2) <= last (3)
Video encoding failed
Conversion failed!

更新,使用-enc_time_base -1给出:

$ ffmpeg -y -hide_banner -i input.mkv -ss 0 -t 1 -an -sn -c:v mpeg4 -enc_time_base -1  -f null /dev/null 
[mpeg4 @ 0x561134551ac0] Failed to parse extradata
Input #0, matroska,webm, from 'input.mkv':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 01:07:47.92, start: 0.000000, bitrate: 1433 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 688x512 [SAR 1:1 DAR 43:32], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
    Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 80 kb/s (default)
    Metadata:
      DURATION        : 01:07:47.880000000
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: mpeg4, yuv420p, 688x512 [SAR 1:1 DAR 43:32], q=2-31, 200 kb/s, 25 fps, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
      encoder         : Lavc58.35.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[mpeg4 @ 0x561134582100] Invalid pts (80) <= last (120)
Video encoding failed
Conversion failed!

答案1

空复用器接受来自编码器的数据包并将其丢弃。不会对数据包进行任何处理,也不会执行任何 I/O 操作。

-f mp4 /dev/null所做的就是将数据包传递给 MP4 复用器,然后将 MP4 复用器的 I/O 目标定向到/dev/null。因此,就 MP4 复用器而言,它正在写出数据。操作系统负责丢弃接收到的数据。

空复用器的作用是将视频流的时间基准设置为帧速率的倒数。对于可变帧速率流,这可能导致 MPEG-4 编码器不喜欢的冲突或非单调时间戳。添加-enc_time_base -1

相关内容