LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-19-2010, 09:01 AM   #1
sylar
LQ Newbie
 
Registered: Apr 2009
Location: Russia
Distribution: debian squeeze
Posts: 10

Rep: Reputation: 0
extract audio from a mkv file


how can extract audio from a mkv file.. i've done it with ffmpeg but the output's quality was terrible..

do you knox any apps for doing that kind of thing with not loosing its quality.

platform: debian testing
 
Old 10-19-2010, 09:21 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,846

Rep: Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007
What was the exact command you used? Because ffmpeg can rip the stream directly out of the container with no re-encoding.
Code:
ffmpeg -i input.mkv -vn -acodec copy outputfile
If you pay close attention to the screen output while ffmpeg is running, you can see exactly what the input and output streams are encoded as.
 
1 members found this post helpful.
Old 10-19-2010, 09:32 AM   #3
sylar
LQ Newbie
 
Registered: Apr 2009
Location: Russia
Distribution: debian squeeze
Posts: 10

Original Poster
Rep: Reputation: 0
i used ffmpeg -i input.mkv -vn xxx.mpeg ( try to do mp3 but its not supported)
 
Old 10-19-2010, 11:02 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,846

Rep: Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007Reputation: 2007
Well, ffmpeg's default audio format for the mpeg container is an mp2 stream, and its default bitrates are always set very low, so yes, that's what you got. I just ran a test myself, and the output showed this for audio:
Code:
stream #0.0: Audio: mp2, 44100 Hz, 2 channels, s16, 64 kb/s
Setting -acodec to copy will give you whatever the original stream is encoded as, no matter what the output filename is. Look at the corresponding input line.

But nothing's keeping you from configuring the command to make it give you the kind of output you want. Just read the ffmpeg man page and/or search the web.

As for mp3 support, it's usually handled by the external libmp3lame library. Run ffmpeg -codecs |grep mp3 and see if there's a line in it for libmp3lame with an "E" (for encode) at the front. Since mp3 is a patent-encumbered codec, I don't think the default debian version of ffmpeg has support for liblame enabled, but I may be wrong.

In any case, you can get better versions of ffmpeg and other similar programs by adding the debian-multimedia repository to your apt sources. These have most of the common codecs enabled. http://debian-multimedia.org/

Once you have a version with liblame support installed, just use -acodec libmp3lame in your command, along with -ab to set the bitrate you want, or -aq to set the quality level.
 
Old 10-19-2010, 12:22 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
You can use mkvextract if you want:

First run:

Code:
mkvinfo Game.mkv
You will get something like:
Code:
| + A track
|  + Track number: 2
...
|  + Track type: audio
...
|  + Codec ID: A_AAC
This tells you that track 2 is audio of type aac, so now you can extract it:

Code:
mkvextract tracks Game.mkv 2:file.aac
If it is mp3, just title it file.mp3. If you want to convert to another format see the howto I made (very bottom):
http://draconishinobi.50webs.com/linux/encoding.html

I refer to it myself, because I figured it out once, then forgot, because I didn't write it down. So I had to figure it out again, but this time I wrote it down.
 
Old 03-31-2015, 09:26 AM   #6
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 517
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
As pointed out above,
Quote:
ffmpeg -i input.mkv -vn -acodec copy out.ext
will extract the audio stream, where .ext would be something like mp3 or aac or whatever - you'l have to look it up with ffprobe first. Or alternatively you can use
Quote:
mplayer -audiodump video.mkv
to dump the audio to a wave file.
 
Old 11-26-2017, 05:07 AM   #7
petroni
LQ Newbie
 
Registered: Nov 2017
Posts: 1

Rep: Reputation: Disabled
Thumbs up mp3 exctraction from mkv container

Hi,
I am novice to Linux (Mint in my case) and I followed quite few forums to find working and easy solution. And the easiest for me is to use ... outsanding Audiacity (file/import/audio) and than (fie/export and choose mp3 in right down corner).
Have fun!
 
Old 11-26-2017, 10:28 AM   #8
packer59
Member
 
Registered: Oct 2017
Posts: 47

Rep: Reputation: Disabled
ffmeg is outdated guys, didn't you know?
 
Old 11-27-2017, 12:41 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,261
Blog Entries: 9

Rep: Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949
^ erm.

firstly, it's ffmpeg.

can you substantiate this claim?
until you do, i object strongly.
quite the opposite actually.
 
Old 11-27-2017, 11:11 AM   #10
packer59
Member
 
Registered: Oct 2017
Posts: 47

Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
^ erm.

firstly, it's ffmpeg.

can you substantiate this claim?
until you do, i object strongly.
quite the opposite actually.
if you want. https://en.wikipedia.org/wiki/Libav
 
Old 11-27-2017, 11:05 PM   #11
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,511

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
I don't think the wikipedia article really settles the issue. https://lwn.net/Articles/650816/
 
Old 11-28-2017, 01:16 AM   #12
packer59
Member
 
Registered: Oct 2017
Posts: 47

Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
I don't think the wikipedia article really settles the issue. https://lwn.net/Articles/650816/
Rather endless story. avconv vs ffmpeg.
 
Old 11-28-2017, 12:34 PM   #13
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,261
Blog Entries: 9

Rep: Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949
Quote:
Originally Posted by packer59 View Post
ffmeg is outdated guys, didn't you know?
Quote:
Originally Posted by packer59 View Post
Quote:
Originally Posted by AwesomeMachine View Post
I don't think the wikipedia article really settles the issue. https://lwn.net/Articles/650816/
Quote:
Originally Posted by packer59 View Post
Rather endless story. avconv vs ffmpeg.
i think you just made a 180 degree turn there?

anyhow, looking at both articles, it seems indeed that "libav is ffmpeg".
but 2 more years have passed since 2015.

anyhow, archlinux uses ffmpeg. searching package database for "libav" returns ffmpeg. it is not possible to install "libav" or "avconv". that is good enough for me.

Last edited by ondoho; 11-28-2017 at 01:41 PM. Reason: added one 'm'
 
Old 11-28-2017, 01:08 PM   #14
packer59
Member
 
Registered: Oct 2017
Posts: 47

Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
i think you just ade a 180 degree turn there?

anyhow, looking at both articles, it seems indeed that "libav is ffmpeg".
but 2 more years have passed since 2015.

anyhow, archlinux uses ffmpeg. searching package database for "libav" returns ffmpeg. it is not possible to install "libav" or "avconv". that is good enough for me.
avconv is actually the most recent, but ffmpeg claims to be the most maintained.
 
Old 11-29-2017, 12:22 AM   #15
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,261
Blog Entries: 9

Rep: Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949
Quote:
Originally Posted by packer59 View Post
avconv is actually the most recent, but ffmpeg claims to be the most maintained.
the way i understod that wikipedia article, avconv has been merged back into ffmpeg.
so that statement doesn't make a lot of sense.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting 6 channel audio to 2 channel audio in a MKV file J_Humphrey Linux - Software 9 10-21-2013 04:27 AM
Extract audio from mov file sigma_50 Linux - Desktop 3 05-31-2008 02:35 AM
Extract audio from exif jpeg file? gbowden Slackware 9 07-13-2007 08:08 AM
.mkv in Xine = No Audio III Linux - Software 0 09-01-2004 08:16 PM

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

All times are GMT -5. The time now is 11:05 PM.

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