Hi all, I’m fairly new to Gstreamer so interested in solving my problem and any suggested debugging approaches. I have some approaches that seem to work but I’m not really sure they are right, so looking for some advice ![]()
What I’m trying to do is pull from an RTSP video stream (from a remote IP camera), h264 encoded, and write to MP4 without decoding / re-encoding the video.
My pipeline looks like this:
pipeline = Gst.parse_launch(
f"rtspsrc location={url} ! "
"rtph264depay ! video/x-h264,stream-format=avc,alignment=au ! "
"h264parse name=parser ! "
"mp4mux ! "
"filesink location=foo.mp4"
)
When there are network constraints (and I can recreate this by tethering my laptop to my phone on 4G) I will at a some point get an error from muxer:
Could not multiplex stream
../gst/isomp4/gstqtmux.c(5402): gst_qt_mux_add_buffer (): /GstPipeline:pipeline0/GstMP4Mux:mp4mux0:
Buffer has no PTS.
I’ve added buffer probes to both the the sink and src pads on h264parse and what I see is that usually there are pts on the buffer going in and out (the same values) but at some point when the bandwidth is constrained I will start to get successive buffers on the sink with identical pts, and the then the buffers on the src will have Gst.CLOCK_TIME_NONE.
These are things I’ve tried:
- Remove
h264parseentirely – then I get a pipeline errorstreaming stopped, reason not-negotiated (-4)unless I addwidth=1280,height=720to the caps filter.- In this case I still see the repeated
ptsvalues (probing anidentityin place of theh264parse) but the muxer seems to happy and the resulting MP4 is playable. - In my test-case I know the width and height so this is OK, but in practise won’t always, so not sure it’s the right solution.
- In this case I still see the repeated
- Using the
srcprobe on the parser to drop any buffers withpts == Gst.CLOCK_TIME_NONE.- This also seems to work and produce a playable mp4, but I’m not sure it’s “the right answer”?
- I’ve tried different options in the caps filter (e.g
stream-format=byte-stream,alignment=nal) to see if that alters the behaviour ofh264parsein some way, but doesn’t seem to make a difference.
My aim is to have a playable MP4, of the best quality I can achieve, accepting that there is some unavoidable degradation if the bandwidth is limited. Any advice appreciated, thanks!