0

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"
ragnor
  • 15
  • 3

1 Answers1

1

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"
  • Thanks a lot, it works like a charm! – ragnor Nov 04 '20 at 08:12
  • Hm no, I correct it: weirdly, the size of the new ¨_¨ file is again the same as the original. However, it works using the code I pasted. – ragnor Nov 04 '20 at 13:03
  • OK, got it: -map 1 needed to be added: @echo off for %%f in (*.mp4) do ffmpeg -i "%%f" -i "%%~nf_1.mp4" -map 1 -map_metadata 0 -c copy "%%~nf_.mp4" – ragnor Nov 04 '20 at 13:04
  • @ragnor yeah, I'm sorry, I lost `-map 1` somewhere when tested line. – Баяр Гончикжапов Nov 04 '20 at 13:49
  • Apparently this doesn't copy Modification time. Anyone know how to copy all metadata (handlers included if possible)? – ragnor Nov 06 '20 at 11:06
  • A small update: handlers seem to work with the following: 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" But file data are still not changed. – ragnor Nov 06 '20 at 11:31