ffmpeg 保留原始文件日期吗?

标签 ffmpeg autohotkey

我在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/

相关文章:

ffmpeg - 将选项传递给 ffprobe

video - 两个文件的ffmpeg concat导致格式错误的视频

powershell - Windows 11 级联 Windows : possible with e. g。 AutoHotkey,不适用于 VBScript 或 PowerShell

REGEX - 将非字母数字符号的任意组合折叠为单个 "."

带和不带花括号的 autohotkey if 语句

linux - 如何从 linux 系统在 windows 中运行 bat 文件

iphone - 如何从视频中提取方向信息?

ffmpeg - 将实时视频流保存到本地存储

python - PyArcade (Pyglet) python3 需要帮助

autohotkey - 图像搜索命令失败