Search code examples
bashffmpegbatch-processing

How to batch process a directory of mp4 files to remove their metadata?


I convert one mp4 file using ffmpeg to remove all metadata from the mp4 file with the following command:

ffmpeg -i test.mp4 -map_metadata -1 -c:v copy -c:a copy out.mp4

This works fine but I want a bash script that will automatically remove all metadata of a directory containing mp4 files, with minimum interaction.

How can I do that?


Solution

  • for f in *.mp4; do ffmpeg -i "$f" -map_metadata -1 -c:v copy -c:a copy "fixed_$f"; done
    

    Bash replaces *.mp4 with names of all matching files in current directory. Each step the loop passes, f contains one of the file names.

    Or use a subdirectory:

    mkdir converted
    for f in *.mp4; do ffmpeg -i "$f" -map_metadata -1 -c:v copy -c:a copy "converted/$f"; done