分配的日期和时间,以输出文件
我的工作的ffmpeg
屏幕捕获和我wan't开始录制的启动,所以我需要让输出的视频文件的名称是不同的每次我开始记录我发现这个问题非常接近我需要什么,所以我结束了这个批处理文件中的命令:
i am working on ffmpeg
screen capture and i wan't it to start recording on start up, so i need to give the output video file a name that is different every time i start recording i did find this question very close to what i need, so i ended up with this commands in a batch file:
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/" %%a in ('time /t') do (set mytime=%%a%%b)
cd /d E:\ffmpeg\bin
ffmpeg -f dshow -i video="screen-capture-recorder"
-c:v libx264 -r 10 -crf 37 -pix_fmt yuv420p E:\%mydate%_%mytime%.flv
现在我得到一个错误的ffmpeg CMD:[NULL @ 0270d2c01]无法找到一个合适的输出格式'E:-04-2014_02:35
now i get an error in ffmpeg cmd: [NULL @ 0270d2c01] Unable to find a suitable output format for 'E:-04-2014_02:35'
E:-04-2014_02:35无效参数
E:-04-2014_02:35 Invalid argument
我知道这是因为数值指明MyTime
特殊字符:
,但我不知道如何去改变它。
i know it because the special characters in mytime
:
but i don't know how to change it.
**编辑,以独立的日期和时间 _
**edited to separate date and time with _
如果你只需要它唯一的文件名,周围不要乱用特殊字符和本地化的格式。您可以使用:
If you only need it for unique filenames, don't mess around with the special chars and localized format. You can use:
for /f "tokens=2 delims==" %%i in ('wmic os get localdatetime /value') do set DateTime=%%i
set DateTime=%DateTime:~0,8%_%DateTime:~8,6%
REM or: set filename=%DateTime:~0,8%_%DateTime:~8,6%.flv
echo %DateTime%
修改以问题的文件名是这样的20140204_161529我wan't它是这样的2014_02_04_16_15_29:使用这里面的为
循环:
EDIT to "the problem is the file name is like this 20140204_161529 and i wan't it to be like that 2014_02_04_16_15_29" : Use this inside the for
loop:
set oldfilename=%DateTime:~0,8%_%DateTime:~8,6%.flv
set newfilename=%DateTime:~0,4%_%DateTime:~4,2%_%DateTime:~6,2%_%DateTime:~8,2%_%DateTime:~10,2%_%DateTime:~12,2%.flv