Handbrake: Feature request: Preserve metadata after conversion.

Created on 28 Sep 2016  Â·  65Comments  Â·  Source: HandBrake/HandBrake

Hi, can we get a enhancement in handbrake for preserving the metadata after converting videos.
Most of the time I have to use ffmpeg with map_metadata to preserve metadata. And it is not user-friendly.

Is there any possibility in handbrake?

Enhancement

Most helpful comment

+1 for preserving some metadata. The key one, like @martijnspaan mentioned is the "date created" and "date modified". In particular, when I'm converting older family videos to conserve file space, I don't want to muck with the date modified so it imports into digital libraries correctly like Google Photos.

All 65 comments

While there isn't any interest in adding a really good meta data UI, passthru may be an option. We can disucss and decide later. Right now we are concentrating on getting 1.0 out the door.

What additional metadata are you interested in?

HB already preserves title, artist director, composer, release date, summary, genre, description, and synopsis from any file demuxed by libav (so everything other than BD and DVD sources).

I've done some brief testing with mkv sources to verify no bugs have crept in. But if you see a problem with other source types, please let us know.

Not actually tested it. Does it require the metadata json block to be popualted? I don't do that at the moment.

Sorry, I forgot to get back to you about this question. hb_job_init, hb_job_init_json and hb_preset_job_init copy the title's metadata into the job they create. So if you are initializing your job with any of these, the metadata should already be there.

HB already preserves title, artist director, composer, release date, summary, genre, description, and synopsis from any file demuxed by libav (so everything other than BD and DVD sources).

I know the Linux GTK GUI has more metadata stuffs. Wondering if it's useful to add an option to preserve or remove additional metadata fields other than the above. For example:

|x| Title
|x| Artist
|x| Description
|x|

Other metadata:
  (o) Passthru
  ( ) Remove

Could also be a checkbox but the explicit nature of the radio control seems more suited for clarity.

Your close enough to just adding a MetaData tab to the GUI at that point.

I'm still on the shelf about that. I have been wanting to write a Subler clone for windows for some time though. Just not found the time.

I had thought about tight integration with the likes of Subler. I.e HandBrake could launch super pre-encode, store the info and let Subler tag it afterwords. So you get the Power of Subler, without writing much code.

Otherwise you'll end up with requests for connecting to various meta data websites, adding fields and all the other nice stuff Subler has anyway.

Your close enough to just adding a MetaData tab to the GUI at that point.

GTK has a tab for this. Fields are minimal, useful for clarifying what's happening and changing some very basic properties.

I absolutely agree we shouldn't get into tagging beyond this. My suggestion is to improve upon the GTK implementation with a catch-all for the rest of the metadata we don't plan to mess around with.

I had thought about tight integration with the likes of Subler. I.e HandBrake could launch super pre-encode, store the info and let Subler tag it afterwords. So you get the Power of Subler, without writing much code.

Agreed, it would be cool if Subler had an API we could access programmatically.

Screenshot of the GTK Tags tab:

handbrake-gtk-tags

I noticed that some of the field are properly preserved, but the cover art for instance is lost. Content and Advisory Ratings are lost too from what I remember.

When you create videos with a camera, a timestamp and GPS info is (most times) added.
It would be great if this can be preserved.

Is this likely to happen?

I'd love to convert my 1080i50 h264 content to 1080p50 while keeping timecodes (iMovie and Photos just blends it to 1080p25).

Actually... 1080i50 h264 converted to 1080p50 HEVC with timecodes will be a great conversion for the new Mac "High Sierra" in a couple of months.

Would be an awesome feature to preserve the meta data. When I convert my files on Windows 10, the new file has 'date created' and 'date modified' set to the day of the conversion. Would be great if it could have the creation date of the original file.

E.g. this stackoverflow post has a solution by using ffmpeg, so should be fairly easy to implement in Handbrake, which is already using it.

+1 for preserving some metadata. The key one, like @martijnspaan mentioned is the "date created" and "date modified". In particular, when I'm converting older family videos to conserve file space, I don't want to muck with the date modified so it imports into digital libraries correctly like Google Photos.

