标题: [已解决-有请领钱的哥们处理一下新的bug-英文错误]批量调整字幕的时间 [打印本页]
作者: hhl1010 时间: 2024-5-17 14:06 标题: [已解决-有请领钱的哥们处理一下新的bug-英文错误]批量调整字幕的时间
本帖最后由 hhl1010 于 2024-5-18 19:48 编辑
具体报酬:50元人民币。
支付方式:支付宝,微信
具体要求:1)将srt字幕 拖入批处理执行 执行完保存覆盖原文件
2)除了开头将字幕时间归零,其他时间戳取余一律取整为 00 20 40 60 80,并且将第一条字幕末尾取余的时间直接覆盖到第二条字幕的开头
联系方式:站内联系 支付以第一个达到完成度需求的用户为准,后续者不算
有效期限:已解决
举个例子
-------------------------------------------------------------
1
00:00:00,021 --> 00:00:00,963
打了二十年
2
00:00:00,969 --> 00:00:03,615
房产官司最多的是动迁纠纷
3
00:00:03,619 --> 00:00:05,188
动迁纠纷当中
----------------------------------------------------------------
经过批处理调整为
----------------------------------------------------------------
1
00:00:00,000 --> 00:00:00,960
打了二十年
2
00:00:00,960 --> 00:00:03,620
房产官司最多的是动迁纠纷
3
00:00:03,620 --> 00:00:05,180
动迁纠纷当中
-------------------------------------------------------------
附件为字幕测试文件
链接:https://pan.baidu.com/s/1s7TOG8lHquYxtZwpv7x7WA?pwd=88bs
提取码:88bs
作者: buyiyang 时间: 2024-5-17 16:51
将bat脚本保存为UTF8编码,保证srt文件名规则- @echo off
- chcp 65001
- set "initialtamp=00:00:00,000"
- set "arrow=-->"
- set /a point=15
-
- setlocal EnableDelayedExpansion
- for %%i in (%*) do (
- (for /f "skip=2 tokens=1-4 delims=] " %%a in ('find /v /n "" %%i') do (
- echo,"%%c"|find /i "!arrow!" >nul&&(
- call :mod "%%b" "%%d" timetamp
- set "mark=1"
- echo,!timetamp!)||(
- echo,%%b%%c%%d)
- ))>%%i.temp
- move /y "%%~i.temp" %%i
- set "initialtamp=!tamp2!"
- set "mark="
- )
- pause&exit
-
- :mod
- if not defined mark (
- set "tamp1=!initialtamp!") else (
- for /f "tokens=1-2 delims=," %%x in (%1) do (
- for /f "tokens=* delims=0" %%i in ("%%y") do (
- set /a quotient=%%i/20,remainder=%%i%%20
- if !remainder! gtr !point! set /a quotient+=1
- set /a round=quotient*20+1000
- )
- set "tamp1=%%x,!round:~1!"
- )
- )
- for /f "tokens=1-2 delims=," %%x in (%2) do (
- for /f "tokens=* delims=0" %%i in ("%%y") do (
- set /a quotient=%%i/20,remainder=%%i%%20
- if !remainder! geq !point! set /a quotient+=1
- set /a round=quotient*20+1000
- )
- set "tamp2=%%x,!round:~1!"
- )
- set "%3=!tamp1! !arrow! !tamp2!"
复制代码
作者: zaqmlp 时间: 2024-5-17 17:28
- <# :
- cls&echo off&cd /d "%~dp0"
- path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
- set "tmpfile=%tmp%\t.t"
- setlocal enabledelayedexpansion
- >"%tmpfile%" echo;!cmdcmdline!
- endlocal
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- function exc($t){
- $tt=[int]('1'+$t);
- $n=-1;$nn='';
- $zrr=@(100,120,140,160,180);
- for($i=0;$i -lt $zrr.length;$i++){
- $m=[Math]::Abs($zrr[$i] -$tt);
- if($n -eq -1){
- $n =$m;$nn =$zrr[$i].toString();
- }else{
- if($m -lt $n){
- $n =$m;$nn =$zrr[$i].toString();
- }
- }
- }
- return $nn.Substring(1);
- }
-
- $text=[IO.File]::ReadAllText(($env:tmpfile), [Text.Encoding]::GetEncoding('GB2312'));
- $files=($text.trim() -replace '^.+?\.(cmd|bat)" ','').replace('"','') -split ' (?=[a-z]:)';
- $enc=New-Object System.Text.UTF8Encoding $False;
- for($i=0;$i -lt $files.length;$i++){
- write-host $files[$i];
- $arr=New-Object -TypeName System.Collections.ArrayList;$flag=@(1,'');
- $text=[IO.File]::ReadAllLines($files[$i], $enc);
- for($j=0;$j -lt $text.count;$j++){
- $line=$text[$j].trim();
- $m=[regex]::match($line, '(\d+:\d+:\d+,)(\d\d\d)( ?--> ?\d+:\d+:\d+,)(\d\d\d)');
- if($m.success){
- $ts='';
- $a=$m.groups[2].value.Substring(0,1)+(exc $m.groups[2].value.Substring(1,2));
- $b=$m.groups[4].value.Substring(0,1)+(exc $m.groups[4].value.Substring(1,2));
- if($flag[0] -eq 1){
- $ts=$m.groups[1].value+'000'+$m.groups[3].value+$b;
- }else{
- $ts=$m.groups[1].value+$flag[1]+$m.groups[3].value+$b;
- }
- $flag[1]=$b;$flag[0]++;
- [void]$arr.add($ts);
- }else{
- [void]$arr.add($text[$j]);
- }
- }
- [IO.File]::WriteAllLines($files[$i], ($arr -join "`r`n"), $enc);
- }
复制代码
作者: hhl1010 时间: 2024-5-17 19:10
将bat脚本保存为UTF8编码,保证srt文件名规则
buyiyang 发表于 2024-5-17 16:51
验收通过,支付宝号码是多少?
作者: buyiyang 时间: 2024-5-17 19:27
回复 4# hhl1010
收款码https://pan.baidu.com/s/1_ke6W5X5pFjEFXlERJgedA?pwd=s6yb
作者: 77七 时间: 2024-5-17 19:33
- @echo off
- rem 批处理保存为utf-8编码格式
- chcp 65001 >nul
- set t1=00:00:00,000
- (for /f "tokens=1* delims=[]" %%i in ('find /n /v "" ^<"%~1"') do (
- if "%%j" neq "" (
- for /f "tokens=1-3" %%x in ("%%j") do (
- if "%%y" equ "-->" (
- setlocal enabledelayedexpansion
- for /f "tokens=1-4 delims=:," %%a in ("%%z") do (
- set /a "t2ms=((1%%a%%100*60+1%%b%%100)*60+1%%c%%100)*1000+1%%d%%1000,p=t2ms%%100%%20"
- if !p! leq 10 (
- set /a t2ms-=p
- ) else (
- set /a t2ms+=20-p
- )
- )
- set /a "h=t2ms/1000/60/60+100,m=t2ms/1000/60%%60+100,s=t2ms/1000%%60+100,ms=t2ms%%1000+1000"
- set t2=!h:~1!:!m:~1!:!s:~1!,!ms:~1!
- echo !t1! --^> !t2!
- for /f "delims=" %%t in ("!t2!") do (
- endlocal
- set t1=%%t
- )
- ) else (
- echo=%%j
- )
- )
- ) else (
- echo=
- )
- ))>$
- move $ "%~1"
- pause
复制代码
作者: hhl1010 时间: 2024-5-17 20:54
回复 hhl1010
收款码
buyiyang 发表于 2024-5-17 19:27
已经支付 请查收
作者: hhl1010 时间: 2024-5-18 00:21
本帖最后由 hhl1010 于 2024-5-18 00:28 编辑
回复 2# buyiyang
你好还是有问题
字幕覆盖不完整
比如前一个字幕的最后时间码没有覆盖到后一个上面去,字幕一长就会发生这个问题
有劳调整检查下
案例如下 这个是经过你这个批处理后产生的效果 虽然单纯的取整了 但是没覆盖到后一条
-----------------------------------------
9
00:00:11,280 --> 00:00:13,020
非常爽快的就答应了
10
00:00:13,040 --> 00:00:13,740
及时救场
11
00:00:13,760 --> 00:00:15,340
当时她都不知道我们是一个
12
00:00:15,360 --> 00:00:16,480
电视节目
13
00:00:16,480 --> 00:00:17,800
一开场直接就炸了
--------------------------------------------
及时救场和电视节目这两句字幕非编上都和前一句有空白间隙产生
麻烦解决一下这个bug
链接:https://pan.baidu.com/s/1sJVOGFOSuyDGS33a_Y8BOQ?pwd=daqc
提取码:daqc
--来自百度网盘超级会员V9的分享
作者: buyiyang 时间: 2024-5-18 00:57
本帖最后由 buyiyang 于 2024-5-18 00:58 编辑
不要意思,之前把“将第一条字幕末尾取余的时间直接覆盖到第二条字幕的开头”理解成了“将第一个字幕文件末尾取余的时间直接覆盖到第二个字幕文件的开头”了。可以批量拖放处理- @echo off
- chcp 65001>nul
- set "initialtamp=00:00:00,000"
- set "arrow=-->"
- set /a point=11
-
- setlocal EnableDelayedExpansion
- for %%i in (%*) do (
- echo,%%i
- (for /f "skip=2 tokens=1-4 delims=] " %%a in ('find /v /n "" %%i') do (
- if not "%%d"=="" (
- call :mod "%%d" timetamp
- set "mark=1"
- echo,!timetamp!) else (
- echo,%%b%%c%%d)
- ))>"%%~i.temp"
- move /y "%%~i.temp" %%i
- set "mark="
- )
- pause&exit
-
- :mod
- if not defined mark (set "tamp1=!initialtamp!") else (set "tamp1=!tamp2!")
- for /f "tokens=1-2 delims=," %%x in (%1) do (
- for /f "tokens=* delims=0" %%i in ("%%y") do (
- set /a quotient=%%i/20,remainder=%%i%%20
- if !remainder! geq !point! set /a quotient+=1
- set /a round=quotient*20+1000
- )
- set "tamp2=%%x,!round:~1!"
- )
- set "%2=!tamp1! !arrow! !tamp2!"
复制代码
作者: hhl1010 时间: 2024-5-18 19:50
本帖最后由 hhl1010 于 2024-5-18 19:52 编辑
不要意思,之前把“将第一条字幕末尾取余的时间直接覆盖到第二条字幕的开头”理解成了“将第一个字幕文件末 ...
buyiyang 发表于 2024-5-18 00:57
哥们您好 这段代码 处理一些英文字幕的时候还是有错误
--------------------------------------------------------
25
00:00:31,740 --> 00:00:33,420
中间所差的那些事情
26
00:00:33,420 --> 00:00:34,200
To do list
27
00:00:34,201 --> 00:00:35,839
一条一条的写下来
--------------------------------------------------------
bat代码处理过以后就变成
-------------------------------------------------------
25
00:00:00,000 --> 00:00:33,420
中间所差的那些事情
26
00:00:33,420 --> 00:00:34,200
00:00:34,200 --> list,200
27
list,200 --> 00:00:35,840
一条一条的写下来
--------------------------------------------------
有劳兄弟修复一下
链接:https://pan.baidu.com/s/11drlPi7XQs9O1RzDfYSsjQ?pwd=7uez
提取码:7uez
--来自百度网盘超级会员V9的分享
作者: buyiyang 时间: 2024-5-18 21:12
- @echo off
- chcp 65001>nul
- set "initialtamp=00:00:00,000"
- set "arrow=-->"
- set /a point=11
-
- setlocal EnableDelayedExpansion
- for %%i in (%*) do (
- echo,%%i
- (for /f "skip=2 tokens=1-4* delims=] " %%a in ('find /v /n "" %%i') do (
- if "%%c"=="!arrow!" (
- call :mod "%%d" timetamp
- set "mark=1"
- echo,!timetamp!) else (
- echo,%%b %%c %%d %%e)
- ))>"%%~i.temp"
- move /y "%%~i.temp" %%i
- set "mark="
- )
- pause&exit
-
- :mod
- if not defined mark (set "tamp1=!initialtamp!") else (set "tamp1=!tamp2!")
- for /f "tokens=1-2 delims=," %%x in (%1) do (
- for /f "tokens=* delims=0" %%i in ("%%y") do (
- set /a quotient=%%i/20,remainder=%%i%%20
- if !remainder! geq !point! set /a quotient+=1
- set /a round=quotient*20+1000
- )
- set "tamp2=%%x,!round:~1!"
- )
- set "%2=!tamp1! !arrow! !tamp2!"
复制代码
回复 10# hhl1010
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |