Issues with writing multi-stream MP4 file

Florian Echtler floe at
Tue Jun 20 13:04:54 UTC 2023

Hello everyone,

my Gstreamer application is writing two H.264 video streams and one Opus audio 
stream to a MP4 file. The relevant parts of the pipeline looks as follows:


queue max-size-time=100000000 leaky=downstream ! x264enc bitrate=1500 
speed-preset=ultrafast tune=zerolatency key-int-max=15 ! 
video/x-h264,profile=constrained-baseline,stream-format=avc ! queue ! mux.
(this part is present twice)

queue max-size-time=100000000 leaky=downstream ! opusenc bitrate-type=vbr 
inband-fec=true ! queue ! opusparse ! mux.

mp4mux name=mux fragment-duration=1000 latency=100000000 ! filesink sync=true 


The result is an MP4 file which I can play just fine in Totem on Ubuntu, and 
even switch between video streams using "Switch angles".

However, none of the following work:

- play it in VLC (plays a few seconds, then freezes)
- do anything with FFMPEG, e.g. split the streams (results are garbage)
- seek in the video (even in Totem)

In all cases, I get some messages about "Invalid NAL unit size" and/or 
"non-monotonous DTS". So what would I need to do to my output pipeline to get a 
"compliant" MP4 file?

Thanks and best, Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the gstreamer-devel mailing list