I have a ton of videos I need to convert from mp4 to wmv using ffmpeg and break up each file into 10 minute segments, but I am a total cmd scripting newb (in fact, I am a scripting newb :)
After spending six hours trying to find an answer, I thought I would bring it to you guys.
The code I have is working a little bit, but I need to be able to read data coming from the command line and send it back into the script for evaluation. I am not sure what code ffmpeg will spit out when it is done processing a video file (when the timestamp reaches an end), but this FOR loop just keeps on trying to create new file segments even though the video is over. This is what I saw when it tried to create a new file, so I think it might work to search for this:
frame= 0 fps=0.0 q=0.0 Lsize= 1kB time=00:00:00.00 bitrate=N/A
This is the code I have come up with so far (Don't laugh :)
@echo off
setlocal ENABLEEXTENSIONS
setlocal ENABLEDELAYEDEXPANSION
for %%a in ("*.mp4") do (
set hour=00
for /L %%i IN (1,1,10) do (
:Beginning
set /a start=%%i-1
set end=%%i
if !start! lss 10 set start=!start!0
if !end! lss 10 set end=!end!0
ffmpeg -ss !hour!:!start!:00 -i "%%a" -b:v 1500k -vcodec msmpeg4 -acodec wmav2 -t !hour!:!end!:00 "Converted\%%~na-!hour!-!start!-!end!.wmv"
if end==60 CALL :Increment
)
)
:Increment
set /a !hour!+1
set %%i=1
GOTO :Beginning
pause
Based on reading this thread was thinking something like this might go in the code, but not sure what to do with it:
set "dosstring=%*"
echo.!dosstring!|findstr /C:"frame= 0 fps=0.0 q=0.0 Lsize= 1kB time=00:00:00.00 bitrate=N/A" >nul 2>&1
Thanks so much for you help!