Batch Copying All Metadata with Ffmpeg

Batch Copying All Metadata with Ffmpeg

I have been reencoding some old mp4 files and using ffmpeg to copy the metadata from the old files to the new ones using:

ffmpeg -i YDXJ0100.mp4 -i YDXJ0100_1.mp4 -map 1 -map_metadata 0 -c copy YDXJ0100_.mp4

Where the first file is the old version, _1 is the new one, and _.mp4 is the fixed one.

However, it is very time consuming to do it file by file. How could I write it in a way that it does it for every old file (but not all files)?

Update: This code works, except for the Modify data and other file timestamps:

for %%f in (*.mp4) do ffmpeg -i "%%f" -i "%%~nf_1.mp4" -map 1 -c copy -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a "%%~nf_.mp4"
2

1 Answer

batch file:

@echo off
for %%f in (*.mp4) do ffmpeg -i "%%f" -i "%%~nf_1.mp4" -map 1 -map_metadata 0 -c copy "%%~nf_.mp4"
6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.