【问题标题】:ffmpeg keep original file date?ffmpeg 保留原始文件日期?
【发布时间】:2019-06-24 16:08:42
【问题描述】:

我在Win7中使用这个批处理来切断一堆mp4文件的开始6秒,创建新文件。它工作得很好,但输出文件的日期是新的。如何保留原始日期?但我不想重新编码 mp4 文件,只是太多了,太慢了。感谢任何回应。

for %%a in ("*.mp4") do ffmpeg -i "%%a" -ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"

【问题讨论】:

标签: ffmpeg autohotkey


【解决方案1】:

您可以使用powershell 更改文件日期:

powershell  (ls 'out.mp4').CreationTime = (ls 'in.mkv').CreationTime
powershell  (ls 'out.mp4').LastWriteTime = (ls 'in.mkv').LastWriteTime
powershell  (ls 'out.mp4').LastAccessTime = (ls 'in.mkv').LastAccessTime

在你的情况下,它看起来像这样:

for %%a in ("*.mp4") do (
    ffmpeg -i "%%a" -ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"
    powershell  ^(ls 'newfiles\%%~na.mp4'^).CreationTime = ^(ls ''%%a'^).CreationTime
    powershell  ^(ls 'newfiles\%%~na.mp4'^).LastWriteTime = ^(ls '%%a'^).LastWriteTime
    powershell  ^(ls 'newfiles\%%~na.mp4'^).LastAccessTime = ^(ls '%%a'^).LastAccessTime
)

【讨论】:

    【解决方案2】:

    感谢您的帮助,@mayudong,但我对 powershell 一无所知,无法理解。最后我通过 AHK 完成了:

    SetWorkingDir g:\
    
    #m::
    Loop, %A_WorkingDir%\*.mp4
    {
    	if( InStr(A_LoopFileName,"news")=1 or InStr(A_LoopFileName,"today")=1  ){
    		FileGetTime,mt,% A_LoopFileLongPath
    		runwait,ffmpeg -y -i "%A_LoopFileLongPath%" -ss 8 -vcodec copy -acodec copy "g:\+temp\%A_LoopFileName%"
    		FileSetTime,mt,g:\+temp\%A_LoopFileName%
    	}
    }
    return

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      • 2020-06-20
      相关资源
      最近更新 更多