How to Convert DAV Footage to mp4 Video
With the increasing popularity of computer vision use cases, you may find yourself leveraging existing hardware from devices like security cameras to create computer vision datasets. Popular security or CCTV systems record in DAV as opposed to more popular formats like MP4.
DAV uses proprietary compression to store video. At the time of this blog post, Roboflow does not yet support DAV upload and your local machine may not even have a DAV player! Indeed, DAV is not the most intuitive format with which to work.
In this guide, we are going to show how to convert DAV video to mp4. Without further ado, let’s get started!
How to Convert DAV to mp4
To convert DAV to mp4, you can use FFmpeg, a popular and comprehensive utility for working with and converting video in different formats. We will call an FFmpeg command in a Python script so we can run FFmpeg over a folder of files.
We will use Homebrew to install FFmpeg on a Mac. Homebrew is a popular package manager for macOS. FFmpeg is an open-source, command-line tool for manipulating, converting, etc. a wide range of media formats. If you’re working on a Windows or Linux machine, head over to FFmpeg’s site for other install tutorials: https://ffmpeg.org/
First, open Terminal and install Homebrew if you don't have it already. Enter the following command in Terminal and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, enter the following command in Terminal to install FFmpeg and press Run the following commandcomandEnter:
brew install ffmpeg
After Installation is complete, you can verify a proper installation with the following command in terminal:
ffmpeg -version
Finally, open up your Python program of choice and paste the following into a new file:
import subprocess
def convert_dav_to_mp4(input_file, output_file):
ffmpeg_command = f'ffmpeg -i "{input_file}" -c:v copy -c:a copy "{output_file}"'
subprocess.call(ffmpeg_command, shell=True)
# Example usage
input_dav_file ='/Users/brian/Desktop/input.dav'
output_mp4_file ='/Users/brian/Desktop/output.mp4'
convert_dav_to_mp4(input_dav_file, output_mp4_file)
Be sure to adjust the input and output file locations in lines 8 and 9. On a Mac, you can double-click on the file, select “Get info”, and copy its location here:
Conclusion
Congratulations! You are now ready to use your CCTV or security camera footage in DAV format, convert it to MP4, and start building a custom dataset in Roboflow using your footage. This will enable you to start building and testing computer vision with potentially already existing hardware.