简体   繁体   中英

ffmpeg keep file creation and modification dates when encoding/resizing multiple videos

I have the following batch code (I'm on Windows 10) that resize all the videos in a folder. It keeps the origin media created date but it doesn't keep the File attributes Date created and Date modified dates after encoding. How do I add this to the code below?

for %%a in ("*.mp4") do ffmpeg -i "%%a" -map_metadata 0 -vf "scale=iw/4:ih/4" -c:v libx264 -c:a copy "..\%%~na.mp4"

I originally got the answer to your question from this post, which can also serve as a template because it worked for me last year: ffmpeg keep original file date?

Moreover, I created this for you below:

for %%a in ("*.mp4") do (
    "C:\Program Files\FFmpeg (LATEST)\ffmpeg.exe" -i "%%a" -map_metadata 0 -vf "scale=iw/4:ih/4" -c:v libx264 -c:a copy "..\%%~na.mp4"
    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"  ^(ls '..\%%~na.mp4'^).CreationTime = ^(ls '%%a'^).CreationTime
    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"  ^(ls '..\%%~na.mp4'^).LastWriteTime = ^(ls '%%a'^).LastWriteTime
    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"  ^(ls '..\%%~na.mp4'^).LastAccessTime = ^(ls '%%a'^).LastAccessTime
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM