Windows 10, ffmpeg
I'm very new to ffmpeg so I can't figure this out. I'm trying to use a command to copy then convert all .MOD video files in a directory to .mp4 files and keep the original date that the .MOD file was created. I don't understand how to map the current file in the loop to the map_metadata option. This command works but doesn't maintain the metadata (taken from this post)
FOR /F "tokens=*" %G IN ('dir /b *.MOD') DO ffmpeg -i "%G" -acodec copy "%~nG.mp4"
I've tried including the map in the above command but get various errors, mostly "invalid input file index: 1". The commands below will copy and convert but the new .mp4 files don't have the original file date so I must be using map_metadata
incorrectly:
FOR /F "tokens=*" %G IN ('dir /b *.MOD') DO ffmpeg -i "%G" -acodec copy -map_metadata 0 "%~nG.mp4"
FOR /F "tokens=*" %G IN ('dir /b *.MOD') DO ffmpeg -i "%G" -map_metadata 0 -acodec copy "%~nG.mp4"
Any suggestions? Thanks
UPDATE
I got this with Powershell! (thanks to this post)
$oldvids = Get-ChildItem *.MOD -Recurse
foreach ($oldvid in $oldvids) {
$newvid = [io.path]::ChangeExtension($oldvid.LastWriteTime.toString("MMMddyyyy_HHmmss"), '.mp4')
ffmpeg.exe -i $oldvid.FullName -c:v libx264 -crf 18 -c:a aac -q:a 100 $newvid
}
input: MOV01E.MOD (Created date 4/1/2012 10:10 AM)
output: Apr012012_101005.mp4
ANOTHER UPDATE
The above command kind of works but I just realized all of the files are output to the root directory. I changed the command a bit but I'm not sure what's going on:
Get-ChildItem *.MOD -recurse | % {
$newvid = [io.path]::ChangeExtension($_.LastWriteTime.toString("MMMddyyyy_HHmmss"), '.mp4')
ffmpeg.exe -i $_.FullName -c:v libx264 -crf 50 -c:a aac -q:a 100 $newvid
}