2.0.0: Extract Video and Audio into MP4
This release supports audio, and if FFmpeg is available then it will create MP4 files. Currently it will create one MP4 for each partition of a multi-partition .ubv, naming the files based on the date+time the video starts.
Audio muxing is new; it should account for audio/video synchronisation, however this has not been extensively tested (I don't have any camera samples where AV sync is particularly obvious). If you're experiencing issues and can supply a .ubv for me to examine please raise an issue and get in touch.
QUICK START: FOR UBIQUITI HARDWARE
Instructions for Cloud Key Gen 2 Plus (and other Ubiquiti hardware):
- Go to the "releases" page at https://github.com/petergeneric/unifi-protect-remux/releases and download the latest remux-arm64 binary (N.B. "ARM64", not "AMD64")
- Upload this to your Cloud Key home folder using SSH (SCP) and extract with
tar -xf remux-arm64.tar.gz && rm remux-arm64.tar.gz && chmod +x remux-arm64
- Download the latest FFmpeg ARM Static Release (available on the releases page, and also from https://johnvansickle.com/ffmpeg/)
- Upload this to your Cloud Key and extract it with
xz -d ffmpeg-release-arm64-static.tar.xz && tar -xf ffmpeg-release-arm64-static.tar && mv ffmpeg*arm64-static/ffmpeg ./ && rm ffmpeg-release-arm64-static.tar.xz && chmod +x ffmpeg
- Run the following on your cloudkey:
export PATH=$HOME:$PATH
(you'll either need to run this every time you log in or put it in your .bashrc file) - Navigate to where your .ubv video is located (base path: /srv/unifi-protect/video).
- Run:
remux-amd64 *.ubv
- By default, only video is extracted. If you need to extract audio too, add "--with-audio" to your command
If FFmpeg is not installed (or if the command fails) the remux tool will leave the raw .aac and .h264 bitstream files; these can be combined with a variety of tools.
NOTE ON AMD64 VERSION
If you have the old (unsupported) x86 version of Protect, extract the ubnt_ubvinfo tool from that (see the path referenced in the scripts/ folder of this repo) and put it in your PATH and you can use the AMD64 binary. This will be significantly faster than running on a Cloud Key. For copyright reasons I can't supply this tool.
If you don't have the x86 Protect installer, you can run some key tasks on your Ubiquiti gear (see the scripts folder). These scripts generate a summary .txt file that you can pull back alongside the .ubv and run remux-amd64 on your x86 machine.
Known Issues
In order to create an MP4 the tool has to detect the framerate of the video; it works this out by looking at the time between the initial video frames. This should work unless the framerate is changed mid-video. In this case some of the video may appear to run faster or slower than realtime. This seems a pretty unusual case so I'm not planning special logic for it any time soon!