+1 for preserving meta as well...

I think use cases described above are leading the developers into considering (then obviously discounting) a full meta data editing tab. This is obviously a chunk of work. There's plenty of 3rd party tools to do this already for things like commercial movies etc.. MetaX for example happily adds film meta mkv/mp4 alike.

Also HB isn't just for (commercial) movies, I use it extensively to shrink family movies made on inefficient cameras - where the difference between 264 quick saved on a battery/processor limited camera to 265 can be huge. In this use case it's incredibly important to preserve the metadata already created - geo, time date, aperture, white balance blah blah blah because there's no way to add them back (easily) afterwards without laboriously saving them and then re-adding them.. cloud image/video libraries such as google photos/flickr etc largely do their magic because they can use this meta data very effectively for albums, image processing and improvement etc.

So simply preserving meta data (either added before hand for movies via something like metaX or embedded by cameras first hand) would be ideal and not as much work as a full meta data editing tab with all the error checking etc that would involve.

I don't think we have any objection to preserving (passing through) existing metadata, just haven't implemented it extensively yet. IIRC there was a patch on our old ReviewBoard to preserve more than we do now, but it's likely far out of date by now.

Where's the code that requires the changes to preserve say the created date? Is it inside libhb or the c# solution?

So it that going to happen anytime soon ? Such a needed feature, that would really be amazing !
Great job on the tool, it is awesome.

It's not high up on anyone's todo list, sorry.

What about approaching this in 2 phases?

Phase 1

Preserving "date created" and "date modified" (for all those who are converting older family videos to save space).
Since HB already preserves some other metadata, it doesn't seem to be too complicated to implement (?)

Perhaps a checkbox under Preferences\Output files:

  • [x] Keep original file Creation and Modification dates

Phase 2

Adding a MetaData tab to the GUI for additional values (or a similar solution)

This issue is about retention of container metadata, not filesystem metadata.

All I can suggest is you create a small powershell script that gets executed using the "When Done" feature in preferences. Stackoverflow has examples of how to set filesystem metadata this way but it's not something i'd recommend doing in the first place.

Having this feature would totally rock my world. I have hundreds of GBs of videos collected over a decade that I'd love to convert to H265 in batch but as they don't have any tags I rely fully on their creation date for meta data.
One thing that may make this easier is that this feature was previously present in HandBrakeBatch, but the developer stopped updating it unfortunately... But code is on Github so you can see how to implement keeping the date stamps the same.

Would be great to have HandBrake keep the original EXIF information. Any progress on this?

Nothing has changed.

Can we do anything to increase the priority for this request?

Nope, Afraid not.

Any updates on this? I'm in the process of figuring out how to backup older family videos and one part of the solution is keeping copies in iCloud Photo library. I'd love to keep all the date metadata intact so it makes sense within my library. There's hundreds of videos so manually doing it again would just be ridiculous.

Nope

I would also love to convert old family videos, but I rely on exif creation date for everything! Please implementi this feature!

Indeed; any update on it? Is it a function to be expected, of not at all?

I would also like to have an option to preserve metadata, especially creation date and location. Currently I'm using slhck's workaround I found on superuser:

You can copy the existing metadata from one file to another without needing to re-encode the video using FFmpeg. It basically takes one second. To do this, let's assume three files:

  • in.mp4 – the original file before conversion
  • out.mp4 – the file after Handbrake conversion
  • fixed.mp4 – the file with "corrected" metadata

The FFmpeg command to copy the complete metadata record to the new file would then be:

ffmpeg -i in.mp4 -i out.mp4 -map 1 -map_metadata 0 -c copy fixed.mp4

[…]

After that, you could obviously rename fixed.mp4 to out.mp4.

I would like this also, especially for the "Recording Date" "Encoding Date" and GPS data. It will make my sorting of family videos so much more easier every month.

Is there any good Linux apps that can preserve metadata of videos?

