How do I remove all metadata from a quicktime movie file?
Solution 1
Well, I have a command-line answer:
Note: This only works with the ffmpeg
included in Ubuntu by default: it will have a version similar to 0.8.1-4:0.8.1-0ubuntu1
; it WILL NOT work with any ffmpeg binaries you have installed from a third-party PPA or compiled yourself. Your mileage may vary.
- Install these:
sudo apt-get install ffmpeg libimage-exiftool-perl
- Then navigate to where your source .mov file is, we'll call it
test.mov
-
And run:
ffmpeg -i test.mov -map_metadata -1 -vcodec copy -acodec copy test-nometadata.mov
You can then use
exiftool
to check that it worked;exiftool test.mov
andexiftool test-nometadata.mov
should show you the difference.-
Here are my sample outputs from an old Nikon .mov with tons of metadata (pastebin'd):
- before - 80 metadata lines
- after - 52 metadata lines (even the create, modify etc.times have been nulled)
(note that the order in ffmpeg above is essential -- the input and output files must be specified at the very end)
Solution 2
NOTE: with a recent version of ffmpeg (and presumably avconv, but I haven't tested that), you can simply use:
ffmpeg -i input.mp4 -map 0 -map_metadata -1 -c copy output.mp4
Using -map_metadata -1
creates an empty 'dummy' metadata source. For the version of avconv in the repos, or other outdated versions, use the method described below.
Using avconv (or ffmpeg if that's your weapon of choice, the syntax is the same):
The easiest way to do this is to set -map_metadata
to use one of the input streams, rather than using global metadata. 99% of the time this should work.
avconv -i input.mp4 -map 0 -map_metadata 0:s:0 -c copy output.mp4
This will take the metadata from the first data stream (normally the video stream) and use that to replace the global metadata of the container file. This works because most of the time, the data streams have no meaningful metadata written to them; however, sometimes they do, and you want to completely get rid of that metadata. Unfortunately, the only way I can think of to do this used a pipe and two avconv processes.
avconv -i input.mp4 -f wav - | avconv -i - -i input.mp4 -map 1 -map_metadata 0 -c copy output.mp4
This takes advantage of the fact that WAV files can't contain metadata (since the format was created before metadata tags existed).
Both of these methods blanked all metadata on a file I just tested them on - all that exiftool
reported on was the codec information, and avprobe reported no metadata to me. Using a pipe for this is pretty ugly, and the first method will work in 99% of cases, so that should be preferred.
BONUS: to create a blanked version of every MP4 in a directory, and then replace the metadata versions with the blanked versions (warning - pretty much irreversible):
for f in *.mp4; do avconv -i "$f" -map 0 -map_metadata 0:s:0 -c copy "out.$f"; mv "out.$f" "$f"; done
Related videos on Youtube
John Baber-Lucero
Updated on September 18, 2022Comments
-
John Baber-Lucero over 1 year
My camera takes .mov files as movies. How can I remove all metadata from them so I can feel confident sharing them on youtube without accidentally sharing when/where they were filmed, what type of camera I have, etc. A command line one-liner is nice, but if it's too confusing, a GUI program would be better.
-
John Baber-Lucero almost 12 yearsI get this when I try to do as you've suggested.
-
ish almost 12 yearsThat's because you're using a non-standard
ffmpeg git-2012-05-13-a927641
, not the standard libav one from the official repos. My version is0.8.1-4:0.8.1-0ubuntu1
and works fine. -
John Baber-Lucero almost 12 yearsAch. That's because I was following these instructions which required the latest ffmpeg. I'll ask on meta if this question should be removed from askubuntu since it's not possible with ubuntu's ffmpeg.
-
Mantra almost 12 years-1, izx, what kind of order is that?! FFmpeg clearly assumes every codec stated before
-i
as the codec to parse input with. You can't parse input with copy. "Copy" is not a valid decoder, so naturally, the command will fail. You just have to move-i test.mov
before thevcodec
/acodec
and it'll work. You might want to replacevcodec
withc:v
andacodec
withc:a
as well, since they've been deprecated for like… forever. This is not a deficiency of a "non-standard" version. It's just the latest version. -
ish almost 12 yearsyou know, then you might want to lobby Ubuntu to switch to ffmpeg instead of libav. I am well aware of the issues you point out BUT this syntax is the only one that works with the (deprecated) ffmpeg included in Ubuntu's libav. Our purpose at AskUbuntu is to work with whatever tools Ubuntu makes available by default, not help out with unofficial forks or even self-compiled bleeding edge git pulls or third-party PPAs.
-
ish almost 12 years@JohnBaber: this works perfectly fine with the ffmpeg that IS INCLUDED in Ubuntu by default as of this date -- and that is the somewhat obsolete version bundled by libav, the ffmpeg fork Ubuntu chose to go with last year instead of ffmpeg's ffmpeg.
-
Mantra almost 12 yearsFair enough – I just can't imagine it's impossible to just use the correct command line, even with Ubuntu's bundled version (i.e. correct placement of the copy encoder and using
c:v
instead ofvcodec
). Can't you give it a spin and see if it works? That'd both help people who want or don't care to run a broken/outdated version and those who stay up to date or don't like runninglibav
for whatever personal reasons (You forgot the @-ping btw) -
ish almost 12 years@slhck: thanks; I will later today. FWIW, I prefer the latest ffmpeg.org versions myself. I will also try with
avconv
, which is what the libav folks have renamed ffmpeg to. -
ish almost 12 years@slhck:
ffmpeg -i test.mov -map_metadata -1 -c:v copy -c:a copy test2.mov
gives a nice fat redUnrecognized option 'c:v' Failed to set value 'copy' for option 'c:v'
; using acodec/vcodec after-i
preserves the metadata in the output.