LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 10-17-2019, 11:47 AM   #1
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Rep: Reputation: 3
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.

Anyone done this before? Any ideas?
 
Old 10-17-2019, 11:50 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
mkvpropedit

that will add/change/delete metadata in mkv



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.

Last edited by Firerat; 10-17-2019 at 11:54 AM.
 
Old 10-18-2019, 09:13 AM   #3
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
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.

Try
Code:
ffmpeg -i input-file.mp4 -map_metadata -1 -c:v copy -c:a copy   output-file.mp4
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.

[See https://superuser.com/questions/4413...s-with-ffmpeg]

Should also work for mkv - but I haven't tried it.

Last edited by JeremyBoden; 10-18-2019 at 09:21 AM.
 
Old 10-18-2019, 09:15 AM   #4
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Original Poster
Rep: Reputation: 3
Is there a way I can do this without copying the file?
 
Old 10-18-2019, 09:27 AM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by aristosv View Post
Is there a way I can do this without copying the file?
mkvpropedit can add/change/delete metadata

wait, .. didn't I already mention this ?
 
Old 10-18-2019, 09:28 AM   #6
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Original Poster
Rep: Reputation: 3
I meant using @JeremyBoden suggestion.
 
Old 10-18-2019, 09:31 AM   #7
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by aristosv View Post
I meant using @JeremyBoden suggestion.
which is pointless if mkvpropedit and exiftool can modify the metadata
 
Old 10-18-2019, 09:59 AM   #8
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
If you have valuable videos, I'd suggest you make sure you have reliable backups before trying an edit in situ.
 
1 members found this post helpful.
Old 10-20-2019, 10:52 AM   #9
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by aristosv View Post
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.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find mkv files; convert to mp4 with ffmpeg daweefolk Linux - Software 5 04-19-2018 04:22 PM
Transcoding MKV files with embedded subtitles to MP4's with 'burned in' subtitles TB0ne LinuxQuestions.org Member Success Stories 0 09-17-2014 11:45 AM
Converting VC1 inside mkv to a x.264 in a mkv J_Humphrey Linux - Software 1 03-26-2010 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration