LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-10-2022, 08:57 AM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,970

Rep: Reputation: 271Reputation: 271Reputation: 271
Capturing audio streams


I capture audio streams with streamripper. It doesn't work on some streams, perhaps because it is 7 years old. Is there a more up-to-date program for this? Preferably one in a Slackware package, but streamripper isn't so I can build.
 
Old 06-10-2022, 01:09 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,140
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
ffmpeg, mplayer, mpv, curl, wget, python urllib, gstreamer, a web browsers engine, will all capture media streams.

The bigger issue is usually finding the source of the stream. You'll need to learn about web scraping. Or just use the web inspector from your web browser.

If you want more info, then give more info on what you are doing. Are the urls plain in the web pages source? Then you can get them with curl.

Or do scripts on the page have to run to generate virtual links to the media? Then you will need something that will execute those scripts.

Are these streams mp3 files, or HLS segmented playlists, or dash segmented playlists? You'll have to get them a segment at a time and put them together. ffmpeg is great for that. So is curl.

Then there is youtube-dl, yt-dlp. Excellent bits of python.
Code:
yt-dlp --list-extractors
Even if the site isn't listed in the extractor list; If you can scrape the .m3u8 file from the page source, yt-dlp/youtube-dl will often times be able to get the segments from the playlist and use ffmpeg to put them all together.
 
Old 06-10-2022, 01:44 PM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,140
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
Start with something simple

https://www.pbs.org/video/hawking-full-episode/

The master playlist
Code:
pl="https://ga.video.cdn.pbs.org/videos/hawking/c41f6c7b-1884-42a9-\
a548-afa99063ad63/116618/hd-mezzanine-16x9/hakn0000_90min_mezz16x9-\
16x9-hls-64-2500k_104.m3u8"
Look at that playlist.
Code:
curl "$pl"
You see that there are 5 streams of different sizes and a captions stream.

Look at the 1200k stream playlist.
Code:
pl2="https://ga.video.cdn.pbs.org/videos/hawking/c41f6c7b-1884-42a9-\
a548-afa99063ad63/116618/hd-mezzanine-16x9/hakn0000_90min_mezz16x9-16x9-\
hls-1200k.m3u8"

curl "$pl2"
Those are the transport stream segments. There are 513 of them.

You could download that with curl if you wanted to.
Code:
agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0"

curl -A "$agent" https://ga.video.cdn.pbs.org/videos/hawking/c41f6c7b-\
1884-42a9-a548-afa99063ad63/116618/hd-mezzanine-16x9/hakn0000_90min_me\
zz16x9-16x9-hls-1200k-[00000-00513].ts -o - >> Hocking.ts
You could also use ffmpeg on that .m3u8 playlist
Code:
ffmpeg -i "$pl2" -c:a copy -c:v copy Hocking.mp4
yt-dlp will also get that, once you have the playlist.
Code:
yt-dlp -F "$pl2"
HLS segmented video/audio streams are downloadable to file using simple tools. It's not the special tool that you need. It is the knowledge of how it works.
 
2 members found this post helpful.
Old 06-10-2022, 08:44 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by teckk View Post
Start with something simple
If I live to be a hundred, this will all remain beyond my ken ...
 
Old 06-11-2022, 12:43 AM   #5
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,970

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
You all tell me how to download files, not capture streams. I may have the term wrong, but stream means a continuous, infinite, stream of data to me. Before I discovered streamripper I used mplayer, which requires me to schedule a separate task to stop the stream. I do this unattended, scheduled with crontab, on remote computers. streamripper allows me to set a duration, after which it will quit.
 
Old 06-11-2022, 01:06 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by RandomTroll View Post
You all tell me how to download files, not capture streams. I may have the term wrong, but stream means a continuous, infinite, stream of data to me. Before I discovered streamripper I used mplayer, which requires me to schedule a separate task to stop the stream. I do this unattended, scheduled with crontab, on remote computers. streamripper allows me to set a duration, after which it will quit.
Well, by "capture" you mean downloading it to disk, no?
The process isn't different for (potentially endless) streams.
You just tell curl or wget or ffmpeg to stop after some time.
 
Old 06-11-2022, 06:49 AM   #7
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,140
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
Quote:
You all tell me how to download files, not capture streams.
No, I told you how to capture HLS streams. Which is what the majority of html5 audio/video are. Doesn't matter if you are playing a remote mp3 or a hls stream, the data stream still comes to your computer, 1 bit at a time.