Thought I'd give Handbrake a try (transcoding my drone videos to h265). First thing I noticed is it dumps all the meta, unfortunately making it unusable for this purpose. Will follow this request with interest, & I guess use ffmpeg directly in the interim.

Thought I'd give Handbrake a try (transcoding my drone videos to h265). First thing I noticed is it dumps all the meta, unfortunately making it unusable for this purpose. Will follow this request with interest, & I guess use ffmpeg directly in the interim.

Do you mind sharing how you're doing this with ffmpeg? It's been 7 months and I still haven't got around to backing up family videos as I just lose all metadata with Handbrake.

Do you mind sharing how you're doing this with ffmpeg? It's been 7 months and I still haven't got around to backing up family videos as I just lose all metadata with Handbrake.

For ffmpeg use the below switches
-map_metadata 0
and/or for mp4/mov containers
-movflags use_metadata_tags

https://ffmpeg.org/ffmpeg.html#Advanced-options

Was this option added recently? I don't see it mentioned as having just been added in 4.2 release...

https://www.google.com/search?q=ffmpeg+map_metadata
I see mentions on page one going back to 2016 so it's been there a while

https://www.google.com/search?q=ffmpeg+movflags+use_metadata_tags
Seems to be from 2017 or earlier

You can search the code of course for a more accurate timeframe

Wait, those are the ffmpeg options (discussed multiple times above) - are you saying handbrake supports these flags too? Per all of the other comments above, it doesn't. Ffmpeg does, but we're discussing Handbrake here.

Nope, HandBrake doesn't use ffmpeg CLI. You need to use ffmpeg as a separate tool.

Was this option added recently? I don't see it mentioned as having just been added in 4.2 release...

Yes they were ffmpeg flag, let me amend my reply to make it clear. I was replying the post above asking what the options in ffmpeg were. I assumed you were also asking about ffmpeg because you mentioned 4.2 and not seeing them mentioned in that release...

Handbrake doesn't support those and doesn't yet support meta data preservation/copying.

Yeah - I just clicked the link you posted, didn't notice it wasn't for Handbrake, which is what this issue is for.

The ffmpeg flag is already mentioned by this issue's OP (very first comment above). I figured you were posting some new info that pertains to handbrake, didn't notice it was just a repeat of the OP's premise.

I get the topic and the duplication. I was answering his question. I could have referenced marcelbrueckner answer above but he missed the movflags option.

This would be a very useful feature, please add it.

In the meanwhile you can use the tool BulkFileChanger to easily copy the time/date tags from the original mp4 files to the converted ones - even the special tag 'date encoded' in the media exif.
Unbelievable that this old tool does exactly what we're looking for and what we're missing in nowadays converters!

Hard to understand that this feature request is now present for 3 years but completely ignored :worried:

None of the current HandBrake developers has a particular interest in metadata. So it's unlikely to get any attention. Speaking for myself, I just don't have enough bandwidth to spend time on things that are not of interest to me.

But in the spirit of moving this forward a notch, we need to create a list of the things that are of interest to users here. As things stand right now, there's not a lot of actionable information in this issue. I asked once already here https://github.com/HandBrake/HandBrake/issues/345#issuecomment-251798940 and got no direct replies. But there have been a few random comments. "Keep all metadata" is not a practical request because metadata comes in a variety of forms that require unique processing for each. Each container has it's own way of representing metadata and it's own keys for indexing the data. Also, ffmpeg may not support all the metadata types I've seen requested. So work may be required on ffmpeg as well. We need a list of what is actually wanted so it can be prioritized and scheduled.

Here are the detailed requests I've seen so far.

  • creation date/time
  • encoding date/time
  • GPS/location
  • EXIF data
  • content advisory ratings
  • cover art

On a number of occasions, people have requested that we modify the file system creation time of HandBrake's output file to make it the same as the source files creation time. Note that I'm not talking about file metadata here, but rather file system data. This is a bad idea for a number of reasons. But there's an alternative that I think is better. If the source doesn't have a creation time metadata tag, read the file system creation time of the source and write that as the output file's creation time metadata. This way the information isn't lost and actually gets written where it should have been in the first place.

