6 months ago I used the R exifr package to extract EXIF information from large MP4 video files and export to csv. Now I get NA's for some files. I have run repeat tests of old file sets that previously worked fine and what worked in the past now doesn't. The initial dat table viewed in R studio shows some NA's. Looking at the video files, it seems that small files of short duration are Ok, but larger video files throw NA. Is this a memory issue? I have updated to R v4.2.0
library(exifr)
library(dplyr)
library(tidyverse)
library(hms)
library(lubridate)
library(tidyr)
library(exifr)
setwd("D:\CAFNEC_GBRF\6_Hinchinbrook_Herbert\Victoria Ck\2021") #Insert Base Folder Location Here
#Set File Locations
survey.videos <- "Video_for_Analysis1/" #Folder with videos
#Get EXIF information from video files
files2 <- list.files(survey.videos, pattern = NULL, recursive = TRUE, full.names = TRUE)
dat <- read_exif(files2, tags=c("FilePath", "FileName",
"CreateDate", "Duration"))
dat <- mutate(dat,
DateTimeOriginal = CreateDate)
#Seperate DateTimeOriginal Column into Date & Time
dat2 <- dat %>% separate(DateTimeOriginal, c("Date", "Time"), sep = "([\\ ])") %>%
separate(Date, c("Year", "Month", "Day"), sep = "([\\:])")
dat2$Time <- strptime(dat2$Time, format = "%H:%M:%S")
dat2$Time <- dat2$Time + lubridate::hours(10)
dat2$Time <- substr(dat2$Time,12,19)
#COnvert video start time to hh:mm:ss
dat2$Video_Start <- as_hms(dat2$Time)
#Convert video duration to hh:mm:ss
dat2$Vid_duration <- as_hms(dat2$Duration)
#Calculate video duration
dat3 <- mutate(dat2, Vid_End = Video_Start + Vid_duration)
#COnvert duration to seconds
dat4 <- as_hms(dat3$Vid_End)
#Add Video End Time as column
dat5 <- mutate(dat2, Vid_End = dat4)
#Round Video End time to nearest second
dat5 <- mutate(dat5, Vid_Stop = round_hms(dat5$Vid_End, secs = 1))
#Export to CSV
write.csv(dat5, 'Output1.csv',
row.names = F)
Solved! To read Exif info of large video files using exifr you need to add a .ExifTool_config file to the ExifTool folder within exifr (@StarGeek FYI exifr calls ExifTool to read Exif info). Here are the steps I followed in case it's of use to anyone else in the future:
%Image::ExifTool::UserDefined::Options = ( CoordFormat => '%.6f', # change default GPS coordinate format Duplicates => 1, # make -a default for the exiftool app GeoMaxHDOP => 4, # ignore GPS fixes with HDOP > 4 RequestAll => 3, # request additional tags not normally generated );
Insert
LargeFileSupport => 1,
Refer to https://exiftool.org/forum/index.php?topic=3916.15 for more info.