Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once FFmpeg has been properly mapped to Path, it can be run in the Windows command prompt with 'ffmpeg' alone. The command prompt examples below assume FFmpeg has been installed in this way.

Convert audio formats

Sometimes we receive digitized or born-digital audio in formats that are not supported by our Islandora repository. Circa 2019 at AILLA, these have included files in WMA, AIFF and OPUS (a lossly format used by WhatsApp). Staff should convert these files into the supported WAV or MP3 formats, depending on the nature and quality of the unsupported digital files. Format conversion with FFmpeg can be as simple as specifying a different extension for the output file, but additional details, such as those discussed in Creating smaller audio files, may also be specified.

...

Note that this will not delete the original MP3 file, but will create a new MP4 file alongside it. Because AAC is a better compression algorithm overall than MP3, the output files will be about 80% smaller than the size of the input files, while achieving the same audio quality.

...

This script lists the contents of path_to_file_directory, then feeds each file in the list to ffmpeg as input. The grep command filters out all output lines except those containing "Duration", which is how ffmpeg displays runtime. The filename is echoed, so each runtime can be paired with the corresponding file. The tr command replaces the newline characters separating the runtime and filename with a blank space (thereby outputting them on the same line), then adds a blank space after the output to break the output for each file up. The processed output is saved as a text file in path_to_output_directory. The output can be further refined to remove additional unwanted information, but as it is written above the script will produce an output that is easy to manipulate and extract data from using Notepad++ or a spreadsheet program. See below for an example output:

If the MP4 files are stored in separate subdirectories, and the filenames match the subdirectory name (or the subdirectory name followed by another filename element), the above script can be adapted to search within each subdirectory:

for file in `ls /path_to_file_directory/` ; do ffmpeg -i /path_to_file_directory/$file/$file.mp4 2>&1 | { grep "Duration" & echo $file; } | { tr '\n' ' ' ; echo ' '; } >> /path_to_output_directory/runtimes.txt ; done