丢弃数据包而不是导致 DTS 错误

Drop packets instead of causing DTS error

我有 2 个 ffmpeg 实例,它们正在通过用 C 编写的缓冲区。

其中一个 ffmpeg 实例正在创建 FLV 输出并将其发送到连接到 C 程序的 TCP 套接字。 C正在填充一个数组,然后将数据包发送到另一个ffmpeg实例。

关键是第一个ffmpeg实例可以断开连接,可以重新启动。

另一个 ffmpeg 实例看起来像这样:

ffmpeg \
    -re \
    -fflags +igndts \
    -fflags flush_packets \
    -fflags discardcorrupt \
    -r 25 \ \
    -i $INPUT_VIDEO_STREAM \
    -safe 0 \
    -i music.txt \
    -fflags +genpts \
    -c:a mp3 \
    -b:a 320k \
    -c:v copy \
    -frame_drop_threshold 1.0
    -preset ultrafast \
    -f flv  rtmp://live.twitch.tv/app/live_KEY \
    -async 1 \
    -vsync 2

问题是,如果我停止另一个ffmpeg实例并重新启动它,我会得到“Packet lost”错误,之后,我会在输出流错误中得到一堆非单调DTS。

[flv @ 0x55acf23632a0] Packet mismatch -1135911011 34757 9695626ate=1560.2kbits/s speed= 1x

... [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19080; changing to 62560. This may result in incorrect timestamps in the output file. [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19120; changing to 62560. This may result in incorrect timestamps in the output file. [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19160; changing to 62560. This may result in incorrect timestamps in the output file. [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19200; changing to 62560. This may result in incorrect timestamps in the output file. [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19240; changing to 62560. This may result in incorrect timestamps in the output file. [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19280; changing to 62560. This may result in incorrect timestamps in the output file. [flv @ 0x55acf23d0ec0] Non-monotonous DTS in output stream 0:0; previous: 62560, current: 19320; changing to 62560. This may result in incorrect timestamps in the output file. ...

我想要的是继续播放mp3并丢弃坏的视频包,视频剪辑可以被剪切,新的剪辑可以开始播放。如果视频在几秒钟内表现异​​常,即使这样也没关系,但流需要连续。

我已经尝试过的事情:

我也开始写一个setpts filter,但是搞不懂语法

如何串流mp3列表,视频时间戳不连续,有时会丢包?

问题似乎是“-c:v copy”造成的。 我将 -c:v copy 更改为 -c:v libx264,现在它按预期工作了。

我还在音频输入前添加了-re