我在Win7中使用这个批处理来截断一堆mp4文件的开头6秒,创建新文件。它工作得很好,但输出文件的日期是新的。如何保留原始日期?但我不想重新编码 mp4 文件,因为它们太多了,太慢了。感谢任何回应。
对于 ("*.mp4") 中的 %%a 执行 ffmpeg -i "%%a"-ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"
最佳答案
您可以使用 PowerShell 更改文件日期:
powershell (Get-Item -LiteralPath 'out.mp4').CreationTime = (Get-Item -LiteralPath 'in.mkv').CreationTime
powershell (Get-Item -LiteralPath 'out.mp4').LastWriteTime = (Get-Item -LiteralPath 'in.mkv').LastWriteTime
powershell (Get-Item -LiteralPath 'out.mp4').LastAccessTime = (Get-Item -LiteralPath 'in.mkv').LastAccessTime
在您的情况下,它看起来像这样:
for %%a in ("*.mp4") do (
ffmpeg -i "%%a" -ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"
powershell ^(Get-Item -LiteralPath 'newfiles\%%~na.mp4'^).CreationTime = ^(Get-Item -LiteralPath '%%a'^).CreationTime
powershell ^(Get-Item -LiteralPath 'newfiles\%%~na.mp4'^).LastWriteTime = ^(Get-Item -LiteralPath '%%a'^).LastWriteTime
powershell ^(Get-Item -LiteralPath 'newfiles\%%~na.mp4'^).LastAccessTime = ^(Get-Item -LiteralPath '%%a'^).LastAccessTime
)
如果您的文件名/路径包含任何特殊字符,则需要 -LiteralPath
。
关于ffmpeg 保留原始文件日期吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54456493/