These things are exactly the same. You use the same about of bandwidth. With the same results. You get to see the video.

A live stream on utube.
Watch mplayer spit out the segements
Code:
mplayer $(yt-dlp -f 94 https://m.youtube.com/watch?v=86YLFOog4GM)
mplayer dump it to file
Code:
yt-dlp -f 94 https://m.youtube.com/watch?v=86YLFOog4GM -o - | mplayer -dumpstream -dumpfile myfile.ts -
ffmpeg is better at it.
Code:
yt-dlp -f 94 https://m.youtube.com/watch?v=86YLFOog4GM -o - | ffplay -
mpv will play it
Code:
mpv https://m.youtube.com/watch?v=86YLFOog4GM
And dump it
Code:
mpv --record-file=myfile.ts https://m.youtube.com/watch?v=86YLFOog4GM
Using a named pipe
Code:
mkfifo pipe

#In one terminal
yt-dlp -f 94 https://m.youtube.com/watch?v=86YLFOog4GM -o pipe

#In second terminal
ffplay pipe
#Get the playlist, do something with it.
Code:
url=$(yt-dlp -f 94 -g https://m.youtube.com/watch?v=86YLFOog4GM)

ffprobe "$url"
These are basic tools that play/dump whatever video/audio stream you wish. Or, if you want to use something else, go ahead.

Quote:
It doesn't work on some streams, perhaps because it is 7 years old
You still haven't given an example.
 
1 members found this post helpful.
Old 06-12-2022, 12:26 AM   #8
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,970

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by ondoho View Post
Well, by "capture" you mean downloading it to disk, no?
no.

Quote:
Originally Posted by ondoho View Post
The process isn't different for (potentially endless) streams.
You just tell curl or wget or ffmpeg to stop after some time.
That takes a separate task, which, since I do it unattended, requires separate scheduling. Secondly streamripper continues to try to capture a stream for the duration of its assignment. Sometimes there's a glitch in the stream or the connection; streamripper doesn't quit until the time is up.

Quote:
Originally Posted by teckk View Post
No, I told you how to capture HLS streams.
HLS?

Quote:
Originally Posted by teckk View Post
Which is what the majority of html5 audio/video are
I'm not trying to capture the majority.

Quote:
Originally Posted by teckk View Post
A live stream on utube.
Watch mplayer spit out the segements
All of your examples are of fetching finite files which are available in full at the initiation of the download.

Quote:
Originally Posted by teckk View Post
You still haven't given an example.
https://audio.wbhm.org/live.mp3 - I don't see what difference it makes. mplayer will play it or dump the stream to a file (as will curl or wget or whatever), streamripper won't.

I already knew how to do all the things you-all have suggested. streamripper offers features that I want. It's 7 years old. Perhaps someone has written a similar app more recently.
 
Old 06-12-2022, 12:57 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by RandomTroll View Post
https://audio.wbhm.org/live.mp3 - I don't see what difference it makes. mplayer will play it or dump the stream to a file (as will curl or wget or whatever), streamripper won't.
And mpv can do both at the same time.

Quote:
I already knew how to do all the things you-all have suggested. streamripper offers features that I want. It's 7 years old. Perhaps someone has written a similar app more recently.
So is this all your question is about? Recommendation for apps that can play live streams, and have certain (as yet undisclosed) "features"?
But your question asked about "capturing" them, and I still don't understand what you mean by that, if it's something else than playing and/or downloading them.
We've shown you that a lot of software can do that.
But you say you know all that already.
So what is capturing, and what does streamripper do that these softwares don't?

Once again you are asking an extremely vague question, then abuse LQ to help you clarify your own thoughts.

Last edited by ondoho; 06-12-2022 at 12:59 AM.
 
Old 06-12-2022, 08:34 AM   #10
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,140
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
Quote:
All of your examples are of fetching finite files which are available in full at the initiation of the download.
No they aren't That utube stream of the space station is a stream. Did you even bother to look at it?

Your example:
Code:
agent="Mozilla/5.0 (iPhone; CPU iPhone OS 15_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/78.0.257670029 Mobile/19A348 Safari/604.1"

curl -LA "$agent" https://audio.wbhm.org/live.mp3 -o live.mp3

#Ctrl+C

ffprobe live.mp3
...
[mp3 @ 0x55dfabef9ec0] Skipping 392 bytes of junk at 0.
[mp3 @ 0x55dfabef9ec0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'live.mp3':
  Duration: 00:00:10.98, start: 0.000000, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
If that streams 24 hours a day, I could wake the machine up at 2am, catch an hour, go back to sleep. Start 2 min early, stop 2 min late. Just to make sure you got everything, allow for clock difference. You can always trim it later with ffmpeg.
Code:
#!/usr/bin/bash

#Wake, record audio stream, return to sleep. Needs rtcwake, curl

agent="Mozilla/5.0 (iPhone; CPU iPhone OS 15_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/78.0.257670029 Mobile/19A348 Safari/604.1"

#Place to keep the recording
cd $HOME/somewhere

#Set wake date/time here, go to sleep
sudo rtcwake -m mem --date "2022-06-13 01:58:00"

#Allow everything to wake up
sleep 10

#Set recording time here
runtime=3720

#Get it 
curl -LA "$agent" https://audio.wbhm.org/live.mp3 -o live.mp3 &

#Recording time
sleep "$runtime"

#Kill record
pkill curl

#Return to sleep
sudo systemctl suspend
And...you could stop curl more gracefully than the sledgehammer approach I used.

Edit:
https://0x0.st/oMC6.png

Edit2:
Forgot to background curl doing it's thing.

Last edited by teckk; 06-12-2022 at 09:00 AM.
 
Old 06-12-2022, 12:42 PM   #11
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
The method of teckk with pipe/youtube "yt-dlp -f" didn't work at all on my PC (opensuse).

To capture and view video and audio (TV, youtube,..), I use fltvstream. It works very fine.
https://gitlab.com/openbsd98324/fltvstream

For that I had to look around. zypper install fltk to compile it.

I have no clue however how to use it to move that webm file to my phone.


??
Quote:
Quote:
Originally Posted by ondoho View Post
Well, by "capture" you mean downloading it to disk, no?
no.

Last edited by Xeratul; 06-12-2022 at 12:56 PM.
 
Old 06-12-2022, 01:06 PM   #12
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,140
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
Quote:
I have no clue however how to use it to move that webm file to my phone
What kind of phone? If it's an android then look at the different mtp transfer programs.

Will your phone play a .webm file?
Answered you here.
https://www.linuxquestions.org/quest...p3-4175713320/
 
Old 06-12-2022, 01:09 PM   #13
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by teckk View Post
What kind of phone? If it's an android then look at the different mtp transfer programs.

Will your phone play a .webm file?
Answered you here.
https://www.linuxquestions.org/quest...p3-4175713320/
it is the nokia banana 8000 series.

For now, I can play mp3 on it in the car. I plug the 3.5mm jack on it.

Ideally, I would a pi zero and play music in the car over the 3.5mm jack, but no idea how to do that. eventually add a TFT Joy it on the pi zero w.
 
Old 06-12-2022, 11:20 PM   #14
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Please do not hijack other people's threads with unrelated wuestions. You already opened a thread about it yesterday, why don't you continue the discussion there.

Quote:
Originally Posted by Xeratul View Post
it is the nokia banana 8000 series.

For now, I can play mp3 on it in the car. I plug the 3.5mm jack on it.

Ideally, I would a pi zero and play music in the car over the 3.5mm jack, but no idea how to do that. eventually add a TFT Joy it on the pi zero w.
 
Old 06-12-2022, 11:39 PM   #15
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,970

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by teckk View Post
...
That was simple.
Code:
streamripper https://audio.wbhm.org/live.mp3 -a live.mp3 -l 3600
captures an hour, requires no separate process to terminate, continues to try to capture the stream - or would, if it worked on wbhm - for the entire hour - even if the stream or the connection fails temporarily.

The downloading apps' model reads an end to the data as an EOF.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Software audio mixing (simultaneous audio streams) in Slackware? malloc Slackware 19 05-11-2011 09:25 PM
Capturing multiple video streams ralfbutler Linux - Software 0 01-23-2010 02:50 PM
Capturing video with Cinelerra works, capturing video with Xawtv doesn't! seaelf Slackware 0 06-27-2004 05:18 PM
Capturing Realplayer Streams (rtsp) Help gbrad Linux - Software 1 04-07-2003 08:35 PM
Capturing Video Streams Under Linux LinuxGeek Linux - Software 3 06-24-2002 01:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration