Ffmpeg-python: Stripping All Exif/Metadata during Convert?

Created on 19 Oct 2019  路  2Comments  路  Source: kkroening/ffmpeg-python

Hello! I must be doing something wrong but forgive me. I want to strip all metadata/exif info from a video. This is what I am using:

stream = ffmpeg.input("./" + ranFilename + ".mp4").
stream = ffmpeg.output(stream, "./" + ranFilename + "2.mp4")
ffmpeg.run(stream).extra_args('-map_metadata', -1)

I dont get how to pass extra arguments but essentially I need to pass this:
ffmpeg -i in.mov -map_metadata -1 -c:v copy -c:a copy out.mov

Gotten from here: https://superuser.com/questions/441361/strip-metadata-from-all-formats-with-ffmpeg

How am i supposed to pass the "-map_metadata -1" into the argument?

Most helpful comment

Also handy to know - if you're ever totally lost as to why your ffmpeg command is failing, you can use print(ffmpeg.compile(stream)) and compare what you get with the desired output. The thought to add it to an input or output declaration only came to me after comparing this way.

All 2 comments

@SingitBatch40 try this in your output declaration:

ffmpeg.output(stream, "./" + ranFilename + "2.mp4", map_metadata=-1)

Complete example at https://github.com/spirulence/ffmpeg-issues/blob/master/279-strip-metadata/279.py

If you do a before and after with a tool like ExifTool, you should find _less_ metadata in your output file.

I say _less_ because there's still a lot of information there. If you're interested in providing even less metadata, you might consider changing the video format you're transcoding to. I know that OGV files, for example, have only about 10 fields of metadata readable by ExifTool if you process them this way.

Also handy to know - if you're ever totally lost as to why your ffmpeg command is failing, you can use print(ffmpeg.compile(stream)) and compare what you get with the desired output. The thought to add it to an input or output declaration only came to me after comparing this way.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roman-ku picture roman-ku  路  4Comments

prajwal-mulkalwar picture prajwal-mulkalwar  路  6Comments

laurentalacoque picture laurentalacoque  路  4Comments

nathanaelneveux picture nathanaelneveux  路  4Comments

reformstudios picture reformstudios  路  3Comments