Use VLC to extract original sound file from youtube video

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#16 Post by Pete »

@nic007

Exactly.
I always convert to wav at 48KHz sample rate and use 24 bit audio pcm_sle24,
the reason being that it gives me more dynamic range that way should I need to apply filters, dynamic compression or conversions.
For me file size is not an issue, quality is, hence the pcm 48KHz 24 bit format

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#17 Post by nic007 »

Pete wrote:@nic007

Exactly.
I always convert to wav at 48KHz sample rate and use 24 bit audio pcm_sle24,
the reason being that it gives me more dynamic range that way should I need to apply filters, dynamic compression or conversions.
For me file size is not an issue, quality is, hence the pcm 48KHz 24 bit format
Just as long as we understand that converting to wave at whatever sample rate from the original compressed file will not increase the audio quality of the file of origin. I take your point that converting to wave may give you more options to do whatever you want to do with the sound furtheron (applying effects, etc. to make it sound better for the human ear). The same way we use equalizers, etc to make it sound "better"). The raw material is still the same though. I use XMPlay to play my music. It uses the very excellent old winamp DSP plugins.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#18 Post by Pete »

@nic007
Just as long as we understand that converting to wave at whatever sample rate from the original compressed file will not increase the audio quality of the file of origin.
Absolutely, as I said a few posts back:
Also keep in mind that if the original audio in the mp4 is rubbish, converting to pcm or flac is certainly not going to improve it.
It will simply be a case of garbage in, garbage out.
Although you would be surprised at what Protools with the Isotope plug-in can do with crappy quality.
Certainly not a substitute but at times one has no option. :wink:

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#19 Post by mcewanw »

What is interesting about nic007's suggestion of using VLC to extract the audio will be if it indeed does so without having to first download the video. I haven't tried his method because I don't have VLC on my system currently.

If you have already downloaded a video, you can of course use ffmpeg to extract the audio track without re-encoding the audio at all. To do so, you use the -c:a copy encoder, which simply tells ffmpeg to copy out the audio track exactly as it is already stored:

For example, you can copy the original audiotrack from videoname (include its extension) into an m4a container:

ffmpeg -i videoname -vn -c:a copy audiotrack.m4a

The -vn option means to not include the video track.

I use this ffmpeg method often, and usually the size of the resulting audio file is considerably less than the original video, as nic007 says.

I do occasionally re-encode to say mp3 (similar to the earlier quoted ffmpeg command) if the player I want to use doesn't understand the original format, but of course the sound quality is going to be degraded then.

The VLC method sounds very good to me since anything to reduce download size is a bonus IMO. However, I would be interested to know how VLC is able to 'tell' youtube not to 'send' the original video but just the audio track. Does youtube have a special webpage URL that points to only the audio track? I certainly didn't know that.

William
github mcewanw

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#20 Post by Pete »

Youtube automatically makes and keeps not only multiple copies of the video, but it also strips the audio and keeps a copy.
This is done once a user uploads their video.

The browser (or in this case VLC) fetches what is required by means of flags in the URL.

The reason Youtube keeps multiple copies is so that it can serve you one that best matches your connection speed.
Netflix does a similar thing.

I don't know all the flags, but some are:

vq=large for 480p
vq=hd720 for 720p
vq=hd1080 for 1080p
2K and 4K also supported but don't know their flags.

These are the new ones, the old way of specifying (which may still work):

&fmt=35, &fmt=22, or &fmt=37

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#21 Post by mcewanw »

Pete wrote: I don't know all the flags, but some are:

vq=large for 480p
vq=hd720 for 720p
vq=hd1080 for 1080p
2K and 4K also supported but don't know their flags.

These are the new ones, the old way of specifying (which may still work):

&fmt=35, &fmt=22, or &fmt=37
That's a useful trick to know.
Thanks.

William
github mcewanw

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#22 Post by nic007 »

VLC does both methods, ie. extracting original audio by just entering the youtube url (not having to download the video first), and extracting from a video you have already downloaded. You can of course also decide to convert to something else if you so wish. The only problem is that in some cases VLC will not accept the url to work with (you may get MRL errors). In these cases you will have to download the video first. Luckily we can download the original video without conversion (I use the html5 browser for this).

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#23 Post by Pete »

There are other tricks too, although youtube keeps changing them, so same may still work whilst others may not or the commands have changed.

To specify an offset to start from:
start=102 would start form 102 seconds in

There is also an "end" also in seconds from the start.

To use these on the URL:

https://blaahblaah....?start=102&end=200

Note the first ? and then any other parameters are separated by a &
This is standard for passing commands/data in the URL.

@mcewanw

Are you thinking of incorporating a download feature in your screen capture program? hint hint :wink:

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#24 Post by nic007 »

The only problem is that in some cases VLC will not accept the url to work with (you may get MRL errors)
I've solved this problem by not using the youtube url but using the google-video url instead. Get the latter by double right-clicking in the html5 video window and select "copy video location"

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#25 Post by mcewanw »

Pete wrote: @mcewanw

Are you thinking of incorporating a download feature in your screen capture program? hint hint :wink:
Probably not, because as you say, youtube keeps changing its url access formats. But, for a second (continuing) I did think of leaving space for a suitable modifiable plugin. Maybe later, if I ever publish it anyway, and if I then most likely end up having to release a further bug-fixed version...

William
github mcewanw

Post Reply