[FFmpeg-user] ffmpeg latency and lag combining audio and video on Raspberry Pi
Neik
neik at rikai.com
Fri Jun 12 22:20:51 CEST 2015
On 2015-06-12 19:43, Lou wrote:
> On Fri, Jun 12, 2015, at 04:32 AM, Neik wrote:
>> I am trying to stream combined audio and video from a Raspberry Pi.
>>
>> To capture video alone I use:
>>
>> raspivid -o - -t 0 -n -w 1280 -h 720 -fps 25 | ffmpeg
>> -thread_queue_size
>> 1024 -y -f h264 -framerate 25 -i - -vcodec copy -f mpegts
>> udp://44.0.0.95:1234
>
> Console output missing.
>
>> It takes 6 seconds for the streaming status line to appear. The video
>> then lags reality by about 2.3 seconds
>>
>> Why does this delay occur? How can I reduce it to zero?
>>
>> To combine video and audio I use:
>>
>> raspivid -o - -t 0 -n -w 1280 -h 720 -fps 25 | ffmpeg
>> -thread_queue_size
>> 1024 -y -f h264 -framerate 25 -i - -thread_queue_size 512 -f alsa -ac
>> 1
>> -i hw:1 -vcodec copy -acodec mp3 -f mpegts udp://44.0.0.95:1234
>>
>> The output is
>
> Complete console output missing. This is required information.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
VIDEO ONLY:
It takes 6 seconds for the streaming status line to appear. The video
then lags reality by about 2.3 seconds
root at raspberrypi:~# raspivid -o - -t 0 -n -w 1280 -h 720 -fps 25 |
ffmpeg -thread_queue_size 1024 -y -f h264 -framerate 25 -i - -vcodec
copy -f mpegts udp://44.0.0.95:1234
ffmpeg version N-72834-gfd004e1 Copyright (c) 2000-2015 the FFmpeg
developers
built with gcc 4.6 (Debian 4.6.3-14+rpi1)
configuration: --enable-libmp3lame
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
Input #0, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 1280x720, 25 fps, 25 tbr,
1200k tbn, 50 tbc
Output #0, mpegts, to 'udp://44.0.0.95:1234':
Metadata:
encoder : Lavf56.36.100
Stream #0:0: Video: h264, yuv420p, 1280x720, q=2-31, 25 fps, 25 tbr,
90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
frame= 363 fps= 39 q=-1.0 size= 13020kB time=00:00:14.52
bitrate=7345.9kbits/s
VIDEO AND AUDIO:
5.5 seconds to "Stream #0:0:", then a pause of 6.2 seconds. Audio lags
2s, audio 10.4s
root at raspberrypi:~# raspivid -o - -t 0 -n -w 1280 -h 720 -fps 25 |
ffmpeg -thread_queue_size 1024 -y -f h264 -framerate 25 -i -
-thread_queue_size 512 -f alsa -ac 1 -i hw:1 -vcodec copy -acodec mp3 -f
mpegts udp://44.0.0.95:1234
ffmpeg version N-72834-gfd004e1 Copyright (c) 2000-2015 the FFmpeg
developers
built with gcc 4.6 (Debian 4.6.3-14+rpi1)
configuration: --enable-libmp3lame
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
Input #0, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 1280x720, 25 fps, 25 tbr,
1200k tbn, 50 tbc
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, alsa, from 'hw:1':
Duration: N/A, start: 1434111432.388990, bitrate: 768 kb/s
Stream #1:0: Audio: pcm_s16le, 48000 Hz, 1 channels, s16, 768 kb/s
Output #0, mpegts, to 'udp://44.0.0.95:1234':
Metadata:
encoder : Lavf56.36.100
Stream #0:0: Video: h264, yuv420p, 1280x720, q=2-31, 25 fps, 25 tbr,
90k tbn, 25 tbc
Stream #0:1: Audio: mp3 (libmp3lame), 48000 Hz, mono, s16p
Metadata:
encoder : Lavc56.41.100 libmp3lame
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
frame=715263 fps= 25 q=-1.0 size=27703638kB time=07:56:50.52
bitrate=7932.3kbits/s
More information about the ffmpeg-user
mailing list