Batch stripping MP3 from videos: A little help needed... :-)

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
DieselDragon
New Cone
New Cone
Posts: 2
Joined: 10 Nov 2010 17:46

Batch stripping MP3 from videos: A little help needed... :-)

Postby DieselDragon » 10 Nov 2010 18:31

Hi board! :-)
I've only recently started to use VLC both as a media player and converter, but I already understand the basics of how media files are encoded and "packaged" in container formats...Although my comprehension of encoding schemes themselves isn't that great. I'm currently struggling with trying to use VLC to batch job a load of FLV files into MPEG-3 audio, with all of my attempts so far resulting in seemingly valid MP3 files that still contain the video data...And of course, I'd like to get the filesize down to reasonable proportions!
FYI: I'm using VLC 1.1.4 for Win32, trying to batch-strip ~50 FLV files into reasonably sized (1MB/min) MP3 audio.

Anyhow...I'm currently using a modified version of the DOS batch script shown Here, and though I've been playing around with various command line parameters, nothing seems to have achieved what I've set out to do in a satisfactory manner.
I know that VLC can produce the output that I'm looking for, as converting files via the GUI (Using "Convert/Save") gives the kind of output that I'm looking for. However - Because the Convert/Save dialogue only seems to support one file at a time - I'm not that keen on the idea of sitting here and manually selecting and transcoding each individual file, especially as I want to reproduce this collection at four seperate bit/sampling rates. (~200 files once I'm done! :shock: )

The command likes that I've tried thus far are given below, along with their result. The input file in all cases is a 22.4MB FLV video (5:09 in length) with H264-MPEG-4 AVC video, and an MPEG AAC audio stream:
  • Code: Select all

    CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{acodec="mp3",ab="128",samplerate="44100","channels=2"}:standard{access="file",mux-audio="ps",dst="%_commanm%.mp3",select="novideo"} vlc://quit
    Output file is 22.2MB in size, registers as 24:15 long, and seems to split audio into chunks with long pauses in between.
    .
  • Code: Select all

    CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 :no-video --sout=#transcode{acodec="mp3",ab="128",samplerate="44100","channels=2"}:standard{access="file",mux=dummy,dst="%_commanm%.mp3"}
    Output file is 21.0MB in size, but otherwise is the same as above.
    .
  • Code: Select all

    CALL "C:\Program Files\VideoLAN\VLC\vlc" %1 :no-video :sout=#transcode{acodec=mp3,ab=128,samplerate=44100,channels=2}:std{access=file,mux=dummy,dst="%_commanm%.mp3"}
    Output file is 22.2MB in size and same as first attempt above. Encoding done in VLC GUI insted of console.
I've been tearing my hair out over this so far. Although I can grasp the concept of transcoding as a stream I/O process (Stream AAC to std out, then stream std out to file via an MP3 recorder) I just cannot seem to find the right command parameters to tell VLC to "Save only an MPEG-3 encoded audio stream with bit/sampling rates as specified to the output file, with no other gumpf added. :(

If someone could please give me a command string that would do the above as I'm trying to, then I would be most greatful! :D

Farewell for now, and many thanks in advance! :twisted:
+++ DieselDragon +++

DieselDragon
New Cone
New Cone
Posts: 2
Joined: 10 Nov 2010 17:46

Re: Batch stripping MP3 from videos: A little help needed...

Postby DieselDragon » 11 Nov 2010 03:18

'Ow do again!
Just a quick follow-up to say that I'd managed to find out how to do it myself, in the end. After having a further play around with the options in VLC, I discovered that the streaming wizard displays the command line that it'll pass to VLC.exe with all the relevant format and conversion options as selected for use in the stream.
A little bit of cutting and pasting later, and I'd managed to achieve the result that I was looking for. :cool:

Just in case anyone else runs into the same or a similar problem, here's the batch script that I'm now using for FLV --> MP3 transcoding jobs, as derived from the script Here. Simply copy it into the folder where your source *.FLV files are located and execute - The script and VLC should do the rest.

Code: Select all

