📜 ⬆️ ⬇️

AviSynth + VirtualDub: Extract Audio from the Command Line

I somehow needed to extract audio from * .flv files. Graphic video editors seemed to me too unsuitable for this purpose, so I decided to write my own utility, which makes extracting sound from any media files, on the command line.
I used only open-source products.

So, what we need:


Step 1. Install the K-Lite Codec Pack, Virtual Dub and AVISynth.
')
Step 2. We write the following script in the BAT language of the cmd.exe command processor:

  @echo off
 @rem (C) danx
 set VD = VirtualDub.audio.
 echo VirtualDub.Open (VirtualDub.params [0], "", 0);  > 1.jobs
 echo% VD% SetSource (1);  >> 1.jobs
 echo% VD% SetMode (1);  >> 1.jobs
 echo% VD% SetInterleave (1,500,1,0,0);  >> 1.jobs
 echo% VD% SetClipMode (1,1);  >> 1.jobs
 echo% VD% SetConversion (44100,0,1,0,1);  >> 1.jobs
 echo% VD% SetVolume ();  >> 1.jobs
 echo% VD% SetCompression ();  >> 1.jobs
 echo% VD% EnableFilterGraph (0);  >> 1.jobs
 echo% VD% filters. Clear ();  >> 1.jobs
 echo VirtualDub.SaveWAV (VirtualDub.params [1]);  >> 1.jobs
 echo VirtualDub.Close ();  >> 1.jobs
 FOR %% i IN (*. *) Do (
   if not exist %% ~ ni.wav (
     echo.
     echo Re-compressing %% i
     echo c = DirectShowSource ^ ("%% i" ^)> 3.avs
     echo AudioDub ^ (BlankClip ^ (length = c.FrameCount ^), c ^) >> 3.avs
     "C: \ Program Files \ VirtulDub \ vdub.exe" / i 1.jobs 3.avs %% ~ ni.wav> nul
   )
 )
 del / q / s 3.avs> nul 2> & 1
 del / q / s 1.jobs> nul 2> & 1 



Step 3. Save this script as “extractaudio.bat” in one of the directories specified in the% PATH% environment variable.

Everything!

When you run this script in the directory in which the audio or video files are located, the script will extract mono WAV 44kHz audio from each such file, the file name will be the same as the source media file, and the extension will be WAV.

This code, for example, can pick out sound from 3GP video clips and FLV flash video.

Successes.

Source: https://habr.com/ru/post/127582/


All Articles