ffplay for radio streams
ffplay for radio streams
Hello all.
This is an off-shoot of FredX's thread here on DogRadio and YRadio
and I did not want to derail his thread.
Given that ffplay is on all modern Puppies, we should give more thought
on using it as a media tool. It would save a good number of Mb's in a
Puppy, if we did not have to include mplayer or mpv in it.
I just found this. The stations do not work anymore, and you have to
align the quotations marks flush to the equal sign in the matrix at the top.
I replaced a couple of those sample radio streams with ones which
I know are still alive, and this person's concept works.
If you have any idea on this subject, or know of scripts, etc., that have
been done with ffplay, please chime in below.
TWYL.
This is an off-shoot of FredX's thread here on DogRadio and YRadio
and I did not want to derail his thread.
Given that ffplay is on all modern Puppies, we should give more thought
on using it as a media tool. It would save a good number of Mb's in a
Puppy, if we did not have to include mplayer or mpv in it.
I just found this. The stations do not work anymore, and you have to
align the quotations marks flush to the equal sign in the matrix at the top.
I replaced a couple of those sample radio streams with ones which
I know are still alive, and this person's concept works.
If you have any idea on this subject, or know of scripts, etc., that have
been done with ffplay, please chime in below.
TWYL.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Here's an early attempt.
You have the radio data file and the ewxcuting script.
The data file:And the script:
And the result (pls see scrot).
BFN.
You have the radio data file and the ewxcuting script.
The data file:
Code: Select all
# Some Internet radio stations that play classical music.
#
# Baroque
STATION["1.FM_-_Otto's_Baroque_Music"]="http://sc17.1.fm:8045"
#
# Two stations for romantic era composers
STATION["AbacusFM Classical"]="http://178.33.232.106:8030/stream"
STATION["Adagio.fm"]="http://lo.adagio.fm:80"
#
# Medieval
STATION["AncientFM"]="http://5.152.208.98:8058"
#
# Various; presentations in Czech.
STATION["CRO-D-dur"]="http://amp.cesnet.cz:8000/cro-d-dur-256.ogg"
#
# Plays the well-known classics
STATION["Venice Classical_Music"]="http://109.123.116.202:8020"
#
# Hard to pinpoint.
STATION["SheetMusicDB.net"]="http://notendatenbank.net:8000/hnChor"
#
# Music from 20th Century composers
STATION["twentysound"]="http://laut.fm/twentysound"
Code: Select all
#!/bin/bash
# Auteur : inconnu. # Source : https://www.ubuntu-user.com/Magazine/Archive/2014/20/Playing-streams-off-the-web-with-FFplay
# Relevé le 3 janv. 2019, à 19 h 55. # Adapté par musher0.
# (c) musher0, 3-4 janv. 2019. GPL3
####
declare -A STATION
[ -f ListingS ] && . ListingS
clear
echo -e "\n\tPlease select an Internet radio station:\n
\tTyping 'Cntl-C' once, exits a stream;
\t\ttwice, quits the script.\n"
select ENTRY in "${!STATION[@]}"; do
URL=${STATION[${ENTRY}]}
echo -e "\t\tPlaying ${URL}\n"
ffplay -nodisp -loglevel info -hide_banner -loop 0 ${URL}
# 2> test2 # pour registre d'erreurs
echo
done
exit
BFN.
- Attachments
-
- ffplay-Iradios.jpg
- (233.16 KiB) Downloaded 403 times
Last edited by musher0 on Fri 04 Jan 2019, 08:26, edited 2 times in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
It comes with a parser for m3u lists.
If you have a few old m3u's lying around and you want to know if the URLs
in them are still valid, AND if ffplay can play them (it can't play all audio
streams, as FredX noted), you can use this:It creates a "ListingS" (sic) data file that the playing
script (see post above) can interpret and play.
No promises, however; this is experimental. Please feel free to adapt it to
your needs.
Have a great day!
If you have a few old m3u's lying around and you want to know if the URLs
in them are still valid, AND if ffplay can play them (it can't play all audio
streams, as FredX noted), you can use this:
Code: Select all
#!/bin/bash
# /mnt/home/Musique/Radios/Listings.sh
# Goal: Create a matrix from a m3u file, that script ffplay-radios.sh can use
#
# (c) musher0, Jan. 3-4 2019. GPL3
####
cd /mnt/home/Musique/Radios
> ListingS
> test # precaution; see below.
while read station;do
if [ "`echo $station | awk -F")" '$1 ~ /EXTINF/'`" ];then
if [ "`echo $station | awk -F")" '$2 !~ /sky.fm/'`" ];then
# Condition concernant un réseau
# The sky.fm network does not exist anymore.
read url
echo "${url}"
[ "${url:0:1}" = "#" ] && OK1=non || OK1=oui
# Excluding music list endings, since ffplay cannot use them.
[ "${url: -3}" = "m3u" ] && OK2=non || OK2=oui
[ "${url: -3}" = "pls" ] && OK3=non || OK3=oui
# echo $OK
if [ "${OK1}" = "oui" -a "${OK2}" = "oui" -a "${OK3}" = "oui" ];then
ffplay -x 300 -y 100 -window_title "${TITLE}" -timeout 2000 -loglevel verbose -hide_banner -loop 0 -i "${url}" 2> /mnt/home/Musique/Radios/test
if [ "`grep -Ev 'close|nvalid|timed|error|Failed' /mnt/home/Musique/Radios/test`" ] # && Test=erreur
# A faulty stream url will have one of those words in the test log.
# Concernant le résultat d'un test du flux. # If the test is good, we create the radio listing.
Name="`echo $station | awk -F")" '{ print $2 }'`"
EndOfN="${#Name}"
Name="${Name:1:$EndOfN}"
Listing="STATION[\"$Name\"]=\"$url\""
# echo "${Listing}"
echo "${Listing}" >> ListingS
sleep 1s
killall -q ffplay
echo
fi
fi
fi
fi
done < Radio.m3u
more ListingS
script (see post above) can interpret and play.
No promises, however; this is experimental. Please feel free to adapt it to
your needs.
Have a great day!
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
pMusic plays radio with ffmpeg - no ffplay required.
- pMusic uses ffplay for visualization
- UPupBB 18.05 hasn't ffplay included
Code: Select all
ffmpeg -i http://lyd.nrk.no/nrk_radio_p2_mp3_h -f s16le -acodec pcm_s16le -ar 44100 -ac 2 - | aplay -f S16_LE -c2 -r44100
- UPupBB 18.05 hasn't ffplay included
Hi zigbert.zigbert wrote:pMusic plays radio with ffmpeg - no ffplay required.- pMusic uses ffplay for visualizationCode: Select all
ffmpeg -i http://lyd.nrk.no/nrk_radio_p2_mp3_h -f s16le -acodec pcm_s16le -ar 44100 -ac 2 - | aplay -f S16_LE -c2 -r44100
- UPupBB 18.05 hasn't ffplay included
Clever discovery.
But why ffplay gone in the BionicPup? It's only about 130 kb.
Sure beats the size of mplayer or mpv.
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
It must be said, I haven't control over ffplay's development the last 2 years, so things might have evolved?musher0 wrote:But why ffplay gone in the BionicPup? It's only about 130 kb.
Sure beats the size of mplayer or mpv.
There has been some attempts over the years to use ffplay. The main issues afaik is that it lacks gui-control (or signal handling for making an external gui) and that it won't embed into browsers. The latter might be less important now when html5 is getting the preferred choice.
I like this idea. I used ffplay in old pAVrecord to allow video to be observed whilst recording (via a pipe to ffplay). That wouldn't work with mplayer because of unwanted pre-buffering issues - ffplay seemed to accept and send out the piped video data without delay. However, I imagined that lack of apparent buffering would make ffplay not good for streaming; though I haven't tried your script I presume I have a mistaken view of ffplay in this case (maybe was more of an issue with old dialup connections?).musher0 wrote:Here's an early attempt [ffplay script].
My only dislike is that your script is GPL. Whilst I myself am retired from programming and have no personal desire to make commercial program releases, I do not like the lack of freedom GNU/GPL licences impose - hence all my own open source programs adopt MIT licences since I am perfectly happy for others to develop my work commercially or otherwise. Indeed I have children who may or may not want to make a livelihood as programmers one day so MIT licences leave that door of opportunity open. Yes, I know, a lot a people on here don't want any software to be able to further developed as any proprietry version, but its nonsense when anyone claims its ever likely for most people to make a livelihood out of GNU software creation. Of course original licensor author can release future proprietry versions but still GPL licences of others restrict what code can be re-used (so GPL-licensed code not properly collaborative outside GPL environment). I guess I should encourage my kids to avoid programming as a career nowadays (or join the Android bandwagon) since we have certainly reduced the Linux-related prgramming livelihood possibilities via GNU-style licensing restrictions. Fine as a hobby though. I'm not sure why so many people in Linux community impose such restrictions on themselves (as if collaboration can't happen in commerce). Anyway it's a small matter compared to the self-imposed restrictions citizens of the UK will have given themselves via BREXIT (good bye at least to European funded research collaborations in that case - e.g. Galileo); won't be many opportunities left in that poor inward-looking country.
EDIT: As for omission of ffplay; yes, its generally just a part of ffmpeg install... It's main binary currently just around 130kB (much smaller indeed than an mpv or mplayer binary) but 'ldd /usr/bin/ffplay' should reveal it also depends on lots of other stuff, including ffmpeg libs such as libavformat etc.
wiak
@zigbert:
Why would a GUI be so important? Linux has a few
competent CLI music players.
@wiak:
1) You have chosen to retire from programming? That is a big loss for this
community...
2) I use GPL3 because it's a known quantity. It may force the hand of some,
or so they may think, but IMO that is a lesser evil than having no GPL-type
license at all.
TWY guys later.
Why would a GUI be so important? Linux has a few
competent CLI music players.
@wiak:
1) You have chosen to retire from programming? That is a big loss for this
community...
2) I use GPL3 because it's a known quantity. It may force the hand of some,
or so they may think, but IMO that is a lesser evil than having no GPL-type
license at all.
TWY guys later.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hi.
The draft of a script formerly presented here has become a full parser
script for pls lists. Please see post below. I apologize for any
inconvenience.
As to the problem I exposed here as well earlier, just make sure your
pls or m3u lists are text files with LF endings only, not WhineDose files.
The small leafpad editor has a quick and easy way to solve that problem
at the bottom right of its save panel.
TWYL.
The draft of a script formerly presented here has become a full parser
script for pls lists. Please see post below. I apologize for any
inconvenience.
As to the problem I exposed here as well earlier, just make sure your
pls or m3u lists are text files with LF endings only, not WhineDose files.
The small leafpad editor has a quick and easy way to solve that problem
at the bottom right of its save panel.
TWYL.
Last edited by musher0 on Sun 06 Jan 2019, 02:09, edited 2 times in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hi.
This is where I'm at.
More later...
BFN.
This is where I'm at.
More later...
BFN.
- Attachments
-
- Not-bad-for-CLI!.jpg
- (199.94 KiB) Downloaded 239 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hello all.
Here is a new, validated (as of this writing), ListingS file. It's
eclectic, covering many musical genres. It does NOT represent my
musical tastes entirely, but it has a slant towards classical and ancient
music (sorry!).
That list is structured to be played by script ffplay-radios.sh above. It
was constructed with the following pls file parser,
and the parser for m3u lists above. Please note that both scripts contain
an actual ffplay test.
If you have old m3u or pls music lists, and you pass them through
these parsers, the resulting list will contain live radios (reservation:
on the day you used the parser).
BFN.
Here is a new, validated (as of this writing), ListingS file. It's
eclectic, covering many musical genres. It does NOT represent my
musical tastes entirely, but it has a slant towards classical and ancient
music (sorry!).
Code: Select all
STATION["1.FM_-_Otto's_Baroque_Music"]="http://sc17.1.fm:8045"
STATION["AbacusFM Classical"]="http://178.33.232.106:8030/stream"
STATION["Adagio.fm"]="http://lo.adagio.fm:80"
STATION["AncientFM"]="http://5.152.208.98:8058"
STATION["BBC Radio 2"]="http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p"
STATION["BBC Radio 3"]="http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio3_mf_p"
STATION["BBC Radio 4"]="http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p"
STATION["CRO-D-dur"]="http://amp.cesnet.cz:8000/cro-d-dur-256.ogg"
STATION["Europe 1"]="http://e1-live-mp3-128.scdn.arkena.com/europe1.mp3"
STATION["France Info"]="http://direct.franceinfo.fr/live/franceinfo-midfi.mp3"
STATION["Hirschmilch Radio Prog-House"]="https://hirschmilch.de:7001/prog-house.mp3"
STATION["Radio 10 "60's & 70's Hits""]="http://17893.live.streamtheworld.com:80/TLPSTR18.mp3"
STATION["Radio Caprice - Mainstream jazz"]="http://79.111.14.76:9085"
STATION["Radio Caprice - Piano Jazz"]="http://79.111.119.111:9059"
STATION["Radio Paradise (320k)"]="http://stream-uk1.radioparadise.com/aac-320"
STATION["RTL2"]="http://streaming.radio.rtl2.fr/rtl2-1-48-192"
STATION["RTL"]="http://streaming.radio.rtl.fr/rtl-1-44-128"
STATION["SheetMusicDB.net"]="http://notendatenbank.net:8000/hnChor"
STATION["twentysound"]="http://laut.fm/twentysound"
STATION["Venice Classical_Music"]="http://109.123.116.202:8020"
was constructed with the following pls file parser,
Code: Select all
#!/bin/bash
# playslist-parser2.sh
#
# Goal: Create a matrix that script ffplay-radios.sh can use
# from an pls list.
#
# © Christian L'Écuyer,Gatineau (Qc), Canada, 4 janv. 2019. GPL3.
# (Alias musher0 [forum Puppy].) Rév. : aucune / none.
####
cd /mnt/home/Musique/Radios
> test
> test-cumul
> ListingS-test
> temporaire.pls
awk -F"=" '$1 ~ /File|Title/' playlist.pls > no-empties.pls
while read url;do
read Name
[ "${Name:0:5}" = "Title" ] && Name="${Name#*=}"
[ "${url:0:4}" = "File" ] && url="${url#*=}"
echo "$Name|$url" >> temporaire.pls
echo "$Name|$url"
done < no-empties.pls
while read line;do
url="";url="${line#*|}"
# Excluding music list endings, since ffplay cannot use them.
if [ "${url: -3}" = "m3u" -o "${url: -3}" = "pls" -o "${url: -3}" = "asx" -o "${url: -3}" = "asf" ];then
echo "on passe (1)"
else
ffplay -x 300 -y 100 -window_title "${TITLE}" -timeout 2000 -loglevel verbose -hide_banner -loop 0 -i "${url}" 2> test
cat test >> test-cumul
if [ "`grep -E 'close|nvalid|timed|error|Failed' test`" ];then
echo "on passe (2)"
# A faulty stream url will have one of those words in the test log.
# Résultat d'un test du flux. # If the test is good, we create the radio listing.
else # si succès / if success
title=""
title="${line%|*}"
Listing="";
Listing="STATION[\"$title\"]=\"$url\""
echo -e "${Listing}" >> ListingS-test
fi
fi
url=""
read
done < temporaire.pls
an actual ffplay test.
If you have old m3u or pls music lists, and you pass them through
these parsers, the resulting list will contain live radios (reservation:
on the day you used the parser).
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)