Profile picture for user admin_romcom

A few months ago I’ve faced up with a task converting audio track in video file to another format in Windows. There are not much simple programs to do this task. The task is simple: convert any audio track to mp3 without converting video track. All programs that were tested propose to convert video and audio track without any options to copy video stream. This case increase a time of converting a lot and was dismissed by default.

I decided to use ffmpeg program. In Linux it’s easy to write the converter script, but in Windows I never faced up with such task.

Task:

  • convert audio stream to mp3,
  • copy video stream,
  • script cmd for Windows
  • batch converter

 

@echo off

ECHO =========================

setlocal enabledelayedexpansion

set argCount=0
for %%x in (%*) do (
   set /A argCount+=1
   set "argVec[!argCount!]=%%~x"
   set "argFex[!argCount!]=%%~nxx"
)

echo Number of files to process: %argCount%

for /L %%i in (1,1,%argCount%) do (
  echo Processfile !argVec[%%i]!
  cmd /k C:\ffmpeg.exe -i "!argVec[%%i]!"  -c:v copy -c:a libmp3lame "C:\convert\!argFex[%%i]!"
  echo File saved at C:\convert\!argFex[%%i]! 
)

explorer.exe C:\convert

ECHO =========================

PAUSE

 

First loop check arguments and write them to array. In the second loop the call of ffmpeg initiated with needed parameters for converting video file.

At the end of the process folder with converted files opened.

https://gist.github.com/onesixromcom/61b98db3a6ed80d9fa826baf8e087169

Add new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed.
 o-o    o-O-o    0    o--o  o--o  
| \ | /| | | |
| O | o | O-o O-Oo
| / | | | | \
o-o o-O-o o-o-o o o o

Enter the code depicted in ASCII art style.