removing all metadata from mp4 and mkv files recursively without creating copies and re-encoding
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
removing all metadata from mp4 and mkv files recursively without creating copies and re-encoding
I have a directory containing about 300 video files, mostly mp4 and mkv files, each one in its own directory.
I am looking for a way to remove the metadata information from all the video files, without having to re-encode them, and without having to make copies for each file.
They are on a NAS with very slow disks, and re-encoding will take ages.
exiftool doesn't work on mkv files and it actually takes ages on each file, I guess it re-encodes each file. ffmpeg also tries to re-encode and I haven't found a way to use it without creating a copy of each file.
Edit:
Just as a side note, if you are serving files via dlna , it may also be providing metadata from the files or some scrapper, its cache may need to be purged.
Would you trust a program that changes a video file in situ?
I think you need to transfer the file to a PC, generate the new file, check it still works, then transfer it back to the NAS.
Both mp4 & mkv are containers so no re-muxing would be needed.
I tried it on a 1GB (one hour) video file and it took about 10 seconds to strip all metadata and create a new video.
If you need to keep the title, you will have to add it back in.
Is there a way I can do this without copying the file?
What I use for them annoying titles that are some of the time embedded in the videos. You could modify the script to your needs.
Code:
MacUser2525:~$ cat Bin/title.sh
#!/bin/bash
# Get directory script is running in
DIR="$(dirname "$PWD")/$(basename "$PWD")"
# Change to directory
cd $DIR
# Now process all .mkv files under that directory
for i in $(find $PWD | grep .mkv ); do
# Name of file to use in title delete
NAME=$(basename "$i")
echo $NAME
mkvpropedit "$i" -d title
# mkvpropedit "$i" -d artist
# mkvpropedit -v movie.mkv -v --edit track:2 --set track-number=3 --edit track:3 --set track-number=2 # set track 3 to first audio delete removes track
# https://www.bunkus.org/videotools/mkvtoolnix/doc/mkvpropedit.html
# Done processing all files
done
And contrary to the paranoid thinking, the changing of the metadata does not effect the files in any way.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.