LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-13-2019, 01:50 AM   #1
drudox
Member
 
Registered: Feb 2016
Posts: 131

Rep: Reputation: Disabled
extract audio from streaming


Hi everybody !
I would just know which is the easiest way to record part of audio from a streaming's film that is free in the channel site (Rai italy)

thanks in advance

Last edited by drudox; 02-13-2019 at 03:04 AM.
 
Old 02-13-2019, 06:23 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,044
Blog Entries: 7

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
the easiest way is to simply download the stream and post-process it to extract audio only.
have you tried if you can do this with youtube-dl?
 
1 members found this post helpful.
Old 02-13-2019, 06:27 AM   #3
drudox
Member
 
Registered: Feb 2016
Posts: 131

Original Poster
Rep: Reputation: Disabled
no I didn't but audacity look works well capturing the audio trace, there is no such a tool from command line ?
 
Old 02-13-2019, 06:35 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,044
Blog Entries: 7

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
youtube-dl is a cli tool.

it would help to give an example of what you are trying to capture. a link.

and why not stick with audacity if it works for you.
 
1 members found this post helpful.
Old 02-13-2019, 07:22 AM   #5
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: VirtualBox win 10 guest | OpenBSD 6.3 bridge | Fedora 29 | windows 10 pro 64bit
Posts: 384

Rep: Reputation: 159Reputation: 159
i have used Streamripper to rip audio streams (IIRC i were using vlc to listen music and ripped it with Streamripper)

Quote:
[root@localhost vile]# dnf search streamripper
Last metadata expiration check: 0:14:24 ago on Wed 13 Feb 2019 03:07:28 PM EET.
========================================================= Name Exactly Matched: streamripper ==========================================================
streamripper.x86_64 : Shoutcast and icecast compatible streams recorder
[root@localhost vile]#
EDIT: it would help if you would post what u are trying to rip.
EDIT2: i missed that you were looking for commandline program, steamripper is _NOT_ commandline.

Last edited by //////; 02-13-2019 at 07:41 AM.
 
Old 02-14-2019, 02:16 PM   #6
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,061

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
there is no such a tool from command line ?
Let me find a free video that says it's free.....google-ing
Ok
"This video has been licensed to ShareTV for distribution purposes"

Example:
https://sharetv.com/shows/days_of_our_lives

Days of our Lives
Season 54, Episode #99 - S54 E99 Tuesday, February 12, 2019
https://sharetv.com/watch/1465778

Get the video, part that you desire.
Code:
#user agent
agent="Mozilla/5.0 (Windows NT 10.0; WOW_64; rv:64.0) Gecko/20100101 Firefox/64.0"

#Get segments 30-35 for this example
curl -A "$agent" https://nbchls-prod.nbcuni.com/tve-adstitch/647/19/02/08/3904302/F2AA39F23B6EF83F2DC2A9358F53F95DFC2073A6F67FB-[30-35].ts -o - >> DaysLives.ts
Check the video
Code:
ffprobe ~/DaysLives.ts
....
Input #0, mpegts, from '~/DaysLives.ts':
  Duration: 00:00:54.05, start: 262.694000, bitrate: 1619 kb/s
  Program 1 
    Stream #0:0[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 74 kb/s
    Stream #0:1[0x102]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 960x540, Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Run it through ffmpeg to make a .mp4
Code:
ffmpeg -i DaysLives.ts -c:a copy -c:v copy DaysLives.mp4
Drop the video, keep just the audio
Code:
ffmpeg -i DaysLives.ts -vn -c:a copy DaysLives.m4a

Last edited by teckk; 02-14-2019 at 02:17 PM.
 
1 members found this post helpful.
Old 02-16-2019, 06:07 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,044
Blog Entries: 7

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
^ with youtube-dl it's just one command:
Code:
youtube-dl -x https://sharetv.com/watch/1465778
 
Old 02-16-2019, 12:53 PM   #8
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,061

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
You are absolutely right @ondoho. I forget about youtube-dl away from youtube.
That works just fine after the video urls are dug out. And the formats available
are found. I've got so use to finding the .m3u8 for html5 videos and using curl
to concatenate segments to file. Thanks.

