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

发布于 2025-02-02 19:27:06 字数 1928 浏览 3 评论 0原文

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 Video file information showing size and duration

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)

exif output initial dat showing NA for larger files and data for smaller files

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九命猫 2025-02-09 19:27:06

解决!要使用EXIFR读取大型视频文件的EXIF信息,您需要将.exiftool_config文件添加到EXIFR中的Exiftool文件夹(@stargeek fyi exifr调用exiftool exiftool以读取EXIF信息)。这是我遵循的步骤,以防将来对其他任何人都使用:

  1. 复制文本位于 https:// 我的情况
  2. 在 您看到的文本的底部
 %image :: exiftool :: userDefined :: options =((
coordformat =&gt; '%.6F',#更改默认GPS坐标格式
重复=&gt; 1,#make -a exiftool应用程序的默认值
geomaxhdop =&gt; 4,#忽略GPS使用HDOP&gt; 4
requestall =&gt; 3,#请求其他标签通常不会生成
);
 

插入

LargeFileSupport => 1, 
  1. 保存文件,

请参阅 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:

  1. Copy text located in https://exiftool.org/config.html
  2. Save as .ExifTool_config within the exifr exiftool folder of R in my case (C:\Users\YOURNAMEHERE\AppData\Local\R\win-library\4.2\exifr\exiftool)
  3. At the bottom of the text where you see
%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, 
  1. Save the file

Refer to https://exiftool.org/forum/index.php?topic=3916.15 for more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文