ffmpeg concat失败,dts计时错误

问题描述

我有一些视频试图与ffmpeg结合,它们本身都可以正常工作,但尝试通过以下命令对其进行结合:

ffmpeg -f concat -safe 0 -fflags flush_packets -fflags discardcorrupt -i ./videos.txt -c copy -an 1.mp4

这不是实时流或mpeg破折号,它只是我想加入一个较长视频中的独立mp4。

这只是不断的错误流:

[mp4 @ 0x5560664a1780] Non-monotonous DTS in output stream 0:0; prevIoUs: 72811593,current: 4396274; changing to 72811594. This may result in incorrect timestamps in the output file.
[mp4 @ 0x5560664a1780] Non-monotonous DTS in output stream 0:0; prevIoUs: 72811594,current: 4396786; changing to 72811595. This may result in incorrect timestamps in the output file.
[mp4 @ 0x5560664a1780] Non-monotonous DTS in output stream 0:0; prevIoUs: 72811595,current: 4397298; changing to 72811596. This may result in incorrect timestamps in the output file.
[mp4 @ 0x5560664a1780] Non-monotonous DTS in output stream 0:0; prevIoUs: 72811596,current: 4397810; changing to 72811597. This may result in incorrect timestamps in the output file.

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e9b217ab40] Dropped corrupted packet (stream = 0)
[mov,mj2 @ 0x55e9b217ab40] stream 1,offset 0x402a6: partial file
./videos.txt: Invalid data found when processing input

请注意,这些不是.ts视频,而是mp4视频。

Here's an example of ffprobe from
      Metadata:
        minor_version   : 512
        major_brand     : isom
        compatible_brands: isomiso2avc1mp41
        comment         : vid:v09044820000brpbed8biap950ufpcr0
        encoder         : Lavf58.20.100
      Duration: 00:00:14.70,start: 0.000000,bitrate: 901 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661),yuv420p,576x1024 [SAR 1:1 DAR 9:16],830 kb/s,29.97 fps,29.97 tbr,11988 tbn,59.94 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D),44100 Hz,stereo,fltp,64 kb/s (default)
        Metadata:
          handler_name    : SoundHandler

一个视频文件

  Metadata:
    minor_version   : 512
    major_brand     : isom
    compatible_brands: isomiso2avc1mp41
    comment         : vid:v090447e0000bo8lplu9uukrbn9qbupg
    encoder         : Lavf58.20.100
  Duration: 00:00:12.12,bitrate: 791 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661),yuv420p(tv,smpte170m/bt470bg/smpte170m),576x1024,718 kb/s,30 fps,30 tbr,1000k tbn,60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D),64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

解决方法

所有输入必须具有相同的属性才能获得最佳结果。您的帧速率和时标有所不同。使输入1与输入2匹配的示例:

ffmpeg -i 2997.mp4 -r 30 -video_track_timescale 1000k -c:a copy 30.mp4

这将消除Non-monotonous DTS错误。 Invalid data found when processing input错误可能无关。