@jstebbins i think the most important things to preserve are

  1. creation date/time
  2. EXIF data
  3. GPS/location

None of the current HandBrake developers has a particular interest in metadata. So it's unlikely to get any attention. Speaking for myself, I just don't have enough bandwidth to spend time on things that are not of interest to me.

But in the spirit of moving this forward a notch, we need to create a list of the things that are of interest to users here. As things stand right now, there's not a lot of actionable information in this issue. I asked once already here #345 (comment) and got no direct replies. But there have been a few random comments. "Keep all metadata" is not a practical request because metadata comes in a variety of forms that require unique processing for each. Each container has it's own way of representing metadata and it's own keys for indexing the data. Also, ffmpeg may not support all the metadata types I've seen requested. So work may be required on ffmpeg as well. We need a list of what is actually wanted so it can be prioritized and scheduled.

Here are the detailed requests I've seen so far.

  • creation date/time
  • encoding date/time
  • GPS/location
  • EXIF data
  • content advisory ratings
  • cover art

On a number of occasions, people have requested that we modify the file system creation time of HandBrake's output file to make it the same as the source files creation time. Note that I'm not talking about file metadata here, but rather file system data. This is a bad idea for a number of reasons. But there's an alternative that I think is better. If the source doesn't have a creation time metadata tag, read the file system creation time of the source and write that as the output file's creation time metadata. This way the information isn't lost and actually gets written where it should have been in the first place.

@jstebbins
In my opinion:

  1. GPS/location
  2. Creation date/time (i can write it in folder name, or in file name)

Very grateful for your work!

Passing through the values "createdate" and "modifydate" would be awesome, these are the ones I always need to fix after compressing videos from my Smartphone.

On a number of occasions, people have requested that we modify the file system creation time of HandBrake's output file to make it the same as the source files creation time.

This is indeed a bad idea, because Android ignores file system data if the meta data values "createdate" and "modifydate" exist. Windows-explorer too uses the meta data to display the "Date"-attribute.

I would also like to have an option to preserve metadata, especially creation date and location. Currently I'm using slhck's workaround I found on superuser:

You can copy the existing metadata from one file to another without needing to re-encode the video using FFmpeg. It basically takes one second. To do this, let's assume three files:

  • in.mp4 – the original file before conversion
  • out.mp4 – the file after Handbrake conversion
  • fixed.mp4 – the file with "corrected" metadata

The FFmpeg command to copy the complete metadata record to the new file would then be:

ffmpeg -i in.mp4 -i out.mp4 -map 1 -map_metadata 0 -c copy fixed.mp4

[…]
After that, you could obviously rename fixed.mp4 to out.mp4.

Tried this, unfortunately it did not copy the metadata, specifically the GPS data. In my case my IN file was an .MOV (HEVC) and my OUT file was a .M4V, and FIXED was an .M4V, not sure if that makes a difference.

How do I know it didn't copy the GPS data? Well, I ran exiftool on the original file and the fixed file. It showed GPS coordinates in the original IN file but not the FIXED file.

However, it did copy some other metadata, such as timestamps, correctly.

Update: I was able to copy the GPS metadata using a different tool called Bento. See this topic: https://exiftool.org/forum/index.php?topic=7826.0. Bento gives more precise control over metadata than exiftool. In my case the commands were:

mp4extract moov/meta img_0014.mov temp.txt
mp4edit --insert moov:temp.txt IMG_0014.M4V IMG_0014_GPS.M4V

This is specifically for Apple iPhone metadata. I shot the videos on my iPhone with HEVC, but Lightroom on Windows doesn't support HEVC, so I had to convert the files to H.264.

Update: I was able to copy the GPS metadata using a different tool called Bento. See this topic: https://exiftool.org/forum/index.php?topic=7826.0. Bento gives more precise control over metadata than exiftool. In my case the commands were:

