how to use opus DTX from opensource OPUS demo binary - opus

i want help in OPUS DTX
1.how OPUS DTX is working.
2.how opus encoder and decoder works for dtx
3.Is there any bit representation for DTX in OPUS
From rfc When DTX is enabled, only one frame is encoded
every 400 milliseconds it didnt works for me with opus_demo binary.
please help with OPUS DTX.

When using Opus over a network, using a protocol such as RTP where the packets are timestamped, DTX may be enabled if you want to reduce the packets sent during periods where there is no voice activity. A packet would still be sent about every 400 ms, updating background noise. Using the packet timestamps the receiver can determine the duration of any gaps and fill them in with the background noise to keep it sounding natural.
Enable DTX in the encoder using opus_encoder_ctl(enc, OPUS_SET_DTX(1));, or with the -dtx option on opus_demo. Then, simply do not send any packets produced by the encoder with a length of 2 bytes or less. (These "DTX packets" are just zero-length frames, with a normal 1- or 2-byte packet header (TOC), and do not contain any audio data.) Packets with a length larger than 2 bytes should be sent as usual.
The receiver should use normal packet loss concealment to handle missing packets, in the same manner as it would handle packet loss. In particular it can call opus_decode() with data = NULL, len = 0, and frame_size equal to the size of the missing frame(s), and the decoder will generate audio data to conceal the missing frame(s).

Related

save opus packet to ogg container

I have opus packets which is merged from 2 frames.
Size of packet can be great than 255 byte (max segment size in ogg page)
I can split this packet into two packets with single frame and save each in separated segment.
But... Can we simple split packet into parts\chunks 255 bytes + last part less then 255
ang put it in sequence segments into ogg page?
It doesn't work to me (maybe incorrect code). But I am interesting how to handle it properly? We really need to repack doubled packets to separated packet? or not?
Sorry for my pure english.
No need to repacketize. I forgot about special case when length of packet is 255, we need add 0 to segment table

What value to use for Libopus encoder max_data_bytes field?

I am currently using libopus in order to encode some audio that I have.
When consulting the documentation for how to use the encoder, one of the arguments the encode function takes in is max_data_bytes, a opus_int32 that has the following documentation:
Size of the allocated memory for the output payload. May be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control
Unfortunately, I wasn't able to get much out of this definition as to how to set the upper size and the relation of this argument to bitrate. I tried consulting some of the examples provided such as this or this but both have the argument defined as some constant without much information.
Could anyone help me understand the definition of this value, and what number I might be interested in using for it? Thank you!
Depends on encoder version and encoding parameters.
In 1.1.4 the encoder doesn't merge packets and the upper limit should be 1275 byte. For the decoder, if repacketizer is used, you could find some packet up to 3*1275.
Things could be changed in recent version, I'm quite sure that the repacketizer has been somehow merged in the encoder. Look into the RFC.
Just paste here some of my notes from a 1½ years ago...
//Max opus frame size if 1275 as from RFC6716.
//If sample <= 20ms opus_encode return always an one frame packet.
//If celt is used and sample is 40 or 60ms, two or three frames packet is generated as max celt frame size is 20ms
//in this very specific case, the max packet size is multiplied by 2 or 3 respectively

OPUS packet size

I have an application, that reads opus packets from a file. The file confirms opus packets in ogg format. My application sends each opus packet every 20 millisecond (it is configurable).
For 20 millisec, it sends packets of sizes ranging from 200 bytes to 400 bytes, say average size is 300 bytes.
Sending 300 bytes for 20millsec, is it right or its too much of data. How can I calculate for 20millisec how much data (in bytes) I can send to remote.
Can somebody help me to understand how to calculate number of bytes I need to send to remote party per 20millisec.
300 bytes/packet × 8 bits/byte / 20 ms/packet = 120 kbit/s
That is enough for good quality stereo music. Depending on the quality that you need, or if you are only sending mono or voice, you could potentially reduce the bitrate of the encoder. However if you are reading from an Ogg Opus file then the packets are already encoded, so it is too late to reduce the bitrate of the encoder unless you decode the packets and re-encode them at a lower bitrate.

UDP packet drop issue in Wireshark while wiritng to pcap file

My FPGA is continuously sending UDP packets on network using 10/100/1000 Mbps Ethernet. I am using Wireshark to capture the packets directly to a .pcap file & then extract & display UDP data in Matlab GUI. FPGA kit is connected to a 1 Gbps switch and then to PC.
Initially i tried using Matlab's built in UDP object instead of .pcap files but using that i was facing packet drop issue at high BW (>1 Mbps) and was only able to achieve drop free reception for very low BW around 110 kbps. That was not acceptable for my case. A link to the problem is given below:
Incorrect UDP data reception in Matlab
Based on these problems i moved towards using Wireshark. I use wireshark to create multiple .pcap files (1 Mb) of UDP data and then start extracting UDP data from these files in Matlab. A link also guided towards this approach i.e. writing packets directly to file(High speed UDP receiver in MATLAB
).
The problem is that i am getting some packets dropped at random intervals. The problem is very frequent when operating at High Ethernet BW - 220 Mbps. So i reduced my BW to around <50 Mbps still i get some packet drops. I tried using some of the tips provided by Wireshark (http://wiki.wireshark.org/Performance) for optimizing performance but still the issue persists.
This seems to be issue with memory as far as i have understood.
Some details about the design:
UDP Data Size = 64 Bytes
Ethernet Frame Size = 110 Bytes
PCAP File Size = 1 Mb
Wireshark Buffer Size = 1 Gb
Please guide me towards a possible solution.
Regards,
Sameed
I would suggest a larger file size may provide efficiency savings, something like 64MB. Also agree with Slava's suggestion - tcpdump is more efficient/robust than the wireshark GUI.
Try writing to a ram disk
[Padding]

Manage Camera video stream with MatLab

I can receive from the camera a packet that contains information about the frame. So, I know its size. The rest of the packet is an array of bytes (uint8).
I would like to know how to manage this packet of bytes and how to decode it in order to get a frame. I know from the header that the frame can be I-frame or P-frame and that its size is 640x360. The encoding can be set to H264 or MP4. I'm working with MatLab script, which is an M-file. If MatLab cannot manage this array of bytes directly, I would like to know how a byte stream works, to be able to re-assamble the frame myself.