2

I have this batch script running perfectly on Windows:

C:\ffmpeg\bin\ffmpeg -i http://ipaddress/stream -deinterlace -c:v libx264 -pix_fmt yuv420p -s 960x540 -preset superfast -vb 1200k -maxrate 1200k -r 30 -g 60 -bufsize 8000k  -c:a aac -b:a 64k -ar 44100 -ac 2 -f flv rtmp://ipaddress/live/

Sometimes ffmpeg crashes, how can I edit the batch script or what can i add to the batch file to restart the stream.

Thanks advance!

2 Answers 2

1

I don't know if the ffmpeg command can be restarted this way,
but I would limit the number of retries to avoid endless loops on fails:

@Echo off
Setlocal EnableDelayedExpansion
Set Retry=0
:loop
C:\ffmpeg\bin\ffmpeg.exe -i http://ipaddress/stream ^
  -deinterlace -c:v libx264 -pix_fmt yuv420p -s 960x540 -preset superfast ^
  -vb 1200k -maxrate 1200k -r 30 -g 60 -bufsize 8000k -c:a aac -b:a 64k ^
  -ar 44100 -ac 2 -f flv rtmp://ipaddress/live/ ^
  ||(Set /A "Retry+=1"&if !Retry! leq 3 Goto :loop)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much! How can i edit, if i need it endless?
The || is a conditional execution if the command fails. So if ffmpeg exits with an error you could change the last line to ``|| goto :loop`
0
@echo off
setlocal enabledelayedexpansion

REM Set the folder path containing the videos
set "input_folder=."
set "ffmpeg_path=C:\ffmpeg\bin\ffmpeg.exe"
REM Set the output folder path for the processed videos
set "output_folder=.\output"

REM Set the desired speed and volume adjustment
set "speed=0.2"
set "volume=0.2"

REM Create the output folder if it doesn't exist
if not exist "%output_folder%" mkdir "%output_folder%"

REM Loop through all video files in the input folder
for %%i in ("%input_folder%\*.mp4") do (
    REM Create the output file path with the same filename in the output folder
    set "output_file=%output_folder%\%%~nxi"

    REM Apply the speed and volume adjustments using FFmpeg
    %ffmpeg_path% -i "%%i" -vf "setpts=!speed!*PTS" -af "volume=!volume!" "!output_file!"
)

echo All videos processed successfully.
pause

1 Comment

You should add explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.