Ffmpeg and BAT Automatic Conversion

Asked

Viewed 291 times

2

I am using ffmpeg to convert all videos from one folder to . mp4, and for that I have created one . bat to make the process, but, the problem that is next:

When it starts the conversion, it creates with same mone a file in format and extension . mp4.

It occurs, that if by chance the process is interrupted, it would remove the . mp4 file not yet finalized by conversion.

My . bat runs by the task scheduler, so for the next run, as the . bat was stopped, mine . bat interrupts execution by requesting my interaction on to confine the previously unfinished.mp4 file overwriting

I would like it to just create the other.MP4 file when the conversion process finishes uninterrupted, someone can help me with this script?

Follow the ultimalized code:


for /r %%F in (*.avi *.rmvb *.flv *.mov *.avi *.ts) do (
    ffmpeg.exe  -i "%%F"  -preset ultrafast "%%~dpnF.mp4"
    if not errorlevel 1 if exist   "%%~dpnF.mp4" del /q "%%F"
)
  • For a more "verbose" output, remove the -v error -stats -vn .

1 answer

3


inserir a descrição da imagem aqui

  • Update Opera recursively in conversion

You can use a for in a looping with the complement -y together with the operator &&, that will work like this:


executa_sem_erro && então_execute_esse_porque_anterior_não_retornou_erro
executa_com_erro || então_execute_esse_porque_anterior_retornou_erro

Note that the complement -y will inform the ffmpeg to execute actions overwriting destination/output file if existing, thus no future confirmations are required on scheduled execution.



@echo off && cd /d "%~dp0" & color 0a 

rem :: edite comandos baixo adicionando caminho completo para pasta pertinentes e remova os "rem ::"
rem :: cd /d "drive:\pasta\sub_pasta\onde_tem_os_arquivos\videos"
rem :: set _ffmpeg=drive:\pasta\sub_pasta\onde_tem\bin\do\ffmpeg.exe"
rem :: como o ffmpeg esta na mesma pasta dos videos, set \_ffmpeg fica assim :: 

cd /d "drive:\pasta\sub_pasta\onde_tem_os_arquivos\videos" && set "_ffmpeg=.\ffmpeg.exe"

for %%F in (avi rmvb flv mov avi ts) do for /f "tokens=*delims= " %%c in ('dir /s /b "*.%%~F"')do (
     echo/ Origem_: "%%~c"
     echo/ Destino: "%%~dpnc.avi"
     !_ffmpeg! -y -i "%%~c" -preset ultrafast -v error -stats "%%~dpnc.mp4" && del "%%c" /q /f
     )

  • To stay in looping and if you already have window/ bat running, will check every second until not finding, then starts the conversions because the previous one has already ended
  • code without comments and looping awaiting previous execution...
@echo off && cd /d "%~dp0" & color 9f

title <nul & goto :^[ 

:^]
title Script Convert Running...

cd /d "drive:\pats_user\User\outra\pasta\video"

for %%F in (avi rmvb flv mov avi ts)do for /f "tokens=*delims= " %%c in ('dir /s /b "*.%%~F"')do (
     echo/ Origem_: "%%~c" && echo/ Destino: "%%~dpnc.mp4" 
     ffmpeg.exe -y -i "%%~c" -preset ultrafast -v error -stats "%%~dpnc.mp4" && del "%%c" /q /f
     echo/______________________________________________________________________________
     )

goto :^? 

:^[
%windir%\system32\tasklist /v |%windir%\system32\findstr.exe /lic:"Script Convert Running" >nul || goto :^] || %windir%\system32\tasklist\timeout /t 1 /nobreak & goto :^[

:^?
title <nul && exit /b

Browser other questions tagged

You are not signed in. Login or sign up in order to post.