一批污泥龄与正确的时间字幕制作视频 [英] Batch to Create video .srt Subtitles with right timing
问题描述
哦,孩子!我不知道,即使知道该怎么下手)所以,我有很多的视频的文件夹。我需要的是建立与这些影片的名称也不在意它们的长度创造.SRT格式字幕的字幕。
Oh boy! I don't know even know what to start with) So, I have a folder with a lot of videos. What I need is to create subtitles with the names of those videos also minding their length to create subtitles in .srt format.
我已经查找一些信息,并复制了一些code
I have already look up some info and copied some code
@echo off
set dirpath=%1
dir C:\FolderwithVideos /O:S /b /-p /o:gn > "C:\result.txt"
call replacer.bat result.txt ".mp4" ""
exit
因此,我得到这个在的Result.txt
As a result i got this in result.txt
videoname1
videoname2
videoname3
我需要的是让他们看起来像这样(当然最终的创造,结果.srt文件,。)
What I need is to make them look like this (And of course in the end to create .srt file with the result.)
1
00:00:0,000 --> 00:00:25,000
videoname1
2
00:00:25,000 --> 00:00:35,000
videoname2
3
00:00:35,000 --> 00:00:55,000
videoname3
希望我得到的一切,请大家帮忙!在此先感谢!
Hope I got everything, please help! Thanks in advance!
推荐答案
用VBS得到每个视频文件的视频长度(使用的 Folder.GetDetailsOf法)和之
的长度在污泥龄
文件定时器(使用的 FormatDateTime函数)。
Using VBS to get the video length of each video files (using Folder.GetDetailsOf method) and to sum
the lengths for the timers in the .srt
file (using the FormatDateTime Function).
该脚本获得的视频姓名与您的Result.txt文件(所以你必须包括在此您code BAT
或运行蝙蝠,那之前生成它。
This script get the name of the videos in your result.txt file (so you have to include your code in this BAT
or run the bat, that generate it, before.
我已经包括在我的code,但与 REM
之前。因此删除 REMS
如果需要的话。
I already include it in my code but with REM
before. So remove the REMs
if needed.
结果显示在CMD和文件以书面形式 Output.srt
(在BAT文件同一目录)
The result is displayed on the CMD and writing in the file Output.srt
(In the same directory of the BAT file)
BuildSrt.bat
BuildSrt.bat
@echo off&cls
::The Path of your Videos files
set "$VideoPath=C:\FolderwithVideos"
::If you want your Code in this BAT remove the REMs Below :
rem dir "%$VideoPath%" /O:S /b /-p /o:gn > "C:\result.txt"
rem call replacer.bat result.txt ".mp4" ""
setlocal enabledelayedexpansion
set /a $Count=1
set "$Timer=00:00:00"
(for /f "delims=" %%a in (result.txt) do (
call:getVideolength "%%a.mp4"
for /f "delims=" %%x in ('cscript //nologo getvideolength.vbs') do (
call:SumTime !$Timer! %%x
for /f "delims=" %%y in ('cscript //nologo SumTime.vbs') do set "$NewTimer=%%y"
echo !$Count!
echo !$Timer!,000 --^> !$NewTimer!,000
echo %%a
Set $Timer=!$NewTimer!
)
set /a $Count+=1
))>Output.srt
echo Done !!!
type Output.srt
pause
exit/b
:GetVideoLength
(echo dim objShell
echo dim objFolder
echo dim objFolderItem
echo set objShell = CreateObject("shell.application"^)
echo set objFolder = objShell.NameSpace("%$videoPath%"^)
echo set objFolderItem = objFolder.ParseName(%1^)
echo dim objInfo
echo objInfo = objFolder.GetDetailsOf(objFolderItem, 27^)
echo wscript.echo objinfo)>GetVideoLength.vbs
exit/b
:SumTime
echo wscript.echo FormatDateTime(CDate("%1"^) + CDate("%2"^),3^) >SumTime.vbs
exit/b
这将创建一个文件 Output.srt
是这样的:
This will create a file Output.srt
like this :
1
00:00:00,000 --> 01:28:28,000
Film1
2
01:28:28,000 --> 02:49:39,000
Film2
3
02:49:39,000 --> 04:45:25,000
Film3
这篇关于一批污泥龄与正确的时间字幕制作视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!