How many bytes of Opus payload need to be sent in one RTP packet - rtp

I have Ogg format file containing OPUS frames. As per my requirement, I need to parse this file (frames/packets), and send OPUS compressed data to a remote device through RTP.
My question is in one RTP packet (assuming 48khz sampling rate)
1. One OPUS frame will be sent
2. Or multiple OPUS frames will be sent
3. Or one packet as per Ogg file format specification, which may be one frame, 2 frames or arbitrary number of frames will be sent

Each Opus RTP packet contains only one Opus packet, as defined by the Opus specification. That may contain more than one Opus frame internally, but it must have the correct header bytes to signal this and conform to other rules, so make sure you mean the same thing the spec does by "frame".
Basically, you want to send each Opus packet out of the Ogg file in its own RTP packet. There's no packing at the RTP payload level. Don't send the Id or Comment headers in the first two packets of the .opus Ogg stream, and of course you need to prepend RTP headers with the appropriate flags, timestamp and so on.
See https://git.xiph.org/?p=opus-tools.git;a=blob;f=src/opusrtp.c#l517 for a toy implementation of this.

Related

[rtp/rtcp server]How to prepare a stored media file for steaming?

Now i'm trying to understand the rtp/rtcp protocol(RFC3550).
I knew that in common case,the audio and video steaming is separately.
But if i want to steaming a stored media file(such as *.mp4) in the server,
how does the server get those tracks from that media file?
RTP is all about carrying the real time data, how you break it up and put it into a RTP packet payload (Called "Packetizing") is up to the implementer, but let's look at a common use case of how you'd actually do this.
If you wanted to send your existing recorded MP4 file through an RTP stream you'd first break it into smaller chunks to be sent down the wire at regular intervals packed inside RTP packets.
Let's say you've got a 10 second MP4 file and you decide your packetization timer is 1 second, we'd split it into 10x 1 second long chunks of data we can put into our RTP payloads. (In practice you could use FFMPeg or something similar to split the MP4 into 1 second chunks)
Then we form our RTP header, we set the Payload Type to something custom, as there's no payload type for MP4 data assigned by IANA. We'd assign a starting sequence number, a Synchronization Source Identifier and a timestamp, and then we'd fill the payload with the first 1 second of data.
1 second after that we'd increment the sequence number by 1, add 1 second to the timestamp, add the next 1 second of data to the payload and send the next RTP header.
We'd then repeat this 8 more times until we've sent 10 RTP packets containing our 10x 1 second MP4 payloads.
If you actually wanted to go about implementing this I wrote this simple Python Library for creating RTP packets,
To learn more about RTP there's obviously RFC 3550, for a really in depth look at RTP there's a great book by Colin Perkins called "RTP: Audio and Video for the Internet" and I've written a bit about all the RTP headers and their meaning.
In practice if you want to get a pre-recorded MP4 file from point A to point B there's better protocols for it than RTP, RTP is focused on the real time transfer of media, as in live-streaming style, not transferring existing pre-recorded media files, FTP, HTTP or even some of the peer-to-peer protocols would be better suited at transferring this.

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

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.

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?

Avcodec : generate OPUS header for a stream

I'm using OPUS with avcodec to encode sounds and stream it using my own protocol.
It works with the MP2 codec so far but when I'm switching to OPUS, I have this issue :
[opus # 1b06d040] Error parsing the packet header.
I suppose that unlike MP2, I need to generate a header for my OPUS encoded data stream but I don't know how.
Can someone explain me how to do that? Thanks.
This error comes from ff_opus_parse_packet() failing, which handles the raw opus packet header, what the specification calls the 'TOC' (for table-of-contents) byte and optional subframe lengths. It means libavcodec couldn't find the packet duration where it expected.
So probably your custom protocol is corrupting the data, returning the wrong data length, or you're otherwise not splitting the opus packet out of your framing layer correctly.
You don't need to invent your own protocol if you don't want to. There are two established designs: Opus over RTP for interactive use (like live chat where latency matters) is documented in RFC 7587. For HTTP streaming, file storage for recording, playback and other applications like that use the Ogg container, documented here. There are implementations of both of these in libavformat. See rtpenc.c, oggenc.c and oggparseopus.c if you're curious about the details.

RTP payload Depacketization for bandwidth Efficient mode for AMR

Do anybody have idea that how can i convert the RTP packetized AMR audio content into standalone AMR file?
I have the dump of RTP payload and I want to convert it into the standalone AMR file. I have followed up RFC 3267 and RFC 4867 and understood the byte pattern but I havenot found anywhere the also where i can see how can i packetize the AMR frames into RTP or vice-versa.
Regards
Nitin
Done and depacketize the content using the answer givne on the link
AMR Raw Output from Wireshark not playing in players