Splitmuxsink mp4mux first segment missing key frame

I have a pipeline that dynamically add video recording branch having rtspsrc → h264 depay / parse → splitmuxsink. As a result it produces fmp4 files.

The recorder have mp4mux and robust muxing so that the moov item is in front. It records segments and all of them individually are playable, but the very first segment have an issue with keyframe.

ffprobe segment00.fmp4 reports st: 0 edit list: 1 Missing key frame while searching for timestamp: 0. This problem not exist for any sequential fragment.

What can i do to get splitmuxsink recording the first segment correctly since the first key-frame ?

Thanks!

Just to be sure, these are likely ‘normal’ mp4 files not fragmented mp4 files in the fmp4 sense.

Have you tried if rtph264depay wait-for-keyframe=true ! video/x-h264,alignment=au ! h264parse ! ... makes any difference?

I haven’t been able to reproduce the issue with videotestsrc is-live=true ! x264enc tune=zerolatency ! ... at least.

What GStreamer version are you using? (gst-inspect-1.0 rtspsrc | grep Version)

I tried rtph264depay wait-for-keyframe=true ! video/x-h264,alignment=au ! h264parse ! …, but it does not make any change.

I have Gstreamer 1.20.3.

I see that for the very first segment the I-Frame is not on pkt_pts_time=0.00000 as for subsequent segments made by splitmuxsink.

Here is the result:

ffprobe -hide_banner -select_streams v -skip_frame nokey -show_frames -show_entries frame=pkt_pts_time,pict_type 0_5182925e-1ec8-4728-844b-e9521452e32e_00000.mp4
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55ca13c37780] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '0_5182925e-1ec8-4728-844b-e9521452e32e_00000.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomiso2
    creation_time   : 2024-07-16T06:50:17.000000Z
  Duration: 00:00:03.90, start: 0.000000, bitrate: 18052 kb/s
  Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080, 18048 kb/s, SAR 1:1 DAR 16:9, 30.25 fps, 30 tbr, 10k tbn, 20k tbc (default)
    Metadata:
      creation_time   : 2024-07-16T06:50:17.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
[FRAME]
pkt_pts_time=0.733400
pict_type=I
[/FRAME]
[FRAME]
pkt_pts_time=1.801500
pict_type=I
[/FRAME]
[FRAME]
pkt_pts_time=2.866100
pict_type=I
[/FRAME]

Note, that I am adding mp4 recording branch dynamically.

Maybe I should wait for the key frame or make some other checks ?

This problem still important.

If any idea pops, thanks in advance!

I have a similar situation where I’m dynamically adding a chain to record to mp4 using splitmuxsink from a live rtsp src. I have a probe thats waits for a keyframe before setting up the new elements. That seems to work.

1 Like

Thank you, waiting for I-frame fixed the thing.

Hey,

I would like to achieve the same so you splitmuxsink to produce fmp4 files that I can later use for streaming using HLS. Can you share your final pipeline that worked for you?

Thanks.

Regards,
Marko