Hydrogenaudio Forums

Lossless Audio Compression => Lossless / Other Codecs => Topic started by: 320kbp/s on 2010-06-17 09:57:37

Title: Convert mp4 Youtube video to lossless audio file
Post by: 320kbp/s on 2010-06-17 09:57:37
Hey guys, I try to convert some of my favorite songs from Youtube video file (.mp4) to lossless music, but the best result is only 320kbp/s.
Could you please show me a software that we can convert mp4 file from Youtube to lossless form like wav or flac, ...
Thank you very much !
Title: Convert mp4 Youtube video to lossless audio file
Post by: probedb on 2010-06-17 10:02:32
There's no point converting it to lossless, it's already compressed, it'll just take up more space for no gain in quality over the aac (?) in the .mp4 container.

Just demux the mp4 and keep the audio separate.
Title: Convert mp4 Youtube video to lossless audio file
Post by: 320kbp/s on 2010-06-17 20:16:48
Quote
Just demux the mp4 and keep the audio separate

Okay, thanks, but how can I seperate them ? Could you please show me a software ? I use Audioro Zune HD Converter and I did converted some of my videos to mp3 320kbp/s.
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-06-17 21:43:24
You could try MP4Box (http://www.videohelp.com/tools/mp4box). Check its documentation (http://gpac.sourceforge.net/doc_mp4box.php) to be sure, but IIRC you'll need to run -info to determine the ID of the audio track, then run -extract with that ID to dump it to a new file. There are probably GUI programs (or frontends for MP4Box) that can also do this, if you prefer that; have a search.

As said already there's no point converting to MP3. You'll just lose quality and space. This applies to any format, even lossless ones (though in this case you just lose space).
Title: Convert mp4 Youtube video to lossless audio file
Post by: splice on 2010-06-18 00:10:32
Avidemux (http://avidemux.org) will extract the audio from a .MP4 file and write it to a WAV file.
As others have pointed out, the recommended method is to first determine what format the audio is in already within the MP4 file. If you can use it in that format, then just split it out to a file using Avidemux or similar.
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-06-18 01:04:57
Avidemux (http://avidemux.org) will extract the audio from a .MP4 file and write it to a WAV file.

This would be suboptimal. However, if I have interpreted the remainder of your post correctly, it seems that you acknowledge this:

Quote
As others have pointed out, the recommended method is to first determine what format the audio is in already within the MP4 file. If you can use it in that format, then just split it out to a file using Avidemux or similar.

According to Wikipedia (http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs), all YouTube videos have their audio in AAC format. Thus it should be trivial to extract the raw AAC. However, I forgot to mention above that you'll want to add a new MP4 container to the resulting raw AAC file with the -add option. I can't edit my above post--so here's what I hope is a slightly more descriptive, accurate, and hopefully useful list of steps:

mp4box -info youtubefile.mp4 = Get TrackID of the audio track
mp4box -raw TrackID = Extract this track to a raw AAC file
mp4box -add resultingfile.aac yournewfile.m4a = Add to this raw file an MP4 container (needed by many apps, including iTunes which 'prefers' the file extension m4a for audio-only files)
Title: Convert mp4 Youtube video to lossless audio file
Post by: 320kbp/s on 2010-06-18 04:26:13
Thank you very much dv1989 !
However I tried using Mp4box gui, I see from the youtube.mp4 info that quality of the AAC file is only 96 or 100kbp/s. It's quite small than the others I got from Audioro Zune HD Converter. So the problem is, is that 320kbp/s getting from Audioro Zune HD Converter faked ?  Sorry for my English and may be stupid questions 
More details :

(http://img121.imageshack.us/img121/3889/realc.gif)


(http://img265.imageshack.us/img265/3772/faked.gif)
Title: Convert mp4 Youtube video to lossless audio file
Post by: Compact Dick on 2010-06-18 06:56:22
Converting any audio file to MP3 will mean quality is lost. The resulting MP3 will always be inferior to the original.

This means the 96 kbps AAC track will be superior to the 320 kbps MP3.

By extracting the AAC audio, the original quality is preserved, regardless of file size.
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-06-18 10:37:38
However I tried using Mp4box gui, I see from the youtube.mp4 info that quality of the AAC file is only 96 or 100kbp/s. It's quite small than the others I got from Audioro Zune HD Converter. So the problem is, is that 320kbp/s getting from Audioro Zune HD Converter faked ?

Yes, it simply transcodes (http://wiki.hydrogenaudio.org/index.php?title=Transcoding) the lossy AAC file to a higher-bitrate lossy MP3 file. As Compact Dick and I have said, converting any lossy format to another will decrease quality. If the bitrate is higher you will lose disk space as well as quality. Transcoding to lossless will preserve quality but waste even more space. So as CD said, you must settle for the low-bitrate AAC/M4A track. Or you could buy the song(s) in a better format . . .
Title: Convert mp4 Youtube video to lossless audio file
Post by: enry2k on 2010-06-18 13:04:28
Did you try Yamb, another Ui for MP4Box, you can extract the aac track to .m4a file which can be played by your Zune wihtout any recoding loss

Enrico
Title: Convert mp4 Youtube video to lossless audio file
Post by: Artie on 2010-10-19 22:41:10
According to Wikipedia (http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs), all YouTube videos have their audio in AAC format. Thus it should be trivial to extract the raw AAC. However, I forgot to mention above that you'll want to add a new MP4 container to the resulting raw AAC file with the [font= "Courier New"]-add[/font] option. I can't edit my above post--so here's what I hope is a slightly more descriptive, accurate, and hopefully useful list of steps:

[font= "Courier New"]mp4box -info youtubefile.mp4[/font] = Get TrackID of the audio track
[font= "Courier New"]mp4box -raw TrackID[/font] = Extract this track to a raw AAC file
[font= "Courier New"]mp4box -add resultingfile.aac yournewfile.m4a[/font] = Add to this raw file an MP4 container (needed by many apps, including iTunes which 'prefers' the file extension m4a for audio-only files)


I'm just learning MP4Box myself, but doesn't the command:

mp4box -single TrackID youtubefile.mp4

. . . automatically combine those last two commands into one?
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-10-20 14:30:37
Now that I check the documentation (http://gpac.sourceforge.net/doc_mp4box.php), it appears to, so that’s a good point.
Title: Convert mp4 Youtube video to lossless audio file
Post by: mixminus1 on 2010-10-20 15:28:38
The end result isn't exactly the same, though...files that are created via the "-single" method display a bitrate of "Unknown" in iTunes, whereas files made via the two-step method display the correct bitrate, so there appears to be some difference in how the metadata is written.
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-10-20 15:36:05
Ah, thanks. I know there’s an ‘issue’ where if one names the file whatever.mp4 (instead of m4a) iTunes identifies a 0 kbps video track; does that have any effect on this?
Title: Convert mp4 Youtube video to lossless audio file
Post by: romor on 2010-10-20 15:52:41
320kbp/s

what's the point of "p" in the name?
It's either metric Kb/s or american kbps or even kb/s, but kbp/s is wrong
Title: Convert mp4 Youtube video to lossless audio file
Post by: mixminus1 on 2010-10-20 15:56:27
Interesting...with the .mp4 extension, iTunes will display the correct bitrate of the "-single" file (as well as reporting a video track with resolution of 0x0), but now the sample rate is "Unknown", and the "Sample Rate" field doesn't even show up in the "Get Info" dialog box...still plays correctly, though.

Strange things are afoot at the Circle K...
Title: Convert mp4 Youtube video to lossless audio file
Post by: Chef on 2010-10-20 15:57:27
You could try MP4Box (http://www.videohelp.com/tools/mp4box). Check its documentation (http://gpac.sourceforge.net/doc_mp4box.php) to be sure, but IIRC you'll need to run -info to determine the ID of the audio track, then run -extract with that ID to dump it to a new file. There are probably GUI programs (or frontends for MP4Box) that can also do this, if you prefer that; have a search.

As said already there's no point converting to MP3. You'll just lose quality and space. This applies to any format, even lossless ones (though in this case you just lose space).

This is a silly supposition, but if you think converting to lossless will not cause a decrease in quality when converting from a lossy format, and you think (presumably) converting lossless to lossy accrues no special loss of quality (other than that is already specified by the lossy format, then does it logically follow that were converting lossy to lossy causes many problems, converting lossy to lossless and then to another lossy format should not have any special losses of quality? This is not supposing that you can make a 128 kb/s file a 196 kb/s file (in terms of the quality they are associated with), but that a 320 kb/s mp3 that someone might want to convert to at 192 kb/s mp3 would be better done with this middle step due extra problems involved in directly converting lossy to lossy formats.

Anyone tried this extensively? I'd be interested to know... An abcx test of a lossless to lossy to lossy, a lossy to lossless to lossy, and the original lossless, would be interesting, if I understand the issues with lossy to lossy conversion correctly.
Title: Convert mp4 Youtube video to lossless audio file
Post by: mixminus1 on 2010-10-20 16:07:57
...if I understand the issues with lossy to lossy conversion correctly.

No, you don't.

Once again, lossless=lossless=lossless...loss...less...no loss...etc.

Any lossy->lossy process necessarily involves an intermediate "lossless" step, i.e. the source lossy file MUST be decompressed to straight PCM, and then that PCM data is encoded into a new lossy file.

Whether that intermediate PCM data is stored in a RAM buffer or as a lossless file on a disk, it is the exact same data (barring memory or disk corruption, of course) and it must exist.

As such:

Quote
lossless to lossy to lossy, a lossy to lossless to lossy,


are one and the same, assuming that the first lossy file in the second process was encoded from the same lossless file at the beginning of the first process.

edit:  Wow, strange things are indeed afoot at the Circle K...dv1989 and I posted essentially the exact same answer one minute apart...which should give you some idea of how often this issue comes up...I think it's something like n+1  .
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-10-20 16:08:49
For the trillionth time, there is no such thing as a direct conversion between audio formats. The source file is always decompressed to PCM before being fed into the encoder of the destination file. What seems to confuse some people and lead to questions like yours is that some applications hide this fact.

So, yes, I’m afraid that is a silly supposition. Lossless is lossless; that is, it is exactly the same as the decompressed PCM fed to the destination encoder.
Title: Convert mp4 Youtube video to lossless audio file
Post by: Miramis on 2010-10-20 16:32:11
XMedia Recode (http://www.xmedia-recode.de/) can be used to extract the audio. Select Copy Audio (= audio will not be recoded).
Title: Convert mp4 Youtube video to lossless audio file
Post by: Artie on 2010-10-20 20:53:03
For the trillionth time, there is no such thing as a direct conversion between audio formats. The source file is always decompressed to PCM before being fed into the encoder of the destination file. What seems to confuse some people and lead to questions like yours is that some applications hide this fact.


Thanks for that clarification. I've always wondered about that.

So, supposing that I don't care about iTunes, (and I don't), is the "-single" command ok to use in all other aspects? I don't mind using the 3-command format if thats better in some way.

Title: Convert mp4 Youtube video to lossless audio file
Post by: mixminus1 on 2010-10-20 21:09:05
FWIW, personally, I've only processed a handful of files using the "-single" method (about a dozen), and thus far, I haven't encountered any problems outside of iTunes not being able to read the bitrate.

iTunes can play them just fine, and foobar2000 also plays them fine and displays the correct bitrate.
Title: Convert mp4 Youtube video to lossless audio file
Post by: Artie on 2010-10-20 21:20:26
Thanks mix. Still, it makes you wonder whats going on deep down inside, so to speak.
Title: Convert mp4 Youtube video to lossless audio file
Post by: db1989 on 2010-10-21 18:58:05
Interesting...with the .mp4 extension, iTunes will display the correct bitrate of the "-single" file (as well as reporting a video track with resolution of 0x0), but now the sample rate is "Unknown", and the "Sample Rate" field doesn't even show up in the "Get Info" dialog box...still plays correctly, though.

Strange things are afoot at the Circle K...
Wait, so that’s with the extension mp4? I meant that iTunes prefers m4a, which doesn't lead to the 0x0 video track being shown in Properties. So your unknown bitrate issue was with the extension m4a?

I also wonder what the technical reason is for the difference between the 3- and 2-command methods, and whether it really matters in the end, but I personally would probably use the former, just to get maximum correctitude from my kibilops (and the superior breathability it confers on my audio, duh!)
Title: Convert mp4 Youtube video to lossless audio file
Post by: mixminus1 on 2010-10-21 20:32:22
Correct:

- .m4a extension on "-single" produced file: iTunes displays "Unknown" for the bitrate, all other (meta)data is correct

- .mp4 extension on "-single" produced file: iTunes displays the correct bitrate (as well as the empty video track), but then displays "Unknown" for the sample rate - note that it also does this with the 2-step produced file

I had been using source files encoded with iTunes, so I tried using Nero's CLI encoder to produce one, and got the exact same results.
Title: Convert mp4 Youtube video to lossless audio file
Post by: roozhou on 2010-10-22 07:39:29
You can also try ffmpeg:

ffmpeg -i input.mp4 -vn -acodec copy output.m4a
Title: Convert mp4 Youtube video to lossless audio file
Post by: DOS386 on 2010-10-23 10:33:46
You can also try ffmpeg:

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


That's what I would try. There should be no quality loss. To test you can "play" the movie and well as the stripped audio-only file with MPLAYER into -vo pcm and the 2 WAV files should be identical (untested).

To get rid of the proprietary AAC codec with no loss, the solution is MPLAYER -vo pcm too and then compress the WAV file with FLAC or WAVPACK. The 100% free and 100% lossless audio-only file might have a size comparable to the original video, or could be even bigger in worst case :shock:
Title: Convert mp4 Youtube video to lossless audio file
Post by: greynol on 2010-10-23 20:07:59
To get rid of the proprietary AAC codec with no loss, the solution is MPLAYER -vo pcm too and then compress the WAV file with FLAC or WAVPACK. The 100% free and 100% lossless audio-only file might have a size comparable to the original video, or could be even bigger in worst case :shock:

If you go back and re-read the entire message you will see that this advice is no longer useful.

While you're at it, please tone-down your the open-source zealotry.
Title: Convert mp4 Youtube video to lossless audio file
Post by: woody_woodward on 2010-10-25 02:18:43
Hey guys, I try to convert some of my favorite songs from Youtube video file (.mp4) to lossless music, but the best result is only 320kbp/s.
Could you please show me a software that we can convert mp4 file from Youtube to lossless form like wav or flac, ...
Thank you very much !

I use FLV Extract.
http://moitah.net/#FLVExtract (http://moitah.net/#FLVExtract)
It will split out the audio and video into seperate files.  No transcoding.  If the FLV contains MP3 audio, that's what you get.  If it contains AAC, that's what you get.  You can do your own transcoding, or not.
Title: Convert mp4 Youtube video to lossless audio file
Post by: Zarggg on 2010-10-26 22:52:36
That solution is irrelevant, as the OP is using MPEG-4 containers, not FLV containers.
Title: Convert mp4 Youtube video to lossless audio file
Post by: Chef on 2010-10-31 15:59:35
For the trillionth time, there is no such thing as a direct conversion between audio formats. The source file is always decompressed to PCM before being fed into the encoder of the destination file. What seems to confuse some people and lead to questions like yours is that some applications hide this fact.

So, yes, I’m afraid that is a silly supposition. Lossless is lossless; that is, it is exactly the same as the decompressed PCM fed to the destination encoder.

Ah... Sorry. So then why does an mp3 get worse and worse the more times you convert it? If a 192 kb/s file were converted to 192 kb/s, shouldn't it output exactly the same? And yet the report I'm most familiar with, is that it does bug out.

In my head I'm imagining the program has determined what it wants to take out, and will always only take out that information... I've only been able to understand why there is a loss of quality in lossy to lossy conversion by assuming that the file is actually different. Your explanation, while I believe you, presents a mystery
Title: Convert mp4 Youtube video to lossless audio file
Post by: devnul on 2010-10-31 16:32:37
well thats what I did:
- dl mp4
- use mkvmerge (mmg.exe) to take the audio track
- use mkvextract to get an aac file
- use mp4iptools (mp4creator.exe I think) to create a new mp4 file

it's rather complicated but at least I know what happens to the file, instead of using some freeware converter
Title: Convert mp4 Youtube video to lossless audio file
Post by: Cynic on 2010-10-31 20:06:16
 
Ah... Sorry. So then why does an mp3 get worse and worse the more times you convert it? If a 192 kb/s file were converted to 192 kb/s, shouldn't it output exactly the same?
No, because MP3 is lossy, not lossless.

 
I've only been able to understand why there is a loss of quality in lossy to lossy conversion by assuming that the file is actually different.
And it IS different: assume you start with a PCM file that you convert to MP3 once. If you convert that MP3 back to PCM, the result will be different from the original PCM file; even though its size would be the same, the audio data would be different. That's why if you compress that new PCM file to MP3 one more time, you will lose quality again. 
Title: Convert mp4 Youtube video to lossless audio file
Post by: Zarggg on 2010-11-03 03:37:25
In my head I'm imagining the program has determined what it wants to take out, and will always only take out that information... I've only been able to understand why there is a loss of quality in lossy to lossy conversion by assuming that the file is actually different. Your explanation, while I believe you, presents a mystery


Here's a dumbed-down explanation (it's not EXACTLY right, but close enough for people not concerned with the details):

MP3 encoding uses an algorithm known as the "psycho-acoustic model" to analyze an audio file and determine what pieces it can take out while still producing a file that sounds the same (or "close enough" to the average ear). If this algorithm is applied using insufficient bits for the task (i.e., low-bitrate files), or applied several times in succession to its output (i.e., re-encoding a lossily-encoded file), then it can "mess up" and generate what are known as "artifacts": warbling, "underwater-like" sounds, blips, pops, etc.

In other words, it doesn't "know" what bits it's going to take out before-hand; it determines that based on the input. It won't (and can't) produce identical output with different inputs.
Title: Convert mp4 Youtube video to lossless audio file
Post by: psix on 2013-12-30 20:45:42
FWIW, personally, I've only processed a handful of files using the "-single" method (about a dozen), and thus far, I haven't encountered any problems outside of iTunes not being able to read the bitrate.

iTunes can play them just fine, and foobar2000 also plays them fine and displays the correct bitrate.

I'm a little late to the game, but Rockbox, for example, doesn't like all -single files and I think I found out why:
-single seems to retain the trackid, which causes problems when it's not 1.

Then again I do have a couple of files with trackid other than 1 with odsm and sdsm tracks present in root OD, which do work.
They were created with mp4ui, or that's what mp4box tells me - I can't remember.
SimplePortal 1.0.0 RC1 © 2008-2019