Code:
list=(
http://www.shoutfactorytv.com/dennis-the-menace/.......
http://www.shoutfactorytv.com/dennis-the-menace/.......
http://www.shoutfactorytv.com/dennis-the-menace/.......
)

agent="Mozilla/5.0 (Windows NT 10.0; WOW_64; rv:64.0) Gecko/20100101 Firefox/64.0"

num=1
for i in "${list[@]}"; do
    youtube-dl --user-agent "$agent" -f hls-1008 "$i" -o Dennis_"$num".mp4
    sleep 30
    num=$(($num + 1))
done
Footer:
Stop and click on a few ads on those pages so the website owner will
get some ad revenue. If you appreciate what they are doing and want
them to stay in business. The more ads you click on the better.

Sorry, I have a hard time feeling sorry for google if all the ads
don't get viewed for a youtube video. They have ads from one end
of the internet to the other. So does amazon.
 
Old 02-16-2019, 04:10 PM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,044
Blog Entries: 7

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
Quote:
Originally Posted by teckk View Post
Code:
list=(
http://www.shoutfactorytv.com/dennis-the-menace/.......
http://www.shoutfactorytv.com/dennis-the-menace/.......
http://www.shoutfactorytv.com/dennis-the-menace/.......
)

agent="Mozilla/5.0 (Windows NT 10.0; WOW_64; rv:64.0) Gecko/20100101 Firefox/64.0"

num=1
for i in "${list[@]}"; do
    youtube-dl --user-agent "$agent" -f hls-1008 "$i" -o Dennis_"$num".mp4
    sleep 30
    num=$(($num + 1))
done
it must be a long time since you looked at youtube-dl's man page:
what you did up there, you don't need a script for:
  • it can take more than one URL on the command line
  • it defaults to downloading the highest possible quality anyhow
  • it has extensive formatting options for the output files
 
Old 02-17-2019, 08:30 AM   #10
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,061

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
You are right again. I hadn't been using youtube-dl for anything other
that an occasional utube vid. And had not read man youtube-dl
for a good while.
Code:
-a, --batch-file FILE
--autonumber-start NUMBER
That is nifty for the web sites that it will work with.
Thanks again.

This gave me the segment playlist so that one could select which
segments to get if you want a partial video.
Code:
curl $(youtube-dl -g <url>)
I could then list the desired segments in a batch file and use the
-a switch. I think that you could also use regex.

The OP said "streaming's film" and "record part of audio"

Another way to get that audio would be to dump what's
coming through your sound card to file. Make a audio loopback device.
Look at modprobe snd-aloop, modifying your ~/.asoundrc
then dump the audio to file when you want.
Example:
Code:
ffmpeg -f alsa -i hw:1,1 -c:a aac -b:a 32k -vn capture.m4a
 
Old 02-17-2019, 10:48 AM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,044
Blog Entries: 7

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
thank you for recognizing the awesomeness of youtube-dl.
just one more comment from me: they are running the neverending race against media website maintainers always changing their sites to push us hackers out.
updates come in almost daily on their github repo.
it is one of the few applications i recommend to use a git version of, over anything that's in your repos.

Quote:
Originally Posted by teckk View Post
Another way to get that audio would be to dump what's
coming through your sound card to file. Make a audio loopback device.
Look at modprobe snd-aloop, modifying your ~/.asoundrc
did you ever get that to work?
to me alsa is like a book with seven seals.
 
Old 02-17-2019, 11:43 AM   #12
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,061

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
did you ever get that to work?
Yes.

I turned on an older machine that I have, and it has one of
those sound devices that is hardware broken on purpose so that
you can't capture the stream through it. I think that a lot
of sound devices are like that.

This is an arch linux box with a nvidia chip for everything.

Code:
lspci | grep 'Audio'
00:05.0 Audio device: NVIDIA Corporation MCP61 High Definition Audio (rev a2)
So the answer is a virtual loopback device.

First make a config file for alsa.

