Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ffmpeg - How to call AAC audio streaming functionality via ssh

I have a USB audio dongle connected to the USB port on the QNAP NAS. I have on the NAS a script called "radio" that streams me internet radio streams via a USB audio dongle to the soundbar. The whole thing is controlled by Raspberry Pi (with the Domoticz home automation system). I mean RPi sends ssh commands to the NAS to run the script "radio" on the NAS. Everything works fine as long as it's an HTTP MP3 stream. I use mpg123 then, that is convertion MP3 to WAV. For AAC stream, I have to use FFMPEG to convert AAC to WAV, needed for aplay. Unfortunately, the number of commands available on the NAS is very limited and I can only use FFMPEG and APLAY. If I run the "radio" script directly (from the console) on the NAS, everything works fine. However, when I run it remotely from RPi, MP3 streams play correctly but AAC does not. Below is the command I am using in "radio" script on NAS at the moment (after many attempts). When I run it from the NAS console, everything works fine. However, when I run it remotely using SSH with RPi, both FFMPEG and APLAY are launched but nothing is played on the NAS.

....
[ ! -e /dev/shm/pipe ] && $path_bin/mkfifo /dev/shm/pipe
....
ffmpeg -y -i "$url" -vn -acodec pcm_s16le -ar 44100 -f wav /dev/shm/pipe & $path_bin/aplay -D   sysdefault:Device --file-type raw --format=cd /dev/shm/pipe
....

If I run "radio" script from NAS console, FFMPEG start to display kind of counter of received/transcoded kbits. When I call it remotely, counter does not start on RPi console. Probably FFMPEG works, but does not transcode stream. Any idea what to do for proper run radio streaming?

EDIT-1 stderr output:

ffmpeg version 3.3.6 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-cross-compile --arch=i686 --target-os=linux --disable-yasm --disable-static --enable-shared --enable-gpl --enable-libmp3lame --disable-libx264 --enable-libsoxr --enable-version3 --enable-nonfree --enable-openssl --disable-decoder=ac3 --disable-decoder=ac3_fixed --disable-decoder=eac3 --disable-decoder=dca --disable-decoder=truehd --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-encoder=dca --disable-decoder=hevc --disable-decoder=hevc_cuvid --disable-encoder=hevc_nvenc --disable-encoder=nvenc_hevc --disable-decoder=h264 --disable-decoder=h264_cuvid --disable-encoder=libx264 --disable-encoder=libx264rgb --disable-encoder=h264_nvenc --disable-encoder=nvenc --disable-encoder=nvenc_h264 --disable-decoder=mpeg2video --disable-decoder=mpegvideo --disable-decoder=mpeg2_cuvid --disable-encoder=mpeg2video --disable-decoder=mpeg4 --disable-decoder=mpeg4_cuvid --disable-decoder=msmpeg4v1 --disable-decoder=msmpeg4v2 --disable-decoder=msmpeg4v3 --disable-encoder=mpeg4 --disable-encoder=msmpeg4v2 --disable-encoder=msmpeg4v3 --disable-decoder=mvc1 --disable-decoder=vc1 --disable-decoder=vc1_cuvid --disable-decoder=vc1image --disable-decoder=aac --disable-decoder=aac_fixed --disable-decoder=aac_latm --disable-encoder=aac --extra-ldflags='-L/root/daily_build/64_41/4.5.1/LinkFS/usr/lib -L/root/daily_build/64_41/4.5.1/Model/TS-X72/build/RootFS/usr/local/medialibrary/lib -Wl,--rpath -Wl,/usr/local/medialibrary/lib' --extra-cflags='-I/root/daily_build/64_41/4.5.1/LinkFS/usr/include -I/root/daily_build/64_41/4.5.1/Model/TS-X72/build/RootFS/usr/local/medialibrary/include -D_GNU_SOURCE -DQNAP' --prefix=/root/daily_build/64_41/4.5.1/Model/TS-X72/build/RootFS/usr/local/medialibrary
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
question from:https://stackoverflow.com/questions/65889945/how-to-call-aac-audio-streaming-functionality-via-ssh

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally I found a workaround. It's not an "elegant" solution - but it works. I used the "expect" functionality and created a script on RPi that triggers SSH streaming to the NAS. Script content below.

#!/usr/bin/expect -f
set channel [lindex $argv 0]
set timeout 5
spawn /usr/bin/ssh -p669 -x -q -i /home/debian/.ssh/id_debian [email protected] 
expect "*# "
send -- "/share/homes/media/Pobrane/RADIO/radio $channel
"
expect "*# "
send -- "exit
"
expect eof

Thats all.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...