Reputation: 85
I have 2 ffmpeg instances which are going through a buffer that is written in C.
One of the ffmpeg instance is creating an FLV output and sending it to a TCP socket, which is connected to the C program. The C is filling up an array, then sends the packets to the other ffmpeg instance.
The point is that the first ffmpeg instance can loose connection, and can be restarted.
The other ffmpeg instance looks something like this:
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
The problem is, if I stop the other ffmpeg instance and restart it, I will get "Packet lost" error, and after, I will get a bunch of Non-monotonous DTS in output stream errors.
[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. ...
What I would like to happen is to continue playing the mp3 and drop the bad video packages, the video clip can be cut and the new clip can start playing. Even that would be OK if video is behaving strange for some seconds, but stream need to be continuous.
Things I already tried:
I also started to write a setpts filter, but couldn't figure out the syntax
How can I stream the mp3 list that way that the video timestamps are not continuous, packet loss will happen sometimes?
Upvotes: 1
Views: 3521
Reputation: 85
It seems like that "-c:v copy" was causing the problem.
I changed -c:v copy
to -c:v libx264
and now it works as intended.
I also added -re
before the audio input.
Upvotes: -3