Sunday, May 2, 2010

Download Youtube(and other) videos and batch convert them to mp3

This is a quick article on how to download videos from youtube (or any other supported site) and batch convert them into mp3 files.

First, how do you get the videos downloaded from youtube? I use the software from http://www.downloadhelper.net/   . It is a Firefox plug in.  Unfortunately, I have not found a Chrome equal.  SO I used Firefox for this task.

Using Download Helper, you just select download from its toolbar when you find your desired video.  You can select between flv and m4p file types.  I choose flv as personal preference.

Now the real reason for writing this, step 2: converting the video to a mp3.  I spent a portion of today trying out freeware that is supposed to do this easy task.  It all pretty much angered me.  Let me tell you what I tried so you don't go down the same path:

Freez FLV to MP3 - Not Free, can use once before getting a registration prompt. If you don't register, the program closes.  It also wouldn't batch encode more than 30 items.
FLV2MP3.org - It kept giving me 0 byte mp3 files.
A file from richapps.de: It wasn't a batch converter.

The program I ended up using, was VideoLan player.  It is an absolute favorite program of mine. There is no batch conversion feature of VideoLan.  However, a quick and dirty BAT file will do the trick.  I found the following code on the videolan help wiki and changed it for flv files.

Create your BAT file (How to create a bat file) in the top most directory where you downloaded your FLV files.  I plan to use this frequently so I called mine vlanFLV2mp3.BAT. It will convert all the files in that directory and in all the sub-directories below it. For instance, if you downloaded the flv files into C:\Documents and Settings\MYPC\Desktop\FLV and then have sub-directories of musical artists, you would want the BAT file in that top ..\Desktop\FLV directory.


Here is the code you need to past into the BAT file:

@ECHO OFF
REM ########################################################################
REM # A Windows XP cmd.com script to batch convert flv files to mp3. #
REM # #
REM # Copyright (C) 2008 Andrew Boden #
REM # (boden@graduate.uwa.edu.au) #
REM # #
REM # This program is free software: you can redistribute it and/or modify #
REM # it under the terms of the GNU General Public License as published by #
REM # the Free Software Foundation, either version 3 of the License, or #
REM # (at your option) any later version. #
REM # #
REM # This program is distributed in the hope that it will be useful, #
REM # but WITHOUT ANY WARRANTY; without even the implied warranty of #
REM # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
REM # GNU General Public License for more details. #
REM # #
REM # You should have received a copy of the GNU General Public License #
REM # along with this program. If not, see .#
REM # #
REM # Version 1.0 (June 27th 2008) #
REM # Uses VideoLAN VLC 0.8.6h (www.videolan.org) #
REM # Gracefully handles commas and apostrophes in file names. #
REM # Not aware of any other characters needing graceful handling. #
REM # 512kbps encoding with 44100 sampling. #
REM ########################################################################

@ECHO OFF
FOR /R %%G IN (*.flv) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.flv.mp*) DO (CALL :SUB_RENAME "%%G")
GOTO :eof

:SUB_VLC
SET _firstbit=%1
SET _qt="
CALL SET _newnm=%%_firstbit:%_qt%=%%
SET _commanm=%_newnm:,=_COMMA_%
REM echo %_commanm%
CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{acodec="mp3",ab="512","channels=2"}:standard{access="file",mux="raw",dst="%_commanm%.mp3"} vlc://quit
GOTO :eof

:SUB_RENAME
SET _origfnm=%1
SET _endbit=%_origfnm:*.flv=%
CALL SET _newfilenm=%%_origfnm:.flv%_endbit%=.mp3%%
SET _newfilenm=%_newfilenm:_COMMA_=,%
COPY %1 %_newfilenm%
DEL %1
GOTO :eof

:eof


This is the original code, it might be easier to copy.  Remember to change m4a to flv if using the linked code.


If you already have all of the software, it isan easy 2 step process. 1: download all the videos you want. 2: run the bat file.

No comments:

Post a Comment