Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


This forum has not been maintained for a long time and will probably get deleted in the near future.
For faster responses to your questions, please use StackOverflow instead and tag your questions with "FFmpeg".
If you need a backup of the posts from this forum, please contact me directly.

ffmpeg growing latency as the time passes.

Discussions about problems encountered using ffmpeg.
Forum rules
FFmpeg is in a state of perpetual development and we do not currently have the person power to backport fixes to official releases. As such, if you wish to query or report a bug, you must try with the latest development branch revision of FFmpeg to confirm the issue still exists. The latest FFmpeg can be downloaded from here: http://www.ffmpeg.org/download.html

ffmpeg growing latency as the time passes.

Postby faisalbmc » Thu Mar 16, 2017 1:05 pm

I'm a very new user of ffmpeg and very new to audio streaming in general. I'm trying to audio to and from an Axis P5515 camera from a Ubuntu 14.04.1 system. As of now I have been using the following command to access to the audio stream from the camera:

Code: Select all
ffmpeg -probesize 32 -analyzeduration 32 -i rtsp://operator:operator@10.10.210.2/axis-media/media.amp?audio=1 -preset ultrafast -f alsa default

When I command this from the terminal, the response I get is shown in the image below:
Image

And the following command is used to transmit to the camera:

Code: Select all
ffmpeg -f alsa -i default -probesize 32 -analyzeduration 32 -c:a pcm_mulaw -ab 128k -ac 1 -ar 16000 -f wav -chunked_post 0 -content_type audio/axis-mulaw-128 http://operator:operator@10.10.210.2/axis-cgi/audio/transmit.cgi

The response I get in terminal is shown in the image below:
Image

The problem is that for some reason there is an initial latency of 500ms which increases as the time passes. My application needs to be run without any interruption for an unlimited time, even for months.

Right now, to cope with this increasing latency I'm restarting the streaming every hour, but I'd like to know what's causing the latency and if there's any way I can get rid of that and get keep the streaming running without restarting.

Could you please suggest me any way to diagnose this issue and find a root cause to it?
faisalbmc
 
Posts: 7
Joined: Fri Nov 11, 2016 2:06 pm

Re: ffmpeg growing latency as the time passes.

Postby milan » Thu Mar 16, 2017 2:13 pm

Not familiar with audio transcoding but I noticed you used "rtsp" from camera to alsa and "http" from alsa to camera. By default, rtsp / rtp uses udp as the transport protocol whereas http uses tcp, which introduces retransmission delay. Is there any reason why you use different protocols?
milan
 
Posts: 6
Joined: Tue Mar 14, 2017 10:06 am

Re: ffmpeg growing latency as the time passes.

Postby faisalbmc » Thu Mar 16, 2017 2:41 pm

milan wrote:Not familiar with audio transcoding but I noticed you used "rtsp" from camera to alsa and "http" from alsa to camera. By default, rtsp / rtp uses udp as the transport protocol whereas http uses tcp, which introduces retransmission delay. Is there any reason why you use different protocols?

The reason is that I couldn't find a way to access the audio from the Axis P5515 camera via http protocol and could not find a way to transmit audio to the camera via rtsp protocol. But why should they matter? Aren't transmission and reception independent of each other?
faisalbmc
 
Posts: 7
Joined: Fri Nov 11, 2016 2:06 pm

Re: ffmpeg growing latency as the time passes.

Postby milan » Fri Mar 17, 2017 12:24 am

Http only guarantees lossless but not timely delivery of data. For one-way streaming such as movie playback, http is acceptable because you will not notice a difference if a one-hour movie is dragged longer by one minute or so. For two-way communication such as voice chat, the accumulated retransmission delay will end up breaking the synchronization between the two ends.

If the axis cam only provides http for sending voice data, I am afraid there is little you can do. You could try to minimize the transmission and receive buffers if there is such an option but this will only alleviate the problem a bit. After all, the interface is provided for broadcasting announcement only and not for voice chat.
milan
 
Posts: 6
Joined: Tue Mar 14, 2017 10:06 am

Re: ffmpeg growing latency as the time passes.

Postby faisalbmc » Thu Mar 30, 2017 8:50 am

milan wrote:Http only guarantees lossless but not timely delivery of data. For one-way streaming such as movie playback, http is acceptable because you will not notice a difference if a one-hour movie is dragged longer by one minute or so. For two-way communication such as voice chat, the accumulated retransmission delay will end up breaking the synchronization between the two ends.

If the axis cam only provides http for sending voice data, I am afraid there is little you can do. You could try to minimize the transmission and receive buffers if there is such an option but this will only alleviate the problem a bit. After all, the interface is provided for broadcasting announcement only and not for voice chat.

But latency also occurs when I run ffmpeg from terminal to only receive the audio from the camera transmitted via rtsp. In my OP I have already posted how I do the reception via the terminal.

I have tested while only doing the reception, so it was only one way voice communication, even then latency grew over time. Surely it's not the fault of http, is it?
faisalbmc
 
Posts: 7
Joined: Fri Nov 11, 2016 2:06 pm

Re: ffmpeg growing latency as the time passes.

Postby milan » Wed Apr 05, 2017 4:11 am

There are also some buffering latency here and there in the whole path. Since your stream is audio only, there is no clock source to sync to (for video-audio streams, the video will be sync'ed to the audio clock) and the timing will drift eventually. You can try to add "-sync ext" to make it sync to the computer clock instead.
milan
 
Posts: 6
Joined: Tue Mar 14, 2017 10:06 am


Return to ffmpeg

Who is online

Users browsing this forum: No registered users and 4 guests