-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump version to 2.0.0, various new features:
- Multiple input files supported - Better error messages - Attempts to use FFmpeg if available locally to generate a .MP4 file - Support to extract only the raw bitstreams with --raw argument - Support for extracting audio if executed with --with-audio argument - Code to run external tools (ubnt_ubvinfo and ffmpeg) try to find it on your PATH, and if not available tries some static locations where they may be found N.B. it doesn't look like video framerate is available within the .ubv, so this tool attempts to detect it. This relies on the framerate staying constant throughout playback (Protect allows camera framerates to be changed on the fly without breaking the .ubv into another partition).
- Loading branch information
1 parent
010c49b
commit 6ff7004
Showing
25 changed files
with
1,910 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ atlassian-ide-plugin.xml | |
~* | ||
*.swp | ||
Makefile.local | ||
src/test/java/ManualProgramInvocation.java |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
Overview | ||
======== | ||
|
||
This is a tool that converts Ubiquiti's proprietary .ubv files into standard .MP4 files with H.264 and AAC. The conversion is a remux: no transcoding takes place, the exact same video and audio essence are placed into a different container; because of this the process is reasonably fast and not CPU intensive even on a low spec ARM machine. | ||
|
||
Native binaries are available for Linux 64-bit ARM and x86 architectures. Most people should use ARM64 on their Ubiquiti hardware. | ||
|
||
Please look in the github "releases" page at https://github.com/petergeneric/unifi-protect-remux/releases for builds of the latest version. | ||
|
||
Latest Features | ||
--------------- | ||
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): | ||
|
||
1. 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") | ||
2. 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``` | ||
3. Download the latest FFmpeg ARM Static Release (available on the releases page, and also from https://johnvansickle.com/ffmpeg/) | ||
4. 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``` | ||
5. 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) | ||
6. Navigate to where your .ubv video is located (base path: /srv/unifi-protect/video). | ||
7. Run: ```remux-amd64 *.ubv``` | ||
8. 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. | ||
|
||
|
||
FINDING SOURCE MEDIA | ||
==================== | ||
|
||
This tool works on .ubv files but is primarily designed to work on "_0_rotating_" .ubv files. You can get a list of these files with the following on your Unifi Protect system: | ||
|
||
``` | ||
find /srv/unifi-protect/video -type f -name "*_0_rotating_*.ubv" | ||
``` | ||
|
||
RUNNING | ||
======= | ||
|
||
Entirely locally | ||
---------------- | ||
|
||
If you have a version of ```ubnt_ubvinfo``` and FFmpeg that runs on your system (and it's on your PATH), you can simply run ```remux somefile.ubv``` | ||
|
||
Run ubvinfo remotely and remux locally | ||
-------------------------------------- | ||
|
||
For better performance (and lower IO and memory overhead on your Unifi Protect server) you can use ubnt_ubvinfo on your Unifi Protect system, writing the output to a .txt file on disk. | ||
A helper script is provided for this: | ||
|
||
1. Simply copy ```prepare.sh``` to your Unifi Protect system and then run ```prepare.sh *.ubv``` | ||
2. Next, transfer the .ubv and the .ubv.txt file(s) back to your main system. | ||
3. Finally, run the remux binary locally on the .ubv file; the tool will automatically find and use the .ubv.txt file prepared on your Protect system. | ||
|
||
|
||
BUILD FROM SOURCE | ||
================= | ||
|
||
Simply run "mvn package" to produce a .jar that can be executed. To use it, just run ```java -jar target/remux*.jar --help``` | ||
|
||
Build Native Binary | ||
------------------- | ||
|
||
You can build a native binary using GraalVM's native-image tool. Instructions on how to install the dependencies are at: | ||
|
||
https://www.graalvm.org/docs/reference-manual/native-image/ | ||
|
||
The installation steps as of the time of writing were: | ||
1. Download latest release from https://github.com/graalvm/graalvm-ce-builds/releases | ||
2. Unpack, put /path/to/graal/bin on your ATH | ||
3. Run ```gu install native-image``` | ||
|
||
N.B. for Ubuntu you'll also need the following packages: | ||
``` | ||
# N.B. Depending on your ubuntu version, you may need zlib1g-dev instead of libz-dev | ||
apt install build-essential libz-dev | ||
``` | ||
|
||
Make Graal your default JVM and put it on your PATH: | ||
|
||
``` | ||
export JAVA_HOME=/path/to/graal | ||
export PATH=$JAVA_HOME/bin:$PATH | ||
``` | ||
|
||
You'll also need Apache Maven 3.6.x installed and placed on your PATH | ||
|
||
Then simply run ```make native-image```, which will run a Maven build and generate a binary via Graal. This process can take some time on slower ARM servers (e.g. Raspberry Pi 4) | ||
|
||
DEPENDENCIES | ||
============ | ||
|
||
FFmpeg | ||
------ | ||
This tool extracts bare audio/video bitstreams, and relies on FFmpeg to mux them into an MP4. | ||
|
||
You can install FFmpeg on Ubuntu with: | ||
|
||
``` | ||
apt install ffmpeg | ||
``` | ||
|
||
There are also several FFmpeg static builds available, see https://ffmpeg.org/download.html |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# This script is designed to prepare a .txt file with .ubv structure info on a CloudKey Gen2 | ||
# to allow the execution of remux-amd64 on another machine (e.g. with more IO and with FFmpeg available) | ||
# | ||
|
||
if [ -z "$UBVINFO" ] ; then | ||
UBVINFO=/usr/share/unifi-protect/app/node_modules/.bin/ubnt_ubvinfo | ||
fi | ||
|
||
function helptext() { | ||
echo "Usage: $0 *_0_rotating_*.ubv" | ||
} | ||
|
||
if [ -z "$1" ] ; then | ||
helptext | ||
|
||
exit 1 | ||
elif [ "$1" == "--help" ] ; then | ||
helptext | ||
|
||
exit 0 | ||
fi | ||
|
||
|
||
while [ -n "$1" ] | ||
do | ||
$UBVINFO -t 7 -P -f "$1" > "$1.txt" | ||
if [ "$?" != "0" ] ; then | ||
echo "ubnt_ubvinfo invocation failed!" >&2 | ||
exit 1 | ||
fi | ||
|
||
shift | ||
done |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.