To align multimedia files, it is necessary at least the photo identification data and one more data source, such as video files. See Extracting metadata of multimedia files.

# read photo id data
photoid <- utils::read.csv(file = "/Volumes/mydisk/MAMMals/photoid.csv")

# check photos with no individual identification
ignore.photos <- photoid[is.na(photoid$camera.PHOTOID), 'camera.photo_filename']

# extract metadata, ignore photos with no ID, export .csv file and assign photoid to data_photoid
photos_metadata <- MAMMals::getPhotoMetadata(
  ROOTfolderpath = photo_folderpath, 
  extension = '.jpg', 
  ignore = ignore.photos, 
  timezone = "America/Sao_Paulo", 
  export = NULL,
  data_photoid = photoid[, c("camera.photo_filename","camera.PHOTOID")]
)

# extract metadata of drone video files
videos_metadata <- MAMMals::getVideoMetadata(
  ROOTfolderpath = video_folderpath,
  extension = '.mp4', 
  include_srt_datetime = FALSE,
  ignore = NULL, 
  timezone = "America/Sao_Paulo",  
  export = NULL
  )

It is also possible to align multiple data sources. For example, extract the metadata of audio files with the getAudioMetadata(). If .wav or .mp3 audio files are available, simply pass the full path where all the audio files are located. As common used recorders use timestamped filenames, it is possible to retrieve the date and time from the filename.

audios_metadata = MAMMals::getAudioMetadata(
  ROOTfolderpath,
  extension = '.wav',
  ignore = NULL,
  filter_folder = NULL,
  is_timestamp_filename = FALSE,
  format_timestamp_filename = "ymd_hms",
  timezone = 'America/Sao_Paulo',
  export = paste0(export_data_folder, '/', 'test_audio_metadata.csv') )

With photo-identification and video metadata available, it is possible to align both data sources to subset only media files containing photo-identification data. The function selectVideos uses the timestamp from the camera images and the drone videos to look for photo identification data taken during the video sampling. The select function then calculates the time of each photograph in the video (or audio with the selectAudios()).

selected_videos <- MAMMals::selectVideos(
  data = photos_metadata,
  data_datetime = NULL,
  video_metadata = videos_metadata, 
  video_datetime = "video",
  format_data_datetime = "%Y/%m/%d %H:%M:%S",
  keep_all = FALSE, 
  export = NULL,
  timezone = "America/Sao_Paulo")
