R似乎无法使用EXIFR软件包读取大型MP4视频文件的EXIF数据
6个月前,我使用R EXIFR软件包从大型MP4视频文件中提取EXIF信息并导出到CSV。现在,我得到了一些文件。我已经对以前工作正常的旧文件集进行了重复测试,并且过去效果不佳。在R Studio中查看的最初的DAT表显示了一些NA。查看视频文件,似乎很短的持续时间还可以,但是较大的视频文件抛出了na。这是一个内存问题吗?我已更新为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)
https://i.sstatic.net/s4cfu.png“ alt =” exif输出初始dat显示较大文件的na和较小文件的数据”>
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决!要使用EXIFR读取大型视频文件的EXIF信息,您需要将.exiftool_config文件添加到EXIFR中的Exiftool文件夹(@stargeek fyi exifr调用exiftool exiftool以读取EXIF信息)。这是我遵循的步骤,以防将来对其他任何人都使用:
插入
请参阅 https://exiftool.org.org.org/forum/forum/index.php?主题= 3916.15 有关更多信息。
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:
Insert
Refer to https://exiftool.org/forum/index.php?topic=3916.15 for more info.