How to extract audio streams from a video file?

Questions about codecs, DVD playback, web plugins...
Forum rules
Before you post please read how to get help
ChrisHvide
Level 1
Level 1
Posts: 10
Joined: Tue Aug 29, 2017 8:08 pm

How to extract audio streams from a video file?

Postby ChrisHvide » Wed Nov 01, 2017 12:34 pm

Hi there. So in a video file, you usually have one audio stream for vocals and one for background music and sound effects.
I would like to extract them from the video file to separate audio files.
Is there an easy way to do this? Preferably without using command line if there are GUI options.

Hoser Rob
Level 9
Level 9
Posts: 2825
Joined: Sat Dec 15, 2012 8:57 am

Re: How to extract audio streams from a video file?

Postby Hoser Rob » Wed Nov 01, 2017 1:34 pm

ChrisHvide wrote:... in a video file, you usually have one audio stream for vocals and one for background music and sound effects. ....


I don't know where you got that from. It's kind of true with 5.1 audio but not really ... you can't assume all dialogue will be in the center channel ... and not true at all for stereo.

However it's not hard to yank the audio stream. Sound Converter will do it for stereo but not multichanne and Audacity will handle just about any audio task. They're both audio processors but if you open a video file with either they'll yank the audio tracks no problem.

I've used Audacity to downmix 5.1 to 2 channel. Sound converter just transcodes but it's much easier to use.

User avatar
jimallyn
Level 16
Level 16
Posts: 6687
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: How to extract audio streams from a video file?

Postby jimallyn » Wed Nov 01, 2017 1:40 pm

I believe you can open a lot of video formats with Audacity to extract the audio from them. Other applications you might try are Sound Converter, WinFF, and FF Multi Converter.

I have to agree with Hoser Rob that most videos don't come that way.
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

ChrisHvide
Level 1
Level 1
Posts: 10
Joined: Tue Aug 29, 2017 8:08 pm

Re: How to extract audio streams from a video file?

Postby ChrisHvide » Wed Nov 01, 2017 5:14 pm

You cannot use audacity though.
That'll only give you the video file's audio.
But I want to extract the audio streams from the video.
I used to be able to do this using Xvid on Windows.
I remember I figured out by accident while I was watching a Family Guy dvd on my PC and experimenting with the xvid settings where I was able to disable certain audio streams.
Then suddenly I heard that the vocals disappeared, leaving only the background sound. It was cool.
So I figured there must be a way to do this on Linux as well.

ugly
Level 2
Level 2
Posts: 89
Joined: Thu Nov 24, 2016 9:17 pm

Re: How to extract audio streams from a video file?

Postby ugly » Wed Nov 01, 2017 6:58 pm

Like others have said, you generally cannot do what you are trying to do. Separate audio tracks are what are recorded in studio by a band, and then they mix it to get the music you end up listening to. I know lately (usually by paying more) some bands offer these 'stems' as bonus material when you buy an album.

If you have a video that you want to extract the audio from you can use ffmpeg:

Code: Select all

ffmpeg -i "/path/to/input/file" -vn -acodec flac -bits_per_raw_sample 16 -ar 44100 "/path/to/output/file.flac"

User avatar
jimallyn
Level 16
Level 16
Posts: 6687
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: How to extract audio streams from a video file?

Postby jimallyn » Wed Nov 01, 2017 7:24 pm

ChrisHvide wrote:But I want to extract the audio streams from the video.

Which audio streams are we talking about here? Some videos might have a mono audio track, with only one "stream." Most of them are probably stereo (two channels), and some of them may have 5 or more separate audio tracks. You can separate out the tracks that are there, but you can't separate individual voices, or music sources, or anything else from the file, unless that's the way the file was created. Which, of course, they aren't.
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

ChrisHvide
Level 1
Level 1
Posts: 10
Joined: Tue Aug 29, 2017 8:08 pm

Re: How to extract audio streams from a video file?

Postby ChrisHvide » Wed Nov 01, 2017 7:40 pm

@ugly That will again only give you the same audio that you hear in the video.
What I want is every single audio stream extracted to its own file.
Because again. Unless all the audio streams have been merged together before the video file was put to dvd, you can separate them like I explained earlier with the Family Guy DVD.

User avatar
phd21
Level 13
Level 13
Posts: 4898
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to extract audio streams from a video file?

Postby phd21 » Wed Nov 01, 2017 8:44 pm

Hi "ChrisHvide",

I just read your post and the good replies to it. Here are my thoughts on this as well.

"SoundKonverter" can easily extract an audio stream from a video file, and or convert various audio formats, and rip audio CD's into digital files, etc... It is in the Software Manager or Synaptic Package Manager (SPM). I would recommend using the "Synaptic Package Manager (SPM)" to install all the recommended and suggested packages for this as well.

YouTube videos can be saved where their audio files are extracted using YouTube-DL or YouTube-DLG, and various browser add-ons.

But to separate various audio tracks the way you mention would require Audacity and or similar applications and I do not know of any that would not require user control.

Remove vocals from mp3 and get only instrumentals
https://askubuntu.com/questions/456021/remove-vocals-from-mp3-and-get-only-instrumentals


Check these links ...
https://www.google.com/search?client=opera&hs=Ihl&ei=aGv6WZb1E4PXavPKj_gI&q=linux+separate+audio+stream+for+vocals+and+one+for+background+music+and+sound+effects.&oq=linux+separate+audio+stream+for+vocals+and+one+for+background+music+and+sound+effects.&gs_l=psy-ab.3...4058.6851.0.9018.15.14.0.0.0.0.338.2066.0j2j6j1.9.0....0...1.1.64.psy-ab..11.0.0....0.1k6-GR7tRp0


Hope this helps ...
Phd21: Mint KDE 17.3 & 18.2, 64-bit Awesome OS, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,3gb Ram,160gb hdd, Video: Intel 4 Graphics, DVD Lightscribe. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

User avatar
trytip
Level 5
Level 5
Posts: 812
Joined: Tue Jul 05, 2016 1:20 pm

Re: How to extract audio streams from a video file?

Postby trytip » Wed Nov 01, 2017 10:57 pm

you can only extract separate streams if they were recorded in multiple channels. for instance if you open a 5.1 surround video in audacity you will get the respective 6 channels more or less depending on the video.

you maybe could do it with xvid from a DVD that was encoded with separate streams but today if you download a video from youtube let's say and you try to get voice stream separate from background audio or center channel it's not possible

Hoser Rob
Level 9
Level 9
Posts: 2825
Joined: Sat Dec 15, 2012 8:57 am

Re: How to extract audio streams from a video file?

Postby Hoser Rob » Thu Nov 02, 2017 8:57 am

So much confusion.; The OP should install mediainfo-gui (that's the name of the package) and then really see what's in the video files.

ChrisHvide
Level 1
Level 1
Posts: 10
Joined: Tue Aug 29, 2017 8:08 pm

Re: How to extract audio streams from a video file?

Postby ChrisHvide » Thu Nov 02, 2017 9:49 am

Omg you're right. Audacity does actually separate all the 6 channels.
Now I feel stupid. Can't believe I haven't seen this before :)
Thank you so much for helping me here, guys.

User avatar
phd21
Level 13
Level 13
Posts: 4898
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to extract audio streams from a video file?

Postby phd21 » Thu Nov 02, 2017 9:59 am

Hi "ChrisHvide",

You are welcome from all of us that responded...
Phd21: Mint KDE 17.3 & 18.2, 64-bit Awesome OS, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,3gb Ram,160gb hdd, Video: Intel 4 Graphics, DVD Lightscribe. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

Hoser Rob
Level 9
Level 9
Posts: 2825
Joined: Sat Dec 15, 2012 8:57 am

Re: How to extract audio streams from a video file?

Postby Hoser Rob » Fri Nov 03, 2017 3:43 pm

ChrisHvide wrote:Omg you're right. Audacity does actually separate all the 6 channels.
Now I feel stupid. Can't believe I haven't seen this before :)
Thank you so much for helping me here, guys.


No problem, everybody at first thinks media is a lot simpler than it really is.


Return to “Sound, Multimedia, & Codecs”

Who is online

Users browsing this forum: No registered users and 6 guests