@ECHO OFF REM ######################################################################## REM # A Windows XP cmd.com script to batch convert flv files to mp3. # REM # # REM # Created by DieselDragon on 10th Nov 2010CE, derived from a copyright # REM # (C) 2008CE work of Andrew Boden <boden@graduate.uwa.edu.au> found at # REM # http://wiki.videolan.org/How_to_Batch_Encode # REM # Changed, cited and redistributed under the GNU GPL as detailed below # 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 <http://www.gnu.org/licenses/>.# REM # # REM # Version 1.10 (Derivative - DieselDragon, November 2010CE) # REM # Uses VideoLAN VLC 1.1.4 (www.videolan.org) # REM # Gracefully handles commas and apostrophes in file names. # REM # Not aware of any other characters needing graceful handling. # REM # 128kbps encoding with 44100 sampling. # REM ######################################################################## 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% ECHO Transcoding %1 REM Here's where the actual transcoding/conversion happens. The next line REM fires off a command to VLC.exe with the relevant arguments: CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -v %1 :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access="file",mux=dummy,dst="%_commanm%.mp3"} vlc://quit REM Having no SLEEP-esque command, we have to trick DOS/Windows into pausing REM for a bit between encode ops - To give the host OS a chance to do what it REM needs to - Via clever use of the PING utility: REM (Thanks to http://www.computing.net/answers/programming/dos-command-for-wait-5-seconds/11192.html for the tip! :-) PING -n 1 -w 5000 1.1.1.1 > NUL 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 REM My own little addition to prevent the batch window from "vanishing" without REM trace at the end of execution, as if a critical error had occurred. PAUSE
That said; For some reason, this only seems to work with transcoding the audio in FLV files to 128kbps with a 44.1KHz sampling rate...When I tried to use the same script to create 256/384kbps versions at 48KHz, VLC was dumping out errors and creating zero-byte files. :roll:

Might anyone else know why higher encodings don't seem to work? I can't see any reason why the options ab=384,samplerate=48000 should cause an error on their own. Indeed, the same thing happens whenever I've tried to do the same thing using the conversion wizard as well, so I've got a feeling that there might be a bug or lack of higher bitrate support in VLCs MP3 library. :geek:

Farewell for now, and hope this helps someone else out there! :twisted:
+++ DieselDragon +++

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Batch stripping MP3 from videos: A little help needed...

Postby Jean-Baptiste Kempf » 11 Nov 2010 13:28

Thanks for the cool howto
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

robueno
New Cone
New Cone
Posts: 1
Joined: 30 Nov 2010 05:01

Re: Batch stripping MP3 from videos: A little help needed...

Postby robueno » 30 Nov 2010 05:31

Hi Dieseldragon,
Thanks for the information. This is exactly what I need. I have many educational videos (*.AVI) that I need to watch (or listen to) in order to prepare for a test, but I don't have the time to actually sit down and watch them. Yesterday I converted a few videos manually, one by one, into mp3 files that I can listen in my iPod (while working, driving, or in the Metro). 128 kbps is allright with me, the original audio quality is good enough and I can listen the speaker clearly. I followed these instructions (http://www.howtogeek.com/howto/2719/how ... -with-vlc/).

Unfortunately I'm too ignorant and you'll forgive me but I don't seem to understand how and where to save the script, with what extension, how to make the VLC media player to see it. I didn't understand what folder exactly to save the script (where the VLC program files are? or in the same folder where the source video *.AVI files are?)

I'd appreciate very much if you could explain further. That will save me a lot of time.
Thanks a lot.
Rob

Buddhahoon
New Cone
New Cone
Posts: 1
Joined: 17 Jan 2011 10:53

Re: Batch stripping MP3 from videos: A little help needed...

Postby Buddhahoon » 17 Jan 2011 11:02

@Rebueno
To make this script work all you have to do is open up notepad and paste the script. Then save it in the folder that contains all of the videos you want to batch convert and save the file as"whatever you want".bat then double click the file and the script will run. Also if you want to convert something other than flv to mp3, in my case mp4 to mp3. just change for ever instance flv to mp4. Im sure also this will work with any other video format. So in your case with the script pasted into your notepad, change all the .flv's you see to .avi.
@Dieseldragon Thanks for the script saved me alot of time!

CathyD
New Cone
New Cone
Posts: 1
Joined: 21 Jan 2011 18:23