mp4extract moov/meta img_0014.mov temp.txt
mp4edit --insert moov:temp.txt IMG_0014.M4V IMG_0014_GPS.M4V

This is specifically for Apple iPhone metadata. I shot the videos on my iPhone with HEVC, but Lightroom on Windows doesn't support HEVC, so I had to convert the files to H.264.

You have to download the HEVC plugin from Windows Store and it'll work.

Also interested in at least preserving these:

Encoded Date
Tagged Date
Mastered Date

Different video formats have different metadata. If handbrake relies on ffmpeg behind the scenes, I'm wondering if it would just be easier to pass something like -map_metadata 0 behind the scenes between source and output files as a post processing step?

would love to be able to keep the metadata or at least be able to add it in the output's naming scheme

I'm trying to compress dozens of 1080p videos from iCloud, which relies on dates to organize everything. Adding a checkbox to preserve the original date is a great idea. PhotoConvert 4 on Mac does this very effectively: https://i.imgur.com/OiAnEQp.png. So does Lightweight PDF.

With the proliferation of very high resolution cameras in our phones, it's bound to become even more important to compress videos without messing up our photo libraries.

I'm trying to compress dozens of 1080p videos from iCloud, which relies on dates to organize everything.

That’s the main issue I have as well fr the very same reason. Obviously I’d like all other metadata to be preserved, but the creation date is the main one for anything I shoot on various devices.
For that sort of things, I have to use either ff Works or Permute on my Mac (they have special preferences to preserve that).

For that sort of things, I have to use either ff Works or Permute on my Mac (they have special preferences to preserve that).

While I still have a sliver of hope that the recent comments will convince the developers to add this feature, it's been asked since 2016 so I stopped expecting anything. I wouldn't mind using other tools than Handbrake for (batch) conversion and have dabbled with Compressor. But ffworks or Permute are new to me, would you recommend them? It looks like they do h265/HEVC, which is a requirement for me. How do they handle batch jobs?

While I still have a sliver of hope that the recent comments will convince the developers to add this feature

The issue is open, not rejected. Nobody has made time or shown interest, yet. We're a very small team and none of us work on HandBrake full time.

Thanks for understanding. Some of these things may happen, it's just hard to say when.

Just a reminder that those of you using Windows Nightly builds can utilise the Send File To Option. Either to ffmpeg or a script. You can do the same on mac but it's a little more tricky to script it on that platform as you only get the destination.

image

and use the examples above to map metadata.

I'm on linux, so I cannot use this GUI feature, but if people are looking to do something with exiftool, here is what you can use : _exiftool -overwrite_original -tagsfromfile {source} {destination}_

For sources shot on a camera (e.g., Canon), it would be nice to block copy the camera metadata as well as the EXIF data.

Hello,

still no change? (preservation of audio track names, sub ...)

Audio and subs track names are preserved.

Audio and subs track names are preserved.

my bad, I was not up to date :)

I'm on linux, so I cannot use this GUI feature, but if people are looking to do something with exiftool, here is what you can use : _exiftool -overwrite_original -tagsfromfile {source} {destination}_

I second the request to have the meta data preserved.

I've spent the last days to find out how to accomplish this with exiftool, and I can say that the above command will actually not do the job as exiftool will re-interpret e.g. the location data which then is no more readable by Apple Photos (in my use case at least).
What you do need is the -all:all option that keeps the original structure intact.
However, that command again may cause videos to rotate erroneously, so you need to add some more. This is the command that works for me (moving tags from .mov to .mp4 in this example):
exiftool -all= -tagsfromfile ./src/%f.mov -ext mp4 -all:all --matrixstructure --rotation ./dest

For those interested in details, see this thread in the exiftool forum:
https://exiftool.org/forum/index.php?topic=11610.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iburunat picture iburunat  Â·  3Comments

jeremymeyers picture jeremymeyers  Â·  4Comments

AlexPasternak picture AlexPasternak  Â·  5Comments

Cagliostrooo picture Cagliostrooo  Â·  3Comments

a7dfj8aerj picture a7dfj8aerj  Â·  3Comments