LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Best way to extract AAC from mp4 losslessly (http://www.linuxquestions.org/questions/linux-software-2/best-way-to-extract-aac-from-mp4-losslessly-852936/)

KickMeElmo 12-28-2010 10:01 PM

Best way to extract AAC from mp4 losslessly
 
Subject says it all. I have an mp4 file I'd like to get the audio out of (details below if you want to know), and every method I've seen suggested either produces a junk file, re-encodes it with loss in quality (noticeable), or re-encodes it at 64kbps (which is disgusting for music, frankly). Not looking for anything more than an audio rip. Tips, anyone?

EDIT:
Just obtained Avidemux and am attempting with it. Have a feeling it's doable, but frankly, I've never used the program and have no clue how to work it. If that'd do it, tips there would work too! And now for a second edit, after looking into it, seems in the newer versions of avidemux, that feature is broken. Ah well.

File info:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Andrea .mp4':
Duration: 00:03:30.28, start: 0.000000, bitrate: 4157 kb/s
Stream #0.0(und): Video: h264, yuv420p, 1920x942 [PAR 1:1 DAR 320:157], 4024 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 128 kb/s

GlennsPref 12-29-2010 01:16 AM

this seems to cover it...

http://www.linuxquestions.org/questi...format-834464/

Hope this helps, Glenn

KickMeElmo 12-29-2010 01:54 AM

Not quite, unfortunately. Worth note is that I'm not trying to produce a flac, which produces a 22.4MB file for 3.2MB of data. I'm just trying to get the AAC stream -out-, really. Already tried with ffmpeg (can produce an Mp3 at 64kbps, but can't produce a usable file of any other type, nor any other bitrate without attempting a lossy transcode) and mplayer (produces junk files). As mentioned above, I also attempted Avidemux, only to find out that feature is very nicely broken in the current release. I did try mencoder, but if there's a way to manage what I'm attempting using it, I have a feeling I'm approaching it from the wrong angle. All I managed with it was a wav, which suffered the same issue as the flac file did.

The quality of audio is already somewhat impaired in the file I'm working with, and any loss of quality from transcoding beyond the current state is -very- noticeable.

Thanks for the response though! I'm going to keep fiddling with these and see if I can come up with something that works, but if you or anyone else has any suggestions, please, feel free to share, I'm up for trying anything.

GlennsPref 12-29-2010 03:31 AM

This is a new one to me, I have been looking in my local haunts and have only come up with a 2 step process.

And that would be to...

convert to .wav or .flac using avidemux or ffmpeg (or whatever)

change to the dir where the file is,
Code:

ffmpeg -i input.flv  output.flac
or change the dir to where you want the output to go to and reference the input file with the url.(see relative and absolute addressing)
Code:

cd ~/build
ffmpeg -i ~/videos/input.flv  output.flac

then, using audacity, import the file (wav or flac)

select all and export it as .m4a (which is mpeg4-aac, from what I can gather).

Quality?, as long as you convert up to wav or flac before converting to aac or mp3

I'd be surprised if you lost anymore detail.

49.3Mb .wav to 3.9Mb .m4a

My assumption is based on a quick check of audacity's import/export functions.

If you can try it you should see , you can change the file format at the bottom of the same window as export (type).

If you need/want to install audacity, install the lame package first, for mp3 support.

please try it, and ask here...

Regards Glenn

edit acc/aac typos

direx 02-05-2011 02:43 PM

Have you found a solution for this yet?

I am trying to accomplish the same thing and this is how I am doing it (pretty dirty, but it works):
  1. Install mkvtoolnix
  2. Launch mkvmerge GUI
  3. Add your MP4 file and start muxing it into a MKV file (this is lossless!)
  4. Open a shell and use mkvextract to extract only the audio track from the MKV. I use this command:
    Code:

    mkvextract tracks "mkv-file.mkv" 1:audio.aac

If anyone has a cleaner solution please let us know!

KickMeElmo 02-05-2011 03:47 PM

Hmmm... step three doesn't transcode the audio at all? I hadn't ever considered that option. And no, I never really found a good, clean, working solution. I just ended up having to eat the loss of quality from the AAC>FLAC>AAC convert. Believe me, I'm still -very- interested in a solid solution.

H_TeXMeX_H 02-06-2011 03:22 AM

I agree with mkvextract, that's the way I always do it.

You can also extract it as is with ffmpeg:
Code:

ffmpeg -i input.mp4 -acodec copy output.aac

KickMeElmo 02-06-2011 06:44 AM

Bingo. That syntax for ffmpeg is the mythical one I couldn't manage to piece together. Just tested and it worked like a charm.

ThurnerRupert 01-01-2013 02:41 PM

Quote:

Originally Posted by H_TeXMeX_H (Post 4249765)
I agree with mkvextract, that's the way I always do it.

You can also extract it as is with ffmpeg:
Code:

ffmpeg -i input.mp4 -acodec copy output.aac

the one which works similar, but much quicker:
Code:

avconv -i input.mp4 -acodec copy output.aac

berain 03-20-2013 04:27 PM

Quote:

Originally Posted by H_TeXMeX_H View Post
I agree with mkvextract, that's the way I always do it.

You can also extract it as is with ffmpeg:
Code:

Code:

ffmpeg -i input.mp4 -acodec copy output.aac

While I believe the above may work it will require processing of the video content which is unnecessary if you're only concerned with extracting the audio portion. This will result in long processing times. Consider adding "-vn" to disable video. This should result in much faster extractions. Demuxing by definition should not require any kind of transcoding so is I/O bound, not processor bound.

Code:

ffmpeg -i input.mp4 -vn -acodec copy output.aac

turtlepurple 03-22-2014 12:10 PM

Let me add a little detail here because aac-files wont play in some players and e.g. puddletag wont open them, but if you use mp4 or m4a as output here ffmpeg will still encode the video. So add -vn to strip the video.

ffmpeg -i input.mp4 -vn -acodec copy output.aac
or since ffmpeg will be replaced through avconv (I think avconv has a shorter syntax too)
avconc -i input.mp4 -vn -acodec copy output.aac

Greets


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