I managed to mux both audio and video streams and save them into a single MP4 file using GStreamer. For example:
gst-launch-1.0 -v
videotestsrc ! videoconvert ! x264enc ! h264parse ! mpegtsmux name=mux ! filesink location=output.mp4
audiotestsrc ! audioconvert ! audioresample ! avenc_aac ! aacparse ! mux.
However, when I attempted to split this process into two parts – sender and receiver – I encountered issues with the receiver part. Here’s how I’m sending it:
Sender:
gst-launch-1.0 -v
videotestsrc ! videoconvert ! x264enc ! h264parse ! mpegtsmux name=mux ! udpsink host=127.0.0.1 port=5000
audiotestsrc ! audioconvert ! audioresample ! avenc_aac ! aacparse ! mux.
I also tried to simplify it by just sending either the video or audio stream, but didn’t manage to get it to work hence I am here hoping someone will help… Any guidance on how to properly set up the receiver would be greatly appreciated. Thank you!
- Note: The process involves streaming, and it’s important for me to splitmuxsink the data into smaller MP4 files. Additionally, I don’t necessarily need to use udpsink, as long as the data can be transferred over the network.”
I have tried various suggestions since then. For example, below is one attempt where I tested sending only video:
gst-launch-1.0 -v videotestsrc ! videoconvert ! x264enc ! h264parse ! mpegtsmux name=mux ! udpsink host=127.0.0.1 port=5000
For the receiver part, something like this:
gst-launch-1.0 -v -e udpsrc port=5000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtpjitterbuffer ! rtph264depay ! h264parse ! mp4mux ! filesink location=/tmp/received_video.mp4
I added -e to include end-of-stream (EOS) signaling, also tried switching between different muxers. However, some attempts resulted in the generated MP4 file having a size of 0 bytes, while others produced files with content that were unable to play.
Justyoung17 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.