Файл ниже делает большую часть того, что я хочу, довольно хорошо. Тем не менее, формат времени, кажется, не совсем то, что я хочу. Я бы предпочел всегда получать время в ISO8601
(например, 20150930T012823Z) независимо от настройки времени на компьютере. Как это можно сделать?
@ECHO off
:: Check the Windows version
IF NOT "%OS%"=="Windows_NT" GOTO:OS
SETLOCAL
:: Initialize variable
SET Error=0
:: Check the command line arguments
IF "%~1"=="" GOTO Syntax
IF "%~2"=="" GOTO Syntax
IF "%~3"=="" GOTO Syntax
set v_barrier=%1
set v_rtspcommand=%2
set v_AccessCard=%3
set v_Pictures=%4
IF "%~4" =="" set v_Pictures=%PUBLIC%\Pictures
:: Keep variables local
SETLOCAL ENABLEDELAYEDEXPANSION
:: Checking if ffmpeg is properly installed as per setting in PATH
IF NOT EXIST "%ffmpeg%\ffmpeg.exe" (
ECHO ffmpeg.exe could not be found in %ffmpeg%
GOTO:EOF
)
VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 ECHO Unable to enable extensions
if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
set '%%a'=%%i
set '%%b'=%%j
set '%%c'=%%k))
if %'yy'% LSS 100 set 'yy'=20%'yy'%
set Today=%'yy'%-%'mm'%-%'dd'%
ENDLOCAL & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'%& SET /a last_year=%'yy'%-1
:: Time in ISO 8601 24-hour format
VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 ECHO Unable to enable extensions
for /f "tokens=1-4 delims=:,.-/ " %%i in ('echo %time%') do (
set 'hh'=%%i
set 'mm'=%%j
set 'ss'=%%k
set 'ff'=%%l)
ENDLOCAL & SET v_hour=%'hh'%& SET v_minute=%'mm'%& SET v_second=%'ss'%& SET v_fraction=%'ff'%
:: Barrier = I1-I9 (for Ingress) or E1-E9 (for Egress)
set output_path=%v_Pictures%\%v_barrier%%v_year%%v_month%
if not exist %output_path% mkdir %output_path%
:: Delete folder that is one year old
if exist %v_Pictures%\%v_barrier%%last_year%%v_month% rmdir /s /q %v_Pictures%\%v_barrier%%last_year%%v_month%
:: Ingress / Egress parrier:
IF %v_barrier% GEQ I0 IF %v_barrier% LEQ I99 GOTO:NEXT
IF %v_barrier% GEQ E0 IF %v_barrier% LEQ E99 GOTO:NEXT
GOTO:SYNTAX
:NEXT
set timestring=%v_barrier%%v_year%%v_month%%V_Day%T%v_hour%""%v_minute%%v_second%Z%v_AccessCard%
START "" "%ffmpeg%\ffmpeg" -rtsp_transport tcp -y -i %v_rtspcommand% -nostats -loglevel 0 -pix_fmt yuv420p -f image2 -
vframes 1 -ss 00:00:01.500 -s 1920x1200 %output_path%\%timestring%.jpg
GOTO:EOF
:SYNTAX
ECHO FFMPEGPIS.BAT - FFMPEG Photo Imaging System ver 1.1
ECHO Usage: FFMPEGPIS [ Ix or Ex, rtsp, Access Card, Picture folder ]
ECHO.
ECHO Where: "Ix or Ex" I = Ingress followed by integer 0-9
ECHO E = Egress followed by integer 0-9
ECHO.
ECHO "rtsp" command from camera (rtsp)
ECHO "Access Card" Short Range Access Card
ECHO "Picture Folder" If blank, %PUBLIC%\Pictures will be used
:OS
IF NOT "%OS%"=="Windows_NT" ECHO OS needs to be Windows NT 4 or higher
:EOF