R 似乎无法使用 exifr 包读取大型 MP4 视频文件的 EXIF 数据

R seems not able to read EXIF data of large MP4 video files using exifr package

6 个月前我使用 R exifr 包从大型 MP4 视频文件中提取 EXIF 信息并导出到 csv。现在我得到一些文件的 NA。我对旧文件集进行了 运行 重复测试,这些旧文件集以前工作正常,而过去工作的现在不工作了。在 R studio 中查看的初始数据 table 显示了一些 NA。查看视频文件,似乎持续时间较短的小文件还可以,但较大的视频文件会抛出 NA。这是内存问题吗?我已经更新到 R v4.2.0

library(exifr)
library(dplyr)
library(tidyverse)
library(hms)
library(lubridate)
library(tidyr)

library(exifr)
setwd("D:\CAFNEC_GBRF_Hinchinbrook_Herbert\Victoria Ck21") #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)

已解决!要使用 exifr 读取大型视频文件的 Exif 信息,您需要将 .ExifTool_config 文件添加到 exifr 中的 ExifTool 文件夹中(@StarGeek FYI exifr 调用 ExifTool 来读取 Exif 信息)。以下是我遵循的步骤,以防将来对其他人有用:

  1. 复制位于 https://exiftool.org/config.html
  2. 的文本
  3. 在我的例子中,在 R 的 exifr exiftool 文件夹中另存为 .ExifTool_config (C:\Users\YOURNAMEHERE\AppData\Local\R\win-library.2\exifr\exiftool)
  4. 在您看到的文本底部
%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
);

插入

LargeFileSupport => 1, 
  1. 保存文件

有关详细信息,请参阅 https://exiftool.org/forum/index.php?topic=3916.15