How can I send arbitrary data as part of an Ogg or Matroska stream in a GStreamer application? - gstreamer

I have live audio and video data that I can either send as an Ogg or Matroska (WebM) stream. I also have dynamic metadata that will be sent from the server to the client, and should be correlated with the A/V streams. For example, the exact server time when the audio packet was recorded.
I attempted to hack this with Kate encoding, but that appears to send all the subtitle data at once in the beginning, and not dynamically as it happens. If you could tell me how to send well-correlated dynamic subtitle data, then that's a viable solution as well.

Related

WebM packet headers for real time streaming

I need to stream webm video to browser from my video server.
The video server (C++) receives vp8 encoded frame packets of webcam or screen from the client with .ivf headers like <4_bytes_data_size><8_bytes_pts><vp8_encoded_data>. Also I send 4 bytes of total packet duration before the rest of data, so the server knows the presentation timestamp, size and duration of each frame.
The question is: which headers should I use for frames in order for the browser to be able to play the stream in the <video> tag. Maybe there is some standard for webm real time streaming implementing?
PS: AFAIK the webm consists of EBML markup. If the same is used in <video> tag to parse the stream, could someone explain me what are the minimal set of EBML elements for video playback (no audio, just video)?
Video tag does not support ivf. Minimum webm requirement is whatever the minimum is to package your stream.

Live555 How Client Decode Audio Data

I am trying to receive an rtsp audio stream via live555 lib from local network and write it to a wav file. Therefore I wrote an data sink class derived from MediaSink class, like done in the example 'testRTSPClient'. The connection is successfully established, but I don't know how to decode the data.
The format is 'L16', which should be uncompressed pcm data. I noticed that I can get details for writing my wav header from sdp description (2 channels, 44100 frequeny,...).
But which format has the data? How can I get my two channel data for writing to my wav file? With each iteration I receive a buffer of type uchar* with size 1400, which should be passed to a decoder.
Does someone has an idea about that?

How to obtain mp3 audio packets for streaming in C/C++

I want to be able to break a song into packets and have access to these individual packets.
The reason for that is that I want to send each individual packet over the network using an experimental network protocol called Named Data Network.
As the packets arrive at the destination I want to play them. So I want to implement a streaming functionality. The only difference is the network layer that I will use. This network layer is not based on IP.
Does anyone know any C/C++ implementation of breaking a song file into pieces and then playing these packets individually? I looked over Gstreamer, but it seems complicated to get individual packets from its pipeline structure.
I found this reference which was the closest to what I wanted, however it was not so clear for me: how can I parse audio raw data recorder with gstreamer?
Summarizing the points I need:
Break a song into packets
Play the audio content of a single packet (or a small set of packets).
Thank you very much for the help!
An MP3 file is just a succession of MP3 frames. Each frame is made of a header and a data block.
Splitting the MP3 file as MP3 frames will involve parsing the MP3 file. You can refer to this documentation for a good description of the format.
Note that in the case of mpeg layer 3 codec, frames are not independant. In the worst case, 9 input frames may be needed before beeing able to decode one single frame.
What I would do instead of this
I guess you could probably ignore most of these details and focus on the streaming problem itself. Here is what I would try to build first:
on the sender side, split a file into packets, and send them one by one using your system. Command example: send_stream test.mp3
on the receiver side, receive the packets and rebuild the original file. Command example: receive_stream test.mp3
Once you have this working fine, modify the receiver program so that it writes the packets in-order on the standard output. This will allow you to redirect stdout to a file
# sender side did not change
send_stream test.mp3
# receiver side
receive_stream > test.mp3
Then, you can use madplay to play the mp3 while it is received simply by redirecting receive_stream output to madplay:
# madplay - tells madplay to read its input from standard input.
receive_stream | madplay -
For a good mp3 decoder, take a look at MAD.

Write RTP Stream Data to file

I have written an application which triggers an IP Camera to stream it's data (MPEG4) over RTP. This works fine so far - I start to setup and start the stream with the corresponding RTSP commands ( DESCRIBE, SETUP and PLAY ).
While streaming I receive the usual Sender Reports and send my own Receiver Reports - Everything is working fine here.
Now with the application mentioned above, I do NOT read the stream. I have a seperate hardware , which just logs all the stuff going over the Ethernet ( a little bit like Wireshark ). Now when the whole streaming is finished I can download those logs from my hardware and extract data from them.
So what I have then is a logfile with all the data from the RTP stream as raw data.
My question would now is: How do I write this appropriately into a MPEG4 file? I know this is a very broad question and I don't expect to get a step-by-step tutorial. But actually I am a bit overwhelmed and don't know where to start.If I just memcpy all the Payload from the RTP messages sequentially into a MPEG4 file it doesn't work. Now I am also a bit confused by SDP and stuff.
Well maybe someone has a link or some help for me..?
You should first read RFC3016, which describes the RTP format of MPEG-4 stream, then you'll know how to extract MPEG-4 frames from the RTP stream.
I actually changed from MPEG4 to H.264 - it actually was a little bit easier to write a video file like this. For H.264 this answer covers it pretty much:
How to process raw UDP packets so that they can be decoded by a decoder filter in a directshow source filter

RTP H.264 save and replay

We are interested in saving a H.264 stream and replaying it. Is there any one who experience saving h.264 using winpcap and replaying it. We were able to save H.263 and replay, but same logic does not work for H.264.
We also tried rtpdump tool to save H264 stream, but we were unable to replay it in that format?
thanks in advance
An H.264 stream is usually sent as a Transport Stream (TS). If you want to save it to file then you need to demux it and then mux it to a format suitable for file storage, for example MP4.
You will probably need to disable bframes in your encoder. Saving an RTP H.264 didn't work for me with bframes enabled.
I also advise to use a low keyint value because the dump will only be readable after the first keyframe.
You can use VLC to save the incoming stream with this command:
vlc -I rc rtp://#:4444 :sout=#std{access=file,mux=mp4,dst=output.mp4} :ipv4
Replace 4444 with the port number.