Hi everyone,
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.

Using the remuxing.c example, I met different issues :
- 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.
- 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.
- 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 ?

Here is my modified code for remuxing.c :

    // same that remuxing.c before, here is around line 130
    i = 0;
    int have_first_keyframe = 0;
    while (1) {
        AVStream *in_stream, *out_stream;
       
        ret = av_read_frame(ifmt_ctx, &pkt);
        if (ret < 0)
            break;
           
        i++;       
        if(i <= 54){ // random number to start further in the stream
            av_packet_unref(&pkt);
            continue;
        }
        fprintf(stderr, "pkt.flags : %d \n", pkt.flags);
        if(!have_first_keyframe){
            if((pkt.flags & AV_PKT_FLAG_KEY) == 0){
                // not a keyframe
                av_packet_unref(&pkt);
                continue;
            } else {
                have_first_keyframe = 1;
            }
        }
    // same that remuxing.c after except I use i = 700 to break the loop and 
stop remuxing

Here is what the output looks like :
pkt.flags : 0
No keyframe
pkt.flags : 1
First keyframe
pkt.flags : 1
pkt.flags : 0
pkt.flags : 1
pkt.flags : 1
pkt.flags : 0
pkt.flags : 1
pkt.flags : 0
pkt.flags : 1
pkt.flags : 1
pkt.flags : 1
pkt.flags : 0
pkt.flags : 1
pkt.flags : 1
pkt.flags : 0
pkt.flags : 1
pkt.flags : 1
pkt.flags : 0
pkt.flags : 1

Someone has any advice to record an RTSP stream ?
Yoann
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to