Hi everyone,<br>I am trying to remux a mp4 RTSP stream (provided by an ffserver) into a mp4 file, but I am struggling to get the file set correctly. I do not want to re-encode the stream for performances reasons.<br><br>Using the remuxing.c example, I met different issues :<br>- if I use the example directly, the PTS and DTS of the firsts frames are mixed up and av_write_interleaved_frames gives me a "Application provided invalid, non monotonically increasing dts to muxer in stream 0: 4752 >= 4752" error.<br>- if I skip a random amount of frames (I would also like to be able to start remuxing from anywhere in the stream and not only from the start), it produces a file which is eventually readable but analyzing it with ffprobe -show_frames, it throws me a "Missing key frame while reordering index according to edit list", which is understandable, I need my first frame to be an keyframe I think.<br>- If I try to use AV_PKT_FLAG_KEY to ensure my first frame is a keyframe, it does not changes anything, and printing the pkt.flags field give me that almost one frame on 2 i a keyframe, which is false, it is around 1 on 10 for my RTSP stream. Am I not using this flag correctly ?<br><br>Here is my modified code for remuxing.c :<br><br>    // same that remuxing.c before, here is around line 130<br>    i = 0;<br>    int have_first_keyframe = 0;<br>    while (1) {<br>        AVStream *in_stream, *out_stream;<br>       <br>        ret = av_read_frame(ifmt_ctx, &pkt);<br>        if (ret < 0)<br>            break;<br>           <br>        i++;       <br>        if(i <= 54){ // random number to start further in the stream<br>            av_packet_unref(&pkt);<br>            continue;<br>        }<br>        fprintf(stderr, "pkt.flags : %d \n", pkt.flags);<br>        if(!have_first_keyframe){<br>            if((pkt.flags & AV_PKT_FLAG_KEY) == 0){<br>                // not a keyframe<br>                av_packet_unref(&pkt);<br>                continue;<br>            } else {<br>                have_first_keyframe = 1;<br>            }<br>        }<br>    // same that remuxing.c after except I use i = 700 to break the loop and stop remuxing<br><br>Here is what the output looks like :<br>pkt.flags : 0<br>No keyframe<br>pkt.flags : 1<br>First keyframe<br>pkt.flags : 1<br>pkt.flags : 0<br>pkt.flags : 1<br>pkt.flags : 1<br>pkt.flags : 0<br>pkt.flags : 1<br>pkt.flags : 0<br>pkt.flags : 1<br>pkt.flags : 1<br>pkt.flags : 1<br>pkt.flags : 0<br>pkt.flags : 1<br>pkt.flags : 1<br>pkt.flags : 0<br>pkt.flags : 1<br>pkt.flags : 1<br>pkt.flags : 0<br>pkt.flags : 1 <br><br>Someone has any advice to record an RTSP stream ?<br>Yoann<br>