ffmpeg failing

Moderator: flatmax

Post Reply
Yile
Posts: 7
Joined: Fri Jan 26, 2018 3:29 pm

ffmpeg failing

Post by Yile » Sat Feb 24, 2018 6:48 am

Downloaded the latest NOOBs installed and updated it. Installed the audio injector package and ran the install script. Test worked fine.

I setup the RPI with the audio injector as the receiver and another RPI as the sender that has a different audio card.

Here is the sender:
pi@raspberrypi:~ $ ./ffmpeg -fflags nobuffer -f alsa -i hw:1,0 -acodec libmp3lame -b:a 23k -ac 2 -ar 44100 -f mpegts udp://239.255.0.6:12641?tos=20\&loop=0
ffmpeg version N-90094-ga877d22d9a Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1) 20170516
configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-libmp3lame
libavutil 56. 7.101 / 56. 7.101
libavcodec 58. 11.101 / 58. 11.101
libavformat 58. 9.100 / 58. 9.100
libavdevice 58. 1.100 / 58. 1.100
libavfilter 7. 12.100 / 7. 12.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
Duration: N/A, start: 1519418558.204070, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Finishing stream 0:0 without any data written to it.kbits/s speed=N/A
Output #0, mpegts, to 'udp://239.255.0.6:12641?tos=20&loop=0':
Metadata:
encoder : Lavf58.9.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 23 kb/s
Metadata:
encoder : Lavc58.11.101 libmp3lame
size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Exiting normally, received signal 2.
pi@raspberrypi:~ $ ./ffmpeg -fflags nobuffer -f alsa -i hw:1,0 -acodec libmp3lame -b:a 23k -ac 2 -ar 44100 -f mpegts udp://239.255.0.6:12641?tos=20\&loop=0
ffmpeg version N-90094-ga877d22d9a Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1) 20170516
configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-libmp3lame
libavutil 56. 7.101 / 56. 7.101
libavcodec 58. 11.101 / 58. 11.101
libavformat 58. 9.100 / 58. 9.100
libavdevice 58. 1.100 / 58. 1.100
libavfilter 7. 12.100 / 7. 12.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
Duration: N/A, start: 1519418598.448034, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://239.255.0.6:12641?tos=20&loop=0':eed=N/A
Metadata:
encoder : Lavf58.9.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 23 kb/s
Metadata:
encoder : Lavc58.11.101 libmp3lame
size= 238kB time=00:01:23.41 bitrate= 23.4kbits/s speed=0.33x

Here is the receiver:
pi@raspberrypi:~ $ ./ffmpeg -f mpegts -i udp://239.255.0.6:12641 -f alsa hw:0,0
ffmpeg version N-90094-ga877d22d9a Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1) 20170516
configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-libmp3lame
libavutil 56. 7.101 / 56. 7.101
libavcodec 58. 11.101 / 58. 11.101
libavformat 58. 9.100 / 58. 9.100
libavdevice 58. 1.100 / 58. 1.100
libavfilter 7. 12.100 / 7. 12.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, mpegts, from 'udp://239.255.0.6:12641':
Duration: N/A, start: 4.202022, bitrate: 32 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Audio: mp3 ([3][0][0][0] / 0x0003), 44100 Hz, stereo, s16p, 32 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, alsa, to 'hw:0,0':
Metadata:
encoder : Lavf58.9.100
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc58.11.101 pcm_s16le
[alsa @ 0x1eaaf30] ALSA buffer xrun.
[alsa @ 0x1eaaf30] ALSA write error: Input/output error
av_interleaved_write_frame(): Input/output error
size=N/A time=00:00:03.00 bitrate=N/A speed=0.0977x
video:0kB audio:518kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
pi@raspberrypi:~ $ ./ffmpeg -f mpegts -i udp://239.255.0.6:12641 -f alsa hw:0,0
ffmpeg version N-90094-ga877d22d9a Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1) 20170516
configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-libmp3lame
libavutil 56. 7.101 / 56. 7.101
libavcodec 58. 11.101 / 58. 11.101
libavformat 58. 9.100 / 58. 9.100
libavdevice 58. 1.100 / 58. 1.100
libavfilter 7. 12.100 / 7. 12.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
[mpegts @ 0x2a9d1e0] DTS discontinuity in stream 0: packet 17 with DTS 2830496, packet 18 with DTS 5216084
Input #0, mpegts, from 'udp://239.255.0.6:12641':
Duration: N/A, start: 31.005878, bitrate: 32 kb/s
Program 1
Stream #0:0[0x100]: Audio: mp3 ([3][0][0][0] / 0x0003), 44100 Hz, stereo, s16p, 32 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, alsa, to 'hw:0,0':
Metadata:
encoder : Lavf58.9.100
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc58.11.101 pcm_s16le
[alsa @ 0x2abcf30] ALSA buffer xrun.
[alsa @ 0x2abcf30] ALSA write error: Input/output error
av_interleaved_write_frame(): Input/output error
size=N/A time=00:00:03.00 bitrate=N/A speed=0.0976x
video:0kB audio:518kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!


Do you know why I get the input/output error?

Thanks
Y-

Yile
Posts: 7
Joined: Fri Jan 26, 2018 3:29 pm

Re: ffmpeg failing

Post by Yile » Sat Feb 24, 2018 6:55 am

Okay I ran the setup script and things started working. I am getting periodic glitches in the sound. I get alot of xrun errors:

