batch file example
© 2012 by KV5R. Rev. August 23, 2012.
In this article, we’ll explore creating and using batch files and command-line A/V processing utilities to post-process the audio tracks of videos.
Recently, I decided to start producing videos with better audio. The audio quality of the microphones in modern cameras and camcorders is surprisingly poor, and to add to the problem, most consumer-grade cameras have built-in audio filtering to reduce wind and handling noise. The result is crappy, tinny audio that sounds like a cheap cordless phone. Adding an external mic may slightly improve some cameras, but you still have that infernal internal filter. I found myself spending hours separating the video and audio tracks in my video editor (PowerDirector), trying to improve the audio equalization and get a more professional sound. But it was just way too slow! And once you edit your audio track in a video editor, it becomes a separate audio file that slows down seeking and editing. I wanted a way to batch-process video files by demuxing, processing the audio, and then remuxing, all without any re-compressing of the video and loss of quality.
The solution is to collect a bunch of audio/video processing utilities and then make a batch file to run them with all their wacky command-line options to post-process them before any video editing begins. So I spent a couple hundred hours finding the right utilities and learning how to use them. The core of the process is a command-line tool called SoX — Sound eXchange — a neato digital audio processing tool that allows you to build a virtual audio processing studio, complete with pro-quality companding, equalizing, filtering, reverb, and more. Once SoX is mastered, the remaining tasks are (1) demuxing video, (2) convert the audio track to WAV, (3) process with SoX, (4) re-encode the processed audio, then (5) remux the audio back into the original video. The end result is astounding—I can now make my home videos sound like they were sent off to an expensive post-processing service! And once the batch file is all set up and properly adjusted, it’s just a matter of running it against a new video and poof! in a few seconds the video has a nicely processed audio track. Even better, it’s a simple matter to copy and rename the batch file many times for various purposes. I now have a tailored batch file to post-process the audio for every camera and mic that I own.In addition to audio processing, you can also sync your video and audio, if needed, by adding a simple delay command to the remux process. This means you don’t have to split them in the video editor, move the audio a few frames, then work with separated tracks. If you do all your audio processing and synchronizing on your source files, it saves many, many hours of fiddling with them in the video editor, and you can focus on just slicing and dicing the video.
Start With Decent Audio
Most of the videos I see on YouTube have terrible audio (including some of my early productions). The mic is all mid-range and too far away, the room acoustics are evident, and background noise like fans and such tend to make audio that’s hard to improve. When making a video with voice in it, take at least these basic steps:
- Don’t use the webcam or camera mic. Get a decent lavaliere and clip it on your shirt. I am now using the Sony ECM-CS3, a stereo lav mic of decent quality for about $15. Not pro equipment, but 100x better than a webcam mic. Don’t put it right on your throat — 2–4 inches down your lapel is much better.
- Don’t use a headset/boom mic. These are fine for your phone, but, unless you buy a pro-audio headset for hundreds of dollars, they have too much “presence” and mouth/nose noise. The lav mic on the shirt is much more natural-sounding—close enough, but not too far away…
- Kill all your background noise. This includes fans, air conditioners, and music. You can’t post-process your voice into good audio if there is more than about -40dB of background noise. Really. If you want background music, add it to the video in post-production, not during voice recording.
- Use the highest quality audio settings your computer supports. I now use 96 kHz sample rate and 384 kbps for recording audio. This gets re-processed and re-compressed and re-sampled during the production, so starting with as good as you can get is the thing to do. It really does make a difference in the end.
- Don’t use crappy cords. I’m continually amazed to see how many “good quality” audio extensions add hum, hiss, whine, RF, and sundry crap to my audio, often outside the range of hearing, but it’s there in the file to make you a clipping mess in post-production. Sure, you can digitally filter it out, but in doing so you also damage your desired audio to some extent.
The point is: make your original audio as good and clean as you can get it, then you have much more room to improve it with audio processing.
First, let’s get one thing straight: if you are afraid of the command line and editing batch files, you need to go and try to find some GUI tool that will do the job for you. I don’t like any of them, because they all force you to work they way the GUI’s author wants. But with command-line tools and batch files, you have complete freedom to design your audio post-processing workshop to work the way you want to work. However, it does have one drawback: you don’t get real-time feedback—you have to make an adjustment, re-process the audio, then play it and evaluate your changes, many times, before it’s satisfactory. So it’s important to set up a proper and efficient work-flow.
Lay out your workspace something like this:
- Find and use a good file manager, something better and more efficient than Windows Explorer. I recommend Total Commander.
- Set up a utility folder and put it in your system PATH, so you can run your tools from any folder without typing a bunch of long path-names.
- Set up a working folder for your video. Don’t mix up your video/audio files with your tools, it’s just too messy.
- Set up a command window and change its defaults to be nice and big—you really do not have to work in a 80x24 character window! Make it like 200x60, and give it a giant scroll-back buffer like 1000 lines (so you can see what your tools did and how much distortion they encountered). Finally, give it is a nice big modern typeface like Consolas at 16 points, in a bright yellow on a black background.
- Use a good text editor (like NP++ or better) to edit your batch file. Editing the batch file is how you control the whole process—it’s the user interface—and you don’t want spend any serious time in some limited crap like notepad!
- Use a good sound system on your computer. There’t no way you can improve your video’s audio if you are setting it by listening to some cheapo computer speakers. Either get some some good studio-type headphones, or invest in a good sound system for your computer. You don't need studio reference monitors, but at least get a small stereo amp and a set of decent bookshelf speakers. You can see what I’m using in the video below.
- Use your batch file to load your tailored audio into Audacity and/or some graphical tool that shows you the waveform and spectrum. Use both your ears and eyes to tailor the audio. SoX can output a spectrum in PNG form, so after you normalize, compand, and equalize, tell SoX to make the spectrum, then tell IrfanView (or some graphics viewer) to run it. Let it run multiple instances, you can compare your latest change with earlier settings.
When using several programs to do one task, it’s important to learn to set them up properly then cycle through them as you work. This is even more important when some of the tools are command-line utilities. Here is they way I use these batch files:
- Open the batch file in the editor
- Set up a working folder for the video
- Open a command window in the video’s folder
- Demux the video
- Process the audio
- Listen to it and look at the waveform and spectrum
- Edit and save the batch file
- Repeat 5-7 until the audio is satisfactory
- Remux the video and audio
- Clean up the temp files
- Close everything
- Start editing the video in PowerDirector
All this may sound too complex, but once you get it set up a use it a few times, you’ll see that it is preferable to processing your audio in your video editor, and the best part is that the next video (with similar bad audio) can be processed in seconds, since your batch file is all set up and adjusted for the task.
Understanding deciBels (dB)
The deciBel scale is a log base 10 function (10 log10) commonly used to represent power and amplitude ratios. In digital audio, we say that 0dB is our reference point, and that is just below clipping, where we are using the entire 8 or 16 bit numeric range. When adjusting a compander or equalizer, keep in mind that:
- 3dB ˜ ±2×
- 6dB ˜ ±4×
- 9dB ˜ ±8×
- 10dB = ±10×
- 20dB = ±100×
- 30dB = ±1000×
- Ref: Wikipedia deciBel article
In practical terms, it simply means that a ±1dB change around 3dB is a very small change, but a ±1dB change around 9dB is very large one. It does take a while to learn to think in terms of log10 instead of linear!
The Batch File
This is the hardest part to come by: getting the batch built and debugged, and figuring out all those confusing, complex command-line parameters used by the processing tools. But I have done the hard work for you, hence, this web page! So let’s get started. You may copy the batch file below and start experimenting with it, or just read it here.
:: KV5R's audio video fixer workshop batch file -- 8/23/2012 11:36:08 PM :: Long lines: enable soft word-wrap to read this file. :: DO NOT EDIT THIS FILE UNTIL YOU HAVE MADE A COPY! :: OVERVIEW: :: Is this gonna be too complicated? Not at all! :: It's modular, and each block of script is like a component in a chain. :: All you need do is (1) configure and tune each component, and (2) keep them connected! :: PURPOSE: (put your specifics here to remind you what this copy does and what it uses) :: 1. To compand and equalize Sony ECM-CS3 lav mic audio :: 2. Sync Logitech C920 mp4 files (delay audio 100-166 ms. (3-5 frames)) :: This file is to demux, correct audio and sync, and remux - NOT transcode. :: You can put HandbrakeCLI in if transcoding is needed. Use -a none in hb to make a video with no :: audio track, then output it's video to the remuxer section. :: This file is for processing mono and stereo -- I don't know what it would do with any kind :: of multi-channel-encoded audio like AC3 or Dolby Sourround/Digital, etc. :: INSTALLATION: :: 1. Locate and download all the command-line tools you will need. :: 2. Make a folder such as C:\utils and put this batch file all the command line tools in it. :: 3. Set your PATH system environment variable to include this new folder. :: a. Computer, Properties, Advanced System Settings, Advanced tab, Environment :: Variables button, System Variables, Path, Edit. :: b. Append a semicolon and your folder to the end of the existing PATH, e.g., :: ;c:\utils :: then reboot to make it take effect. :: 4. Read all below very carefully! Don't change things until you understand what they do. :: USAGE: :: This batch has branching so you can run sections of it. See the HELP section below. :: 1. Open a command prompt in the folder that contains your video file (like, C:\video\test). :: a. First time, you can click the control menu (up-left corner), choose both Defaults and Properties :: and set up the command window to a much larger size, large line buffer, better color, etc. :: b. This batch file makes no provisions for pathing outside the current working folder, :: except it will create a \Remux\ subfolder for the remuxed videos. :: 2. Open this batch file in a text editor. Editing this batch file is how you adjust audio settings. :: 3. First, run the batch like: this-bat-basename your-vid-basename demux. :: It will demux your file into video and audio tracks, and convert the audio to WAV. :: 4. Next, repeatedly run the batch like: this-bat-basename your-vid-basename audio. :: It will process the WAV file with SoX and play a clip, make a spectrogram, and if you set it, :: open the file in Audacity (or whatever) so you can look at the waveform. :: a. Make changes as needed to the companding and equalization parameters, and run it again. :: b. Repeat until the audio sounds right and is not clipping too much. :: 5. When the audio is good, run the batch like: this-bat-basename your-vid-basename remux. :: It will remux the video and audio files into a new one named like: \Remux\your-vid-remux.mp4. :: 6. You'll now have a remuxed a/v in the \Remux sub-folder, and several temp files. :: You can delete them manually or un-comment the del commands after the mux. :: NOTES: :: * If you have more videos to process, run the batch like: mybat myvideo all :: It will run all the way through demux, audio, and remux. :: * TO KEEP MULTIPLE SETTINGS simply COPY and REName this batch file, :: as many copies as needed for different purposes. :: * To batch-process a whole folder of videos, make another batch file with this in it: :: FOR /f "delims=" %%a IN ('dir /a-d /s /b *.mp4') DO CALL MicSony.bat "%%~na" all :: Explain it: :: /a-d : attribute = not a Directory (files only) :: /s : recurse Subdirectories (optional) - but be careful to not re-process remuxed files in \Remux! :: /b : dir in Bare format (no header/footer) :: %%~na : send just the base-name (no .ext) of the files in the list. :: This will (1) make a bare filename list in memory and (2) repeatedly call this bat file to process each one. :: * NOTE: If your filenames have spaces, you're gonna need to "quote" all %1's in here. :: If your working folder has spaces, you need to quote them, too. I prefer to just avoid spaces in filenames. :: TOOLS: (keep track of what you're using) (you'll need to search and download these): :: 1. MP4Box to de-mux the video :: 2. FAAD2 to de-mux the AAC audio track and convert it to WAV. :: 3. SoX for audio tailoring :: 4. Qaac to convert the tailored WAV to AAC :: (Faac is outdated; NeroAacEnc chokes MP4Creator; remuxers need an ADTS audio stream) :: 5. HandBrakeCLI for converting 13Mbps MJPEG/MOV to 3Mbps AVC/MP4 Profile High@L4.1, without audio track (if needed) :: 6. MP4Creator to re-mux (and sync tracks if needed) them into one mp4 file (requires apple app support be installed) :: You can also use MP4Box to remux, but MP4Creator has more options. :: KEEP'EM CONNECTED! When bypassing a stage, MAKE SURE to alter the extensions so the chain stays connected: :: TOOL WHAT INPUT OUTPUT :: MP4Box Extract video %1.mp4 (source) %1_track1.h264 (or whatever it finds in the source) :: MP4Box Extract audio %1.mp4 (source) %1_track2.aac (or whatever it finds in the source) :: FAAD Decode audio %1_track2.aac %1-in.wav :: SoX Normalizing %1-in.wav %1-b.wav :: SoX Companding %1-b.wav %1-a.wav :: SoX Equalizing %1-a.wav %1-a.wav (bounces betwixt a and b) or %1-OUT.wav :: SoX Hi/Lowpass %1-a.wav %1-a.wav or %1-OUT.wav (bounces once again, if enabled) :: SoX Reverb %1-a.wav %1-OUT.wav* :: *This is the final output of audio tailoring, and it feeds the re-encode to AAC. :: If you bypass an effect, set previous output to -out.wav. :: Play Play %1-out.wav plays sound (note: play.exe is just a copy of sox.exe) :: SoX Spectro %1-out.wav gins spectrogram %1-out.png (can open with any png viewer) :: SoX Review Waveform %1-out.wav run Audacity (or whatever) with %1-out.png :: HandbrakeCLI Transcode video %1.mp4 %1-no-audio.mp4 (only if you need to transcode video track) :: Qaac Encode audio %1-out.wav %1.aac (make sure qaac makes an ADTS aac or MP4Creator will bomb) :: MP4Creator Mux %1_track1.h264 %1-remux.mp4 :: MP4Creator Mux %1.aac %1-remux.mp4 :: ============================== START ========================================= :: You can clear your screen and scroll-back buffer, or not: :: @cls :: Branch the bat exec with 2nd command-line param: @IF "%1"=="" GOTO help @IF "%1"=="help" GOTO help @IF "%2"=="help" GOTO help @IF "%2"=="demux" GOTO demux @IF "%2"=="audio" GOTO audio @IF "%2"=="remux" GOTO remux :: another param is "all" which is scattered down through the file. :: with no 2nd param, it'll use a couple pauses where you can abort with Control-C. :demux @set prompt=demux:$g @echo -----------------------------------D E M U X---------------------------------- @echo MP4Box EXTRACTING video and audio... MP4Box.exe -raw 1 "%1.mp4" :: ^ extract video in native format (if is avc, ext will be .h264) MP4Box.exe -raw 2 "%1.mp4" :: ^ extract audio in native format (if is aac, ext will be .AAC; if raw pcm, then .RAW) :: if your vid has more than 2 tracks, add them here in similar manner. @echo. @echo --------------------------(for vids with aac audio)--------------------------- :: Convert to wav so we can process it several times w/o loss of quality faad %1_track2.aac -o %1-in.wav :: NOTE: Use EITHER ABOVE OR BELOW, not both :: @set prompt=sox:$g :: @echo -------------------(for pocket cameras with RAW PCM audio)-------------------- :: @echo SoX is CONVERTING to WAV and CORRECTING a slight DC offset... :: :: (the LZ-8 has a little dc shift to remove): :: sox -t raw -r 8000 -c 1 -e unsigned-integer -L -b 8 %1_track2.RAW %1-in.wav dcshift .075 :: :: type samprate chan encoding endian bits infile outfile (option) :: :: Use MediaInfo first to determine what's in your headerless PCM source file, if unknown. @IF "%2"=="demux" GOTO done :audio @echo. @set prompt=audio:$g @echo ----------------------------N O R M A L I Z I N G----------------------------- sox -D --norm=-1 %1-in.wav %1-b.wav :: -D: don't dither. --norm=: normalization: should be 0 or a bit under. @echo. @echo -------------------------------F I L T E R I N G------------------------------ :: Note: Use low/highpass for rumble/hiss. LP may also remove most DC bias. sox -D %1-b.wav %1-a.wav lowpass -2 15k sox -D %1-a.wav %1-b.wav highpass -1 15 :: poles: more poles = sharper filter ^ @echo. @echo -----------------------------C O M P A N D I N G------------------------------ sox -D %1-b.wav %1-a.wav compand 0.1,0.2 6:-35.1,-35,-15 -12 -90 0.2 :: ^1, ^2 ^3 ^4, ^5, ^6 ^7 ^8 ^9 :: 1: Attack time in sec - should be very fast, .1 to .3 sec :: 2: Decay time in sec - should be a little slower than attack, .2 to .5 sec :: 3: Soft-knee: compander transition smoothing, helps keep it from being too obvious :: 4: Noise gate threshhold: dB values below this are not processed. Good for removing fan noise, etc. :: 5: in-dB1: compress from this value to 0 into range of out-dB1 to 0. :: 6: out-dB1: if in-dB1 is -40 and out-dB1 is -20, the range of -40 to 0 is compressed into -20 to 0. :: 7: overall gain. Set this in conjunction with prior normalization setting to prevent clipping after eq. :: 8: initial level for compander to assume :: 9: time delay -- a look-ahead that makes the compander predictive instead of responsive :: NOTE: The settings I have here are good for voice, not music. :: ref: https://en.wikipedia.org/wiki/Dynamic_range_compression @echo. @echo -----------------------------E Q U A L I Z I N G------------------------------ @echo SoX EQUALIZING 10 BANDS... :: These settings for: Sony ECM-CS3 lav mic. :: Note: Any electret lav on the throat gonna need a little low bass and a sharp cut at throaty 250/500. :: Don't push the eq "smile" too hard -- you'll lose voice intelligibility. :: Just take the mud out of it -- and remember, you probably have better speakers than most users! ;-) :: infile outfile effect ctr bw dB sox -D %1-a.wav %1-b.wav equalizer 31 2o 3 sox -D %1-b.wav %1-a.wav equalizer 63 2o 9 sox -D %1-a.wav %1-b.wav equalizer 125 1o -1 sox -D %1-b.wav %1-a.wav equalizer 250 1o -9 sox -D %1-a.wav %1-b.wav equalizer 500 1o -6 sox -D %1-b.wav %1-a.wav equalizer 1k 1o -3 sox -D %1-a.wav %1-b.wav equalizer 2k 1o -1 sox -D %1-b.wav %1-a.wav equalizer 4k 1o 1 sox -D %1-a.wav %1-b.wav equalizer 8k 2o 5 sox -D %1-b.wav %1-OUT.wav equalizer 16k 2o 6 :: set the frequencies up at octaves^ ^and make bandwith 1-2 octaves wide :: See %1-OUT.wav above? That's the end of processing because I have bypassed reverb. :: To plug it in, just change "OUT" to "a" and uncomment the block below. :: @echo. :: @echo ----------------------------------R E V E R B--------------------------------- :: sox -D %1-a.wav %1-OUT.wav reverb 20 0 0 100 30 -9 :: 1. Reverberance % ^1 ^2 ^3 ^4 ^5 ^6 :: 2. Hi-Freq Damping % :: 3. Room Size % :: 4. Stereo Depth % :: 5. Pre-delay ms :: 6. Wet-gain dB ("wet" is what reverb adds; "dry" is the original audio) :: Note: 0 room size but 30ms pre-delay produces a nice stereo "spatial" image :: to improve mono and near-mono-stereo mic sources. :: DON'T OVER-DO REVERB: just the lightest touch is nice, any more is cheezy.. @IF "%2"=="all" GOTO jump @echo. @echo ----------------------------S P E C T R O G R A M----------------------------- @echo SoX is GENERATING SPECTROGRAM %1.png ... sox %1-out.wav -n remix 2 trim 15 60 spectrogram -z 100 -q 10 -o %1-out.png :: start^ ^length - set trim to spectro a clip. @START /MAX c:\"Program Files (x86)"\Irfanview\i_view32.exe %1-out.png @echo. @echo -------------------------R E V I E W W A V E F O R M------------------------ :: Might put a command here to pop it into Audacity, WaveEditor, or something. @START /MAX c:\"Program Files (x86)"\Audacity\audacity.exe %1-out.wav @echo. @echo -----------------------------------P L A Y------------------------------------ @echo SoX is PLAYING a CLIP of %1-out.wav... :: comment play if you don't wanna hear a clip right here: @play "%1-out.wav" trim 30 15 :: start^ ^length - set trim to play the clip. :: NOTE: "play.exe" is simply a copy of sox.exe. @IF "%2"=="audio" GOTO jump @set prompt=$p$g @echo. @echo ----P A U S E---P A U S E---P A U S E---P A U S E---P A U S E---P A U S E----- @echo CHECK for EXCESS CLIPPING above! (Under ~200 per minute is usually okay) @echo Ctrl-C to stop, or @pause :jump @IF "%2"=="audio" GOTO done :remux @echo. @set prompt=remux:$g @echo ------------------------------T R A C K D A T A----------------------------- mp4creator -list %1.mp4 @IF "%2"=="all" GOTO jump2 @IF "%2"=="remux" GOTO jump2 @echo. @set prompt=$p$g @echo ----P A U S E---P A U S E---P A U S E---P A U S E---P A U S E---P A U S E----- @echo About to MUX the files! @echo LOOK at the info and EDIT the the batch file if needed. Ctrl-C or @pause :jump2 @echo. @set prompt=remux:$g @echo ---------------------E N C O D I N G W A V T O A A C-------------------- qaac --delay -118 --adts %1-out.wav -o %1.aac :: ^^ ^^ this is for Logitech C920 webcam; remove if you don't need to sync. :: Convert the equalized wav to AAC :: mp4creator chokes unless the aac is ADTS! (transport stream) :: Qaac delay gives me perfect sync for the C920 which starts the video a bit after the audio. :: THE CORRECT offset (for C920 videos) APPEARS to be 2x the difference in video and audio length, :: as reported by mp4creator -list. :: Make a subdirectory for the output files (to prevent batch re-processing of output files): @IF NOT EXIST ".\Remux\" MD "Remux" :: Delete the output if it exists (because MP4Creater will not overwrite): @IF EXIST .\Remux\%1-remux.mp4 del .\Remux\%1-remux.mp4 @echo. @echo ----------------------------------R E M U X----------------------------------- @echo MP4Creator is writing out video track %1_track1.h264 to .\Remux\%1-remux.mp4... mp4creator -create="%1_track1.h264" -r 30 ".\Remux\%1-remux.mp4" :: set your frame rate^ (use MediaInfo to determine) @echo MP4Creator is Writing out modified audio track %1.aac to .\Remux\%1-remux.mp4... mp4creator -hint -optimize -create="%1.aac" ".\Remux\%1-remux.mp4" :: ^for web streaming/YT, put the MOOV at the front :: :: Do something like this if you wanna transcode the video: :: :: (I use this to convert 13,000 kbps mjpeg/mov Lumix camera files to 1500 kbps avc/mp4.) :: @echo. :: @set prompt=transcode:$g :: @echo ---------------T R A N S C O D I N G M J P E G T O A V C---------------- :: :: High@L4.1, all of AVC's fancy tricks on -- slow!: :: HandBrakeCLI.exe -i "%1.MOV" -o "%1-no-audio.MP4" -f mp4 -e x264 -b 1500 -r 30 --cfr --optimize --crop 0:0:0:0 --strict-anamorphic -a none -v 1 :: :: in out type encoder kbps frames const for stream don't do no audio :: :: Watch out for converting vids from 29.97 to 30.00 for vides with drop-frame timecode. HB might crap. :: :: Video bit-rates: for non-pro uses, 1500 for 480p, 4000 for 720p, and 6000 for 1080p is usually good enough. :: :: @echo. :: @set prompt=remux:$g :: @echo ----------------------------------R E M U X----------------------------------- :: @IF EXIST %1-remux.mov del %1-remux.mov :: @echo MP4Box is MUXING the VIDEO and AUDIO FILES into %1-remux.mp4... :: MP4Box.exe -keepall -add "%1-no-audio.mp4:fps=30.000" -add "%1.aac" -new ".\Remux\%1-remux.mp4" :: :: set to your source's exact frame rate^ (use MediaInfo to determine) :: Use this is you want it to cleanup ONLY when running in "all" mode: @IF "%2"=="remux" GOTO done @echo. @set prompt=cleanup:$g @echo --------------------------------C L E A N U P--------------------------------- :: NOTE: if you wanna review each stage, comment these out so they don't get deleted. :: Uncomment these for regular processing (not testing) and it'll clean up the temps, :: if you run “all” as the second parameter. IF EXIST %1_track1.* del %1_track1.* IF EXIST %1_track2.* del %1_track2.* IF EXIST %1.aac del %1.aac IF EXIST %1-in.wav del %1-in.wav IF EXIST %1-a.wav del %1-a.wav IF EXIST %1-b.wav del %1-b.wav IF EXIST %1-out.wav del %1-out.wav IF EXIST %1-no-audio.mp4 del %1-no-audio.mp4 @GOTO done :help @echo. @echo =================================== H E L P ================================== @echo Your utility folder must be in system PATH variable. @echo Run this bat from the folder containing your video file. @echo type: ThisBatBaseName YourMp4BaseName [2ndParameter] @echo i.e., myBat myVideo all @echo. @echo Their are SIX ways to branch the batch file from the command line with a 2nd parameter: @echo 1. no 2nd parameter : Runs the whole bat with pauses (Control-C to abort) @echo 2. 2nd parameter = all : Runs the whole bat and skips the pauses (normal operation) @echo 3. 2nd parameter = demux : Runs demux portion only (run it once) @echo 4. 2nd parameter = audio : Runs audio portion only (run repeatedly to adjust audio; no need to demux or remux now) @echo 5. 2nd parameter = remux : Runs remux portion only (run when done adjusting audio) @echo 6. 2nd parameter = help : shows this. Also shows help if no first parameter given. @echo. @echo For details, read the whole batch file! It's loaded with comments. @echo. :: It doesn't delete the temps unless you run ALL or REMUX, because DEMUX and AUDIO jumps here: :done @echo. @echo =================================== D O N E ================================== @set prompt=$p$g
You can see that it would be very easy to chop this file down to process audio only, or for other purposes. For example, to process mp3 files, you can use ffmpeg to convert to WAV, then SoX to process, then lame to re-encod to mp3. Or, to process WAV files only, simply name your WAV file SomeWav-in.wav and then run
ThisBat SomeWav-in audio and it will make SomeWav-OUT.wav for you, skipping the demux and remux.
I made this page because decent examples of using these command-line tools are very hard to find on-line.
To hear how this batch file sounds, see my audio review video, made with the Sony ECM-CS3 stereo lav mic and processed with the above batch file. If you shop carefully, you can put a nice sound system on your computer for under $75!
Better in 720p HD, full-screen, on good speakers…