~/.loop_asoundrc
Code:
pcm.!default {
  type asym
  playback.pcm "LoopAndReal"
  #capture.pcm "looprec"
  capture.pcm "hw:0,0"
}

pcm.looprec {
    type hw
    card "Loopback"
    device 1
    subdevice 0
}


pcm.LoopAndReal {
  type plug
  slave.pcm mdev
  route_policy "duplicate"
}


pcm.mdev {
  type multi
  slaves.a.pcm pcm.MixReale
  slaves.a.channels 2
  slaves.b.pcm pcm.MixLoopback
  slaves.b.channels 2
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
}


pcm.MixReale {
  type dmix
  ipc_key 1024
  slave {
    pcm "hw:0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}

pcm.MixLoopback {
  type dmix
  ipc_key 1025
  slave {
    pcm "hw:Loopback,0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}
Then when I want to use it I simply copy that file to the right
place and modprobe snd-loop module.
Code:
mv ~/.loop_asoundrc ~/.asoundrc && sudo modprobe snd-aloop
Then capture what I want, to output format I want.
Code:
ffmpeg -f alsa -i hw:1,1 -c:a libmp3lame -b:a 32k -vn capture.mp3
Then when done
Code:
mv ~/.asoundrc ~/.loop_asoundrc && sudo modprobe -r snd-aloop
You need to start ffmpeg grabbing before you start the sound stream or no
capture.

And yes, I just checked all of that, it still works fine.

It's not the best way to get audio, to reencode something that has already
been encoded.

If you want you can
Code:
ffmpeg -f alsa -i hw:1,1 -c:a pcm_s16le capture.wav
Code:
mplayer capture.wav
.....
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
Anyway, if all else fails, you can capture the stream going through
your sound device.
 
1 members found this post helpful.
Old 02-18-2019, 01:05 AM   #13
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,044
Blog Entries: 7

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
Thanks a lot for this understandable explanation!
I'll make sure to bookmark it for future reference.

But while it is like that, you cannot listen to the sound, correct?
 
Old 02-18-2019, 06:11 AM   #14
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,061

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Yes, you can listen while you are recording. You have to start ffmpeg capturing
before starting the sound stream though, or you get a blank file.

To the OP:
Web browsers cache video in their cache directory. You can look for it there and
then dump the audio from it. For a segmented video it looks like Palemoon dumps
the segments in it's cache, look somewhere like:
Code:
~/.cache/moonchild productions/pale moon/123456.default/cache/entries/
Firefox does the same. Which means there is a plugin that will get the video
out of it's cache.

Any browser or python script using PyQt4-5, WebEngine, WebKit cache them too.
Code:
ffprobe ~/.cache/insp/Cache/f_0000c6
....
Input #0, mpegts, from '~/.cache/insp/Cache/f_0000c6':
  Duration: 00:00:11.33, start: 11.275433, bitrate: 1119 kb/s
Quote:
I would just know which is the easiest way
Which ever way listed in this thread that you like.
And then there is python with it's acres of modules for it.
mplayer and mpv will both dump streams to file with -dumpstream
and --stream-dump=. ffmpeg will dump a stream to file with -c:copy
youtube-dl dumps to file. curl supports regex in a url so that you
can continue to dump segments to file with the same connection. With wget
you will have to loop on the segments to get them all. mplayer supports playlists
with -playlist, you can combine that with -dumpstream -dumpfile.
Web browsers have plugins to get the video out of it's cache.
Or if you don't like any of that, dump the stream coming through the sound
card to file.

Happy dumping.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] video streaming support with VLC(?) as the streaming server wachi Linux - Embedded & Single-board computer 3 03-28-2011 12:35 PM
Darwin streaming server Video streaming local only ahmed_as8 Linux - Networking 2 05-28-2009 02:52 PM
Streaming movies not streaming... shame SUSE / openSUSE 2 04-12-2007 07:16 AM
audio cd works - mp3's, streaming audio, flash sound don't spoody_goon Linux - Software 7 07-08-2006 03:11 PM
streaming audio from audio-in Murdock1979 Linux - Software 0 06-09-2006 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:27 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration