How to extract audio streams from a video file?

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ChrisHvide
Level 1
Level 1
Posts: 47
Joined: Tue Aug 29, 2017 8:08 pm

How to extract audio streams from a video file?

Post by ChrisHvide »

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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
System: Intel© Core™ i9-10900K CPU @ 3.70GHz × 10
NVIDIA Corporation GA104M [GeForce RTX 3080]
Hoser Rob
Level 20
Level 20
Posts: 11796
Joined: Sat Dec 15, 2012 8:57 am

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

Post by Hoser Rob »

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.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
User avatar
jimallyn
Level 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

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

Post by jimallyn »

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.
“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: 47
Joined: Tue Aug 29, 2017 8:08 pm

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

Post by ChrisHvide »

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.
System: Intel© Core™ i9-10900K CPU @ 3.70GHz × 10
NVIDIA Corporation GA104M [GeForce RTX 3080]
User avatar
ugly
Level 5
Level 5
Posts: 592
Joined: Thu Nov 24, 2016 9:17 pm

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

Post by ugly »

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 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

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

Post by jimallyn »

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.
“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: 47
Joined: Tue Aug 29, 2017 8:08 pm

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

Post by ChrisHvide »

@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.
System: Intel© Core™ i9-10900K CPU @ 3.70GHz × 10
NVIDIA Corporation GA104M [GeForce RTX 3080]
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

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

Post by phd21 »

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/ ... trumentals


Check these links ...
https://www.google.com/search?client=op ... k6-GR7tRp0


Hope this helps ...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
User avatar
trytip
Level 14
Level 14
Posts: 5367
Joined: Tue Jul 05, 2016 1:20 pm

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

Post by trytip »

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
Image
Hoser Rob
Level 20
Level 20
Posts: 11796
Joined: Sat Dec 15, 2012 8:57 am

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

Post by Hoser Rob »

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.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
ChrisHvide
Level 1
Level 1
Posts: 47
Joined: Tue Aug 29, 2017 8:08 pm

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

Post by ChrisHvide »

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.
System: Intel© Core™ i9-10900K CPU @ 3.70GHz × 10
NVIDIA Corporation GA104M [GeForce RTX 3080]
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

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

Post by phd21 »

Hi "ChrisHvide",

You are welcome from all of us that responded...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
Hoser Rob
Level 20
Level 20
Posts: 11796
Joined: Sat Dec 15, 2012 8:57 am

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

Post by Hoser Rob »

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.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
Locked

Return to “Sound”