#> During 2 video(s), 11 photo(s) were taken of 2 individual(s)
head(selected_videos)
#>                 camera.photo_path camera.photo_filename camera.PHOTOID
#> 1 /Volumes/mydisk/MAMMals/photoid          6Q1A0177.JPG           L_24
#> 2 /Volumes/mydisk/MAMMals/photoid          6Q1A0178.JPG           L_24
#> 3 /Volumes/mydisk/MAMMals/photoid          6Q1A0179.JPG           L_24
#> 4 /Volumes/mydisk/MAMMals/photoid          6Q1A0180.JPG           L_26
#> 5 /Volumes/mydisk/MAMMals/photoid          6Q1A0181.JPG           L_26
#> 6 /Volumes/mydisk/MAMMals/photoid          6Q1A0182.JPG           L_26
#>   camera.photo_filename_exif camera.datetime_GPS_UTC camera.datetime_local
#> 1               6Q1A0177.JPG     2019-05-22 15:05:14   2019-05-22 12:05:15
#> 2               6Q1A0178.JPG     2019-05-22 15:05:14   2019-05-22 12:05:15
#> 3               6Q1A0179.JPG     2019-05-22 15:05:29   2019-05-22 12:05:30
#> 4               6Q1A0180.JPG     2019-05-22 15:05:59   2019-05-22 12:06:01
#> 5               6Q1A0181.JPG     2019-05-22 15:06:14   2019-05-22 12:06:29
#> 6               6Q1A0182.JPG     2019-05-22 15:06:14   2019-05-22 12:06:29
#>     camera.CreateDate camera.TimeZone camera.TimeZoneCity
#> 1 2019-05-22 12:05:15          -03:00           Sao Paulo
#> 2 2019-05-22 12:05:15          -03:00           Sao Paulo
#> 3 2019-05-22 12:05:30          -03:00           Sao Paulo
#> 4 2019-05-22 12:06:01          -03:00           Sao Paulo
#> 5 2019-05-22 12:06:29          -03:00           Sao Paulo
#> 6 2019-05-22 12:06:29          -03:00           Sao Paulo
#>   camera.DaylightSavings camera.CanonModelID camera.GPSLatitudeRef
#> 1                    Off      EOS 7D Mark II                 South
#> 2                    Off      EOS 7D Mark II                 South
#> 3                    Off      EOS 7D Mark II                 South
#> 4                    Off      EOS 7D Mark II                 South
#> 5                    Off      EOS 7D Mark II                 South
#> 6                    Off      EOS 7D Mark II                 South
#>   camera.GPSLongitudeRef camera.GPSMapDatum    camera.GPSAltitude
#> 1                   West             WGS-84 3.9 m Above Sea Level
#> 2                   West             WGS-84 3.9 m Above Sea Level
#> 3                   West             WGS-84 3.5 m Above Sea Level
#> 4                   West             WGS-84 1.1 m Below Sea Level
#> 5                   West             WGS-84 3.6 m Below Sea Level
#> 6                   West             WGS-84 3.6 m Below Sea Level
#>   camera.direction.angle camera.direction.angle.ref  camera.GPSLatitude
#> 1                    226             Magnetic North 28 deg 29' 44.91" S
#> 2                    226             Magnetic North 28 deg 29' 44.91" S
#> 3                    167             Magnetic North 28 deg 29' 44.87" S
#> 4                    241             Magnetic North 28 deg 29' 44.77" S
#> 5                    247             Magnetic North 28 deg 29' 44.77" S
#> 6                    246             Magnetic North 28 deg 29' 44.77" S
#>   camera.GPSLongitude camera.latitude camera.longitude
#> 1 48 deg 45' 35.74" W       -28.49581        -48.75993
#> 2 48 deg 45' 35.74" W       -28.49581        -48.75993
#> 3 48 deg 45' 35.69" W       -28.49580        -48.75991
#> 4 48 deg 45' 35.74" W       -28.49577        -48.75993
#> 5 48 deg 45' 35.72" W       -28.49577        -48.75992
#> 6 48 deg 45' 35.72" W       -28.49577        -48.75992
#>                                    video.path video.local_start_datetime
#> 1 /Volumes/mydisk/MAMMals/videos/DJI_0042.MP4        2019-05-22 11:59:05
#> 2 /Volumes/mydisk/MAMMals/videos/DJI_0042.MP4        2019-05-22 11:59:05
#> 3 /Volumes/mydisk/MAMMals/videos/DJI_0042.MP4        2019-05-22 11:59:05
#> 4 /Volumes/mydisk/MAMMals/videos/DJI_0042.MP4        2019-05-22 11:59:05
#> 5 /Volumes/mydisk/MAMMals/videos/DJI_0042.MP4        2019-05-22 11:59:05
#> 6 /Volumes/mydisk/MAMMals/videos/DJI_0042.MP4        2019-05-22 11:59:05
#>   video.local_end_datetime video.duration video.photoid_time   video.file
#> 1      2019-05-22 12:14:48    00:15:43.72           00:06:10 DJI_0042.MP4
#> 2      2019-05-22 12:14:48    00:15:43.72           00:06:10 DJI_0042.MP4
#> 3      2019-05-22 12:14:48    00:15:43.72           00:06:25 DJI_0042.MP4
#> 4      2019-05-22 12:14:48    00:15:43.72           00:06:56 DJI_0042.MP4
#> 5      2019-05-22 12:14:48    00:15:43.72           00:07:24 DJI_0042.MP4
#> 6      2019-05-22 12:14:48    00:15:43.72           00:07:24 DJI_0042.MP4