多亏了用户mklement0的帮助,我得到了这个脚本,可以自动转换文件夹“ video_old”中的所有文件并将它们移至“ video_new”,同时保留原始文件名。原始帖子。
现在,我要删除容器中的黑条。我知道这里有“ cropdetect”,但是AFAIK必须手动将值解析为脚本。我应该在波纹管的ffmpeg执行中添加什么参数?
Get-ChildItem .\video_old -Filter *.mkv | ForEach-Object {
.\ffmpeg.exe -i $_.FullName -c:v libx265 -crf 18 ".\video_new\$($_.Name)"
}
ffmpeg -ss 90 -i input.mkv -vframes 10 -vf cropdetect -f null -
...
[Parsed_cropdetect_0 @ 0x220cdc0] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:215 t:0.215000 crop=1280:720:0:0
[Parsed_cropdetect_0 @ 0x220cdc0] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:257 t:0.257000 crop=1280:720:0:0
[Parsed_cropdetect_0 @ 0x220cdc0] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:299 t:0.299000 crop=1280:720:0:0
在此示例中,我们可以像这样应用过滤器:
ffmpeg -i input.mkv -vf crop=1280:720:0:0 -c:a copy output.mkv
现在我明白了,试试这个:
Get-ChildItem .\video_old -Filter *.mkv | ForEach-Object {
$exportPath=".\video_new\$($_.Name)"
#Export
.\ffmpeg.exe -i $_.FullName -c:v libx265 -crf 18 $exportPath
Write-Host "Exported file on $exportPath."
#Know where to cut
$results = .\ffmpeg.exe -ss 90 -i $exportPath -vframes 10 -vf cropdetect -f null - 2>&1
#Cut
if(($results | ? {$_ -match 'crop=\d{1,4}:\d[0-9]{1,4}:\d:\d'})){
Write-Host "The regular expression was matched, value $($Matches[0])."
.\ffmpeg.exe -i $exportPath -vf ($Matches[0]) -c:a copy ($exportPath.Replace($_.BaseName,"$($_.BaseName)_CUT"))
}else{
Write-Host "The regular expression was NOT matched. The line was '$($resultsParsed[0])'"
$results | Out-File .\resultsFromCropDetect.txt
}
}
我实际上没有测试的方法,但是基本上我正在运行第一个命令,告诉我要切割的位置,使用正则表达式,我只拉出那部分,然后将实际的切割导出到名为“ OriginalName_CUT”的新文件中。 mkv”。
让我知道如何进行修改。
经过长时间的尝试,我要求输出ffmpeg cropdetect的输出并在本地进行调试,从而简化了查找cropdetect匹配项的过程。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句