8

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.

ish
  • 138,666
  • 36
  • 303
  • 312
John Baber-Lucero
  • 2,363
  • 4
  • 25
  • 35

2 Answers2

14

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 and exiftool test-nometadata.mov should show you the difference.

  • Here are my sample outputs from an old Nikon .mov with tons of metadata (pastebin'd):

    1. before - 80 metadata lines
    2. 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)

ish
  • 138,666
  • 36
  • 303
  • 312
  • I get [this](http://paste.ubuntu.com/997540/) when I try to do as you've suggested. – John Baber-Lucero May 20 '12 at 15:56
  • That'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 is `0.8.1-4:0.8.1-0ubuntu1` and works fine. – ish May 21 '12 at 03:41
  • Ach. That's because I was following [these instructions](http://superuser.com/questions/424015/what-bunch-of-ffmpeg-scripts-do-i-need-to-run-video-for-everybody) 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. – John Baber-Lucero May 21 '12 at 14:14
  • -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 the `vcodec`/`acodec` and it'll work. You might want to replace `vcodec` with `c:v` and `acodec` with `c: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. – slhck May 21 '12 at 14:36
  • you 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 May 21 '12 at 14:44
  • @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. – ish May 21 '12 at 14:45
  • Fair 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 of `vcodec`). 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 running `libav` for whatever personal reasons *(You forgot the @-ping btw)* – slhck May 21 '12 at 14:50
  • @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 May 21 '12 at 14:52
  • @slhck: `ffmpeg -i test.mov -map_metadata -1 -c:v copy -c:a copy test2.mov` gives a nice fat red `Unrecognized option 'c:v' Failed to set value 'copy' for option 'c:v'` ; using acodec/vcodec after `-i` preserves the metadata in the output. – ish May 21 '12 at 14:55
3

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
evilsoup
  • 4,435
  • 1
  • 19
  • 26