Press [q] to stop, [?] for help
Output #0, alsa, to 'hw:1,0':
Metadata:
encoder : Lavf58.9.100
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc58.11.101 pcm_s16le
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.23x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.32x
[alsa @ 0x2687270] ALSA buffer xrun.A speed= 1.3x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.29x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.27x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.26x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.24x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.23x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.22x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.21x
[alsa @ 0x2687270] ALSA buffer xrun.A speed= 1.2x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.19x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.18x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.17x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.16x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.15x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.21x
[alsa @ 0x2687270] ALSA buffer xrun.A speed= 1.2x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.19x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.18x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.18x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.17x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.16x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.15x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.15x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.14x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.13x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.13x
[alsa @ 0x2687270] ALSA buffer xrun.A speed=1.12x
size=N/A time=00:00:55.72 bitrate=N/A speed=1.11x
video:0kB audio:7718kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.


[1]+ ./ffmpeg -fflags nobuffer -f alsa -i hw:0,0 -acodec libmp3lame -b:a 23k -ar 44100 -f mpegts udp://239.255.0.8:12841 &
./ffmpeg -fflags nobuffer -f alsa -i hw:0,0 -acodec libmp3lame -b:a 23k -ar 44100 -f mpegts udp://239.255.0.8:12841 size= 0kB time=-577014:32:22.77 bitrate= ^Cze= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A kbits/s speed=N/A
gmpesize= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A s speed=N/A
pi 1115 96.9 0.6 27772 5872 pts/3 R 20:52 0:10 ./ffmpeg -fflags nobuffer -f alsa -i hw:0,0 -acodec libmp3lame -b:a 23k -ar 44100 -f mpegts udp://239.255.0.8:12841
pi 1117 0.0 0.0 4372 540 pts/3 S+ 20:52 0:00 grep --color=auto ffmpeg
k[alsa @ 0x1dff260] ALSA buffer xrun. bitrate= -0.0kbits/s speed=N/A its/s speed=N/A
156size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
kill: (11156): No such process
15size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A speed=N/A
Output #0, mpegts, to 'udp://239.255.0.8:12841':
Metadata:
encoder : Lavf58.9.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 23 kb/s
Metadata:
encoder : Lavc58.11.101 libmp3lame
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 3.3kbits/s speed=0.915x /s speed=0.931x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 10.8kbits/s speed=0.939x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 15.0kbits/s speed=0.953x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 17.5kbits/s speed=0.961x
^Cze= 191kB time=00:01:22.83 bitrate= 18.9kbits/s speed=0.973x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 19.3kbits/s speed=0.967x /s speed=0.972x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 20.6kbits/s speed=0.972x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 21.5kbits/s speed=0.975x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 22.3kbits/s speed=0.977x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 22.9kbits/s speed=0.979x
[alsa @ 0x1dff260] ALSA buffer xrun.rate= 23.5kbits/s speed=0.981x
size= 467kB time=00:02:41.76 bitrate= 23.6kbits/s speed=0.988x

Anything I can do to fix the xrun issue?
THanks,
Y-

Yile
Posts: 7
Joined: Fri Jan 26, 2018 3:29 pm

Re: ffmpeg failing

Post by Yile » Sun Feb 25, 2018 3:42 am

Just a note, I notice that ffmpeg takes 100% of one of the processor cores on the RPI 3.
I assume that is to be expected... using a Sabrent USB card with this same ffmpeg, I get about 36% utilization.

Y-

alejandro
Posts: 5
Joined: Sun Feb 18, 2018 7:28 am

Re: ffmpeg failing

Post by alejandro » Thu Apr 19, 2018 10:52 pm

Hi! same issue here, I test compile FFMPEG manually with optimization and same issue always, second test with Darkice and the same problem.

Using other USB devices works perfect... but with AudioInjector always got Bufferunderrun.

Some advice? @flatmax?

alejandro
Posts: 5
Joined: Sun Feb 18, 2018 7:28 am

Re: ffmpeg failing

Post by alejandro » Mon Apr 30, 2018 1:32 am

HI! same problem here... you found some workarround to made this works better?

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: ffmpeg failing

Post by flatmax » Tue May 08, 2018 8:11 pm

Hi there,

It is possible that the buffer being used is too small. It is likely that with USB there is some buffering provided for you.

While ffmpeg is executing can you probe the buffer size it is using ?

For example :
cat /proc/asound/card0/pcm0p/sub0/hw_params

Here is documentation on how to probe /proc/asound to find this information :
https://alsa.opensrc.org/Proc_asound_documentation

Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

alejandro
Posts: 5
Joined: Sun Feb 18, 2018 7:28 am

Re: ffmpeg failing

Post by alejandro » Mon Jun 18, 2018 1:35 pm

Hi @flatmax

Thanks for the response here the information requested:

root@raspberrypi3-2335cd4:/usr/src/app# cat /proc/asound/card0/pcm0p/sub0/hw_params

Code: Select all

access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 5513
buffer_size: 22052
let me know if you recommend increase the buffer_size?

Regards,
Alejandro

RoEdAl
Posts: 2
Joined: Wed Jun 06, 2018 6:40 pm

Re: ffmpeg failing

Post by RoEdAl » Mon Jun 18, 2018 8:07 pm

As a workaround you can use arecord/aplay and ffmpeg.

Record:

Code: Select all

arecord -q -N -M -t raw -D hw:audioinjectorpi -c 2 -r 48000 -f S16_LE|ffmpeg -f s16le -ac 2 -ar 48000 -i - -acodec libmp3lame -b:a 23k -f mpegts udp://239.255.0.6:12641
Play:

Code: Select all

ffmpeg -f mpegts -i udp://239.255.0.6:12641 -f s16le -| aplay -q -N -M -t raw -D  hw:audioinjectorpi -c 2 -r 48000 -f S16_LE
See: Issue with FFMPEG ALSA CPU usage.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests