Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Converting Video to MP3 (Read 5825 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Converting Video to MP3

Looking to convert video to Audio (mp3), mostly from Youtube

I have tried a couple of Add-ons for Firefox, but they didn't work that well,

I use Free studio from dvdvideosoft.com currently, but am looking to see
if there are better options.

Thanks

Re: Converting Video to MP3

Reply #1
From what I hear, the youtube-dl project is good for this, and is free.

Re: Converting Video to MP3

Reply #2
Thanks,
took a quick looks interesting.
Anyone here used it ?

Re: Converting Video to MP3

Reply #3
Yes, I use it all the time. I watch entire channels through it, with mpv:
Code: [Select]
mpv <channel name> --ytdl-format='bestvideo[height<=144]+bestaudio' --ytdl-raw-options='continue=,ignore-errors='

If you just want to download the audio from a youtube video, the process is as follows:

First, check the video for available formats:
Code: [Select]
youtube-dl -F <youtube-video-url>

This will result in a list of available formats:
Code: [Select]
[...]
format code extension resolution  note
171         webm      audio only  DASH webm audio , audio@ 48k (worst)
140         m4a       audio only  DASH audio , audio@128k
160         mp4       192p        DASH video
133         mp4       240p        DASH video
134         mp4       360p        DASH video
135         mp4       480p        DASH video
17          3gp       176x144    
36          3gp       320x240    
5           flv       400x240    
43          webm      640x360    
18          mp4       640x360     (best)
As you can see in that list, there's a decent audio track available (format 140).

Next you just download that one:
Code: [Select]
youtube-dl -f 140 <youtube-video-url>
and you're done!

Alternatively, you can let youtube-dl figure out the best quality:
Code: [Select]
youtube-dl -f 'bestaudio' <youtube-video-url>
This might not be an MP4-file, it might be WebM, if the best available audio is Opus.
And in case you need a specific format, you can use things like bestaudio[ext=m4a], etc.

This is no conversion, btw. It's just downloading the audio as it comes from youtube, in its available format. The only thing it does, it just strips away the video track.

Re: Converting Video to MP3

Reply #4
In order to get m4a from youtube, I do this (replace path_to_ffmpeg_bin with the appropiate path)
Code: [Select]
youtube-dl.exe -f 140 --ffmpeg-location path_to_ffmpeg_bin  youtube_URL
Thanks to ffmpeg, this line extracts the dash-based m4a into a regular m4a.

Then I also run these other commands to fix some badly generated files that can work incorrectly in some players

Code: [Select]
move generatedfile.m4a  generatedfile-bad.m4a

path_to_ffmpeg_bin\ffmpeg.exe -y -v error -i generatedfile-bad.m4a -f ffmetadata %TEMP%\metadata.txt
path_to_ffmpeg_bin\ffmpeg.exe -y -v error -i generatedfile-bad.m4a -acodec copy -vn generatedfile.aac
path_to_ffmpeg_bin\ffmpeg.exe -y -v error -i generatedfile.aac -i %TEMP%\metadata.txt -map_metadata 1 -acodec copy -bsf:a aac_adtstoasc -vn generatedfile.m4a
Basically it extracts the metadata, extracts the plain aac data and regenerates the m4a file.

For opus, also use ffmpeg to extract it from webm into opus
Code: [Select]
youtube-dl.exe -f 251 --ffmpeg-location path_to_ffmpeg_bin  youtube_URL

Re: Converting Video to MP3

Reply #5
In my experience it is sufficient to use youtube-dl's -x option, it will then write the audio to a container file of the appropriate format (mp4 in the case of AAC, ogg in the case of opus).
Code: [Select]
youtube-dl -x URL

Re: Converting Video to MP3

Reply #6
In my experience it is sufficient to use youtube-dl's -x option, it will then write the audio to a container file of the appropriate format (mp4 in the case of AAC, ogg in the case of opus).
Code: [Select]
youtube-dl -x URL

From the documentation:
Quote
-x, --extract-audio              Convert video files to audio-only files
                                 (requires ffmpeg or avconv and ffprobe or
                                 avprobe)
maybe your system already has ffmpeg.

Re: Converting Video to MP3

Reply #7
If you don't like to mess with an CLI you can use an GUI like youtube-dl-gui
Just select download type: audio
Quality: best

Be sure to have ffmpeg.exe and ffprobe.exe in same folder as youtube-dl-gui.exe
Download the latest ffmpeg here
Latest youtube-dl can be fund here

Re: Converting Video to MP3

Reply #8
Download the latest ffmpeg here
Latest youtube-dl can be fund here


I'd rather get software from the source, rather than a 3rd party site:



Actually, my preferred way to get youtube-dl on Windows is through Python's package manager pip:
pip install youtube_dl

Re: Converting Video to MP3

Reply #9
In order to get m4a from youtube, I do this (replace path_to_ffmpeg_bin with the appropiate path)
Code: [Select]
youtube-dl.exe -f 140 --ffmpeg-location path_to_ffmpeg_bin  youtube_URL
Thanks to ffmpeg, this line extracts the dash-based m4a into a regular m4a.

Then I also run these other commands to fix some badly generated files that can work incorrectly in some players

Code: [Select]
move generatedfile.m4a  generatedfile-bad.m4a

path_to_ffmpeg_bin\ffmpeg.exe -y -v error -i generatedfile-bad.m4a -f ffmetadata %TEMP%\metadata.txt
path_to_ffmpeg_bin\ffmpeg.exe -y -v error -i generatedfile-bad.m4a -acodec copy -vn generatedfile.aac
path_to_ffmpeg_bin\ffmpeg.exe -y -v error -i generatedfile.aac -i %TEMP%\metadata.txt -map_metadata 1 -acodec copy -bsf:a aac_adtstoasc -vn generatedfile.m4a
Basically it extracts the metadata, extracts the plain aac data and regenerates the m4a file.

For opus, also use ffmpeg to extract it from webm into opus
Code: [Select]
youtube-dl.exe -f 251 --ffmpeg-location path_to_ffmpeg_bin  youtube_URL

You should use -f 'bestaudio[ext=<ext>]',. If you use a specific format ID that isn't present for that particular video, it will simply not work.

Also with FFmpeg, use -c:a copy.

Since youtube-dl 2015-xx-xx, youtube-dl uses ffmpeg by default to fix header issues, unless it can't find ffmpeg. So as long as it's inside %PATH% (or $PATH) you're fine. You can also just pack your metadata re-packing in one go, it creates the same output.

In fact, I'd advice keeping ffmpeg in your %PATH% such that youtube-dl can use it by default.

ref: https://github.com/ytdl-org/youtube-dl/issues/3681

Download the latest ffmpeg here
Latest youtube-dl can be fund here


I'd rather get software from the source, rather than a 3rd party site:



Actually, my preferred way to get youtube-dl on Windows is through Python's package manager pip:
pip install youtube_dl

I wasn't even aware people are "mirroring" ytdl.

Speaking of it, be ready to update it regularly. Youtube-dl is in a cat-and-mouse game with websites. Youtube-dl is one of the few things I don't use through repos, since it needs updating quicker, than Fedora is putting it into their repos. I'm also using it for soundcloud and all other websites it supports. It also works with Twitch and nearly all streaming platforms out there (for live video, but also VOD).

Re: Converting Video to MP3

Reply #10
Thanks for all the info, I'm on Windows 7,
not sure if I have Python etc....

Are there any other options other than  youtube_dl ?

Currently I use the free version of Dvdvideosoft  https://www.dvdvideosoft.com/
which works fine 95% of the time (there are some vids on YT that don't seem to work ??)

Re: Converting Video to MP3

Reply #11
I think youtube-dl should cover your issues. You don't need Python if you download exe, it only needs msvc runtime 2010. Which part that still not working to you?

 

Re: Converting Video to MP3

Reply #12
Maybe they need a fancy dialog window to paste the link into, because a terminal window is too hard to figure out.

Re: Converting Video to MP3

Reply #13
If you ever need a good dvd/blu-ray ripper, I have used this a ton for several years. Always satisfied http://www.dvdae.com/