Extract metadata of audio files from a given root folder.

getAudioMetadata(
  ROOTfolderpath,
  extension = ".wav",
  ignore = NULL,
  filter_folder = NULL,
  is_timestamp_filename = FALSE,
  format_timestamp_filename = "ymd_hms",
  timezone = "America/Sao_Paulo",
  export = NULL
)

Arguments

ROOTfolderpath

full path to folder where all audio files are (without a final slash). E.g. '/Users/you/Desktop'

extension

extension of audio files, either a single string or a vector with more than one extension. Currently it takes c('.wav', '.mp3')

ignore

Should any audio be skipped, enter a string or a vector of strings that match the file name of such files E.g. if you want to ignore all audio with file names containing 'test', then input ignore = "test". If you want all file names with 'test' and 'edited' to be ignored, then input ignore = c("test", "edited").

filter_folder

Should entire folders be ignored, pass a string with the main subfolder tag name, the one from which the audios should be read from. For instance, if you have recorded from 2 different hydrophones (say, PAM and hand-held) and have saved them in different folders (say, './PAM_recordings/', './Handheld_recordings/') and only want to extract the metadata of the hand-held hydrophones then set filter_folder = 'Handheld_recordings'. If you want the metadata from the PAM hydrophones, then set filter_folder = 'PAM_recordings'. If you want to get teh metadata of all subfolders, then use the detault filter_folder = NA.

is_timestamp_filename

logical. If TRUE, retrieves the date and time from file names using the date formats "ymd_hms" "epoch" formats, defined in the argument format_timestamp_filename

format_timestamp_filename

character. Depending on the file name structure, choose between "ymd_hms" and "epoch".

timezone

string. Add the correct timezone where the drone videos were taken, as per the R base notation (for additional information, see help(timezomes)). Should this argument be left empty, the time zone will be assumed to be the same as the computer system.

export

full path and .csv filename to where the metadata should be exported to. E.g. export = '/Users/you/Database/camera_metadata.csv'. Should the metadata not be exported, export=NA

Value

a data frame with the metadata of audio files: "UTC_datetime_dec", "UTC_datetime_sec","UTC_datetime_min","audio.UTC_start_datetime","audio.UTC_end_datetime","audio.local_start_datetime" ,"audio.local_end_datetime","audio.date", "audio.folder" ,"audio.filename","audio.duration" , "audio.file_size_MB" ,"audio.num_channels" ,"audio.sample_rate" ,"audio.average_bytespersecond" ,"audio.bitspersample".

Details

The function is designed to deal with the metadata from audios of hydrophones but it could work with other audio recording types. You can also edit the exiftool to extract metadata of other audio files (see line 121).

Author

Mauricio Cantor

Examples

if (FALSE) { audio_metadata = getPhotoMetadata(ROOTfolderpath = '/Desktop/you/data', extension='.wav', ignore = NA, filter_folder = NA, timezone='America/Sao_Paulo', export = NA) }