user3812737
user3812737

Reputation: 33

Create a bat file to exit FFMPEG (Windows)

Hello everyone I am using this bat file in order to capture my screen.

ffmpeg -f dshow -i video=screen-capture-recorder -r 240001001 -q 1 lma_recording.avi

When I press the q button the video capture stops.

However I would like to stop the screen capturing with another bat file.

I have tried this:

taskkill /im ffmpeg.exe

without luck

Any suggestions?

Upvotes: 3

Views: 5918

Answers (4)

Juraj
Juraj

Reputation: 61

Note: You must use other output format than .mp4 as this will lead to a corrupted file. You can try with .mkv or .avi and then convert it if want.

taskkill /im ffmpeg.exe /t /f

The answer by nephi12 works, but depending on the codec/container used for capture.

Capture to .avi works fine with this. I usually capture h264 video to .mkv container, kill it with this command, then re-encode it to whatever I need.

On the other hand, for example capturing h264 video to .mp4 won't work, I believe because the kill command won't let ffmpeg write moov atom after capture end, and the file becomes unusable.

Upvotes: 3

John Raines
John Raines

Reputation: 1

Give your command window a unique title by adding this line before the call to FFmpeg:

title My Window Title

Then you can terminate it cleanly with taskkill.exe:

taskkill /fi "windowtitle eq My Window Title"

Upvotes: 0

Carlos Cuesta
Carlos Cuesta

Reputation: 1484

You can stop the recording sending the Ctrl-c signal to ffmpeg.exe with the SendSignal utility command, available at : https://github.com/AutoSQA/SendSignal

Once downloaded and selected your version (x86, x64) you can use it in this way:

sendsignal ffmpeg.exe

Hope this helps!!!

Upvotes: 6

cure
cure

Reputation: 2688

what is screen capture recorder? is it an alternate executable's output? (im not familiar with ffmpeg) also, try this:

taskkill /im ffmpeg.exe /t /f

/f forces kill, and /t kills child processes too.

Upvotes: 2

Related Questions