Site icon Bytefreaks.net

Change date in GoPro media (photos/video/low quality videos/still frames) files

Advertisements

Recently, we took some videos and pictures with our GoPro camera which was not used for some time and discharged. Due to that, the date and time configuration of the camera was wrong and the resulting video files had wrong metadata information in their EXIF.

To update the dates in the produced video and photo files we used the exiftool that is shipped in the perl-Image-ExifTool package.
We usually use Fedora, so we used dnf to install the application with all needed dependencies as follows:


sudo dnf install -y perl-Image-ExifTool;

After installing exiftool, we used the following script to change the dates and times of the media files using an offset between the camera date and the real date:

[download id=”4544″]

#!/bin/bash

directory="$1";
echo "Processing '$directory'";
date_change="$2";
echo "Change '$date_change'";

find "$directory" \( -iname "*.mp4" -o -iname "*.lrv" -o -iname "*.jpg" -o -iname "*.thm" \) -type f -execdir sh -c '
	image=$1;
	echo "$image ";
	old_date=`exiftool -d "%a %b %d %T %Z %Y" -CreateDate -S -s "$image"`;
	echo -e "\t$old_date";
	new_date=`date -d "$old_date $date_change"`;
	echo -e "\t$new_date";
	formated_date=`date "+%Y:%m:%d %H:%M:%S %Z" -d "$new_date"`;
	echo -e "\t$formated_date";
	exiftool "-AllDates=$formated_date" "-TrackCreateDate=$formated_date" "-TrackModifyDate=$formated_date" "-MediaCreateDate=$formated_date" "-MediaModifyDate=$formated_date" -overwrite_original "$image";
' _ '{}' \;

[download id=”4544″]

Usage Example:

After we extracted the script to a folder we were able to use it as follows:


./mediaDates.sh '/run/media/100GOPRO' '+ 3 years + 6 months + 11 days + 7 hours + 5 minutes';

Notes:

Link to an older post that handles a single video each time.

This post is also available in: Greek

Exit mobile version