/home

Sat, 28 Sep 2024

Keep tags and timestamp from converted videos with Handbrake

I'm using handbrake to convert h264 videos taken from my camera or smartphone into AV1 (13 minutes for a 100MB video on a Core i5-6200 CPU).

As for now with the latest version (1.8.2), I'm loosing the date, time and GPS meta data during the convertion process which is annoying.

In the Settings menu of Handbrake there's a subsection When Done in which you can configure an action when the encoding is complete.

Handbreak When Done settings

One of the action is to send the encoded file to an external software and I configure the path to the videotimestamp.bat script described below.

The script depends on exiftool (v12.97 as for now)

set SOURCE=%1
set DEST=%2
set EXIFTOOL="<whatever your setup>\exiftool.exe"

REM -extractEmbedded for timed GPS track data 
%EXIFTOOL% -tagsFromFile %SOURCE% -all:all -FileModifyDate -overwrite_original -FileCreateDate \
    -overwrite_original %DEST%

Exiftool is perl based so it is not that fast to extract data and update the target video, yet it is still a lot faster that a converting h264 video into AV1 so speed does not matter here.

Note: Exiftool does not support WEBM container meta-data, that's why I'm using the M4V file format in Handbrake.

That's it.

Handbreak launching the script

Digikam configuration

In case GPS metadata are not set by the camera or smartphone in the orginal video, you can still edit them thanks to Digikam.

Be sure to correctly configure Digikam to use ExifTool and to save GPS location into metadata. (in Settings / Configure DigiKam / Metadata submenu)