Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streaming MP4 Video File on Gstreamer

I am working on gstreamer for first time and trying to Stream an MP4 Video file from a server to client using Gstreamer (RTP and UDP) . The Command Line which I am trying to use :

On Server Side:

gst-launch-1.0 -v filesrc location = file_name.mp4 ! decodebin ! x264enc ! rtph264pay ! udpsink host=192.1XX.XX.XX port=9001

On Client Side:

gst-launch-1.0 -v udpsrc port=9001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtpstreamdepay ! decodebin ! videoconvert ! autovideosink

I am able to Stream the video successfully. But, I don't want decodebin and x264enc operations on the server side. So, I removed these operations and used this command line on the server side

gst-launch-1.0 -v filesrc location =file_name.MP4 !  rtpstreampay ! udpsink host=192.1XX.XX.XX port=9001

On which I was not able to Stream the Video.

Could anybody guide me, why do we need to have the decode and encode operations in this scenario while sending the data. Is there any way by which we can send data without using these operations.

Thanks.

like image 794
Pratyush Kulwal Avatar asked Apr 22 '15 09:04

Pratyush Kulwal


People also ask

Does VLC use GStreamer?

Since GStreamer can be used for network streaming, programs like VLC can be used to capture this media stream using a SDP file.

What is MP4 mux?

The Dolby MP4 streaming muxer (dlb_mp4base) is a software implementation of a muxer of fragmented or unfragmented ISO base media file format (mp4). It supports muxing of Dolby Digital (AC-3), Dolby Digital Plus (E-AC-3), and Dolby AC-4 audio formats as well as Dolby Vision.


2 Answers

Decoding and re-encoding is not necessary. The element you are after is demultiplexer, and in this case, qtdemux.

Here a clip from it's document:

Demultiplex a QuickTime file into audio and video streams ISO base media file format support (mp4, 3gpp, qt, mj2)

It is enough to demultiplex the video container open and just read the encoded video stream directly from the container. mp4 containers usually contain H.264 encoded video, so your server-side pipeline would simplify into:

gst-launch-1.0 -v filesrc location = file_name.mp4 ! qtdemux ! video/x-h264 ! rtph264pay ! udpsink host=192.1XX.XX.XX port=9001
like image 155
Hannes R. Avatar answered Oct 14 '22 04:10

Hannes R.


Make sure you know the encoding of the video you are trying to stream. With VLC you can get the codec information:

For H264:

enter image description here

The following pipeline works:

filesrc location=<video location>.mp4 ! qtdemux ! h264parse config-interval=-1 ! rtph264pay pt=96 name=pay0

And for mp4v:

enter image description here

The following pipeline works:

filesrc location=<video location>.mp4 ! qtdemux ! mpeg4videoparse ! rtpmp4vpay pt=96 name=pay0

Also the examples above work if you only care about streaming the video as is. A different pipeline is needed if you want to change the encoding or any other video property.

like image 40
est.tenorio Avatar answered Oct 14 '22 02:10

est.tenorio