Re: Batch stripping MP3 from videos: A little help needed...

Postby CathyD » 21 Jan 2011 18:27

I've used your script to convert an .flv (audio only) to .mp3, but it's cutting off the end of the audio file (the files I'm trying to process are audio files of single words only, so they're only a few seconds long). Is there some buffering going on, or how can I modify your script to make sure it converts the whole file?
Any suggestions gratefully received!

AKazak
Blank Cone
Blank Cone
Posts: 16
Joined: 05 May 2008 19:59

Re: Batch stripping MP3 from videos: A little help needed...

Postby AKazak » 23 Apr 2011 07:35

Please take my version of the script and use it on demand:

Code: Select all

@echo off setlocal enabledelayedexpansion :: Batch DVD to MP3 ripper. The script uses VLC :: :: cls rem echo %0&pause path=%CD%;%path% set "LogFile=%~n0" :: The same name as script itself if exist "%LogFile%" del /q "%LogFile%" rem echo %LogFile% &pause set /p TargetFolder="Please enter the name of the rip: " if exist "%TargetFolder%" rmdir /s /q "%TargetFolder%" mkdir "%TargetFolder%" rem echo %TargetFolder% &pause set /p Title="Please enter the number of the Title: " set /p FirstChapter="Please enter the number the first Chapter: " set /p LastChapter="Please enter the number the first Chapter: " set FileNumberWitdh=2 echo. for /l %%C in (%FirstChapter%,1,%LastChapter%) do ( set FileNumber=%%C call :ZeroLeftFill FileNumber !FileNumberWitdh! rem echo !FileNumber!&pause rem echo !CD!\!TargetFolder!\&pause echo Ripping Title !Title!, Chapter %%C to !CD!\!TargetFolder!\!FileNumber!.mp3 ... CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --qt-start-minimized dvd:///E:\@!Title!:%%C :sout=#transcode{vcodec=none,acodec=mp3,ab=320,channels=2,samplerate=44100}:standard{access="file",mux=dummy,dst="!CD!\!TargetFolder!\!FileNumber!.mp3"} vlc://quit echo Done^^! echo. ) echo All the work is done^^! echo. pause endlocal goto :eof ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :ZeroLeftFill :: Expand with zeroes on the left. :: Usage: :: call :StrLen NumberStringVariable DesiredNumberWidth :ZLFLoop set NumberString=%1 call set NumberString=%%%NumberString%%% call :StrLen %NumberString% CurrentLength if %CurrentLength% lss %2 ( set %1=0%NumberString% goto ZLFLoop ) set NumberString= set CurrentLength= goto :eof ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :StrLen :: String length calculation. :: Usage: :: call :StrLen String NameOfLengthVariable set #=%1 set %2=0 :SLCLoop if defined # ( set #=%#:~1% set /a %2 += 1 goto SLCLoop ) set #= goto :eof
P. S. Don't forget to adjust path to your VLC executable in the for loop.
:)

ptlinva
New Cone
New Cone
Posts: 1
Joined: 26 Apr 2011 04:04

Re: Batch stripping MP3 from videos: A little help needed...

Postby ptlinva » 26 Apr 2011 04:07

I used dieseldragon's batch file and it worked GREAT!

I converted my 1st three videos (from flv to mp3) manually from a video on utube using vlc.

Then it dawned on me how long this was going to take... Running the batch was PERFECT. In fact, the file sizes and quality were exactly the same as what I was coming up with.

Thank you DD! Definately saved me some time!

Your friend in Virginia

AMEN-RA
New Cone
New Cone
Posts: 1
Joined: 14 May 2011 05:29

Re: Batch stripping MP3 from videos: A little help needed...

Postby AMEN-RA » 14 May 2011 05:33

I keep getting message "the system cannot find the path specified" what am I doing?

dgrapov
New Cone
New Cone
Posts: 1
Joined: 28 May 2011 22:24

Re: Batch stripping MP3 from videos: A little help needed...

Postby dgrapov » 28 May 2011 22:31

Thank you for this code DieselDragon! You have saved me a great deal of time.

For anyone using windows 7, you need to change the file path from:

"C:\Program Files\VideoLAN\VLC\vlc"

to

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"

or where ever vlc.exe is.


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 4 guests