Skip to content

Commit

Permalink
Update README.md with instructions on how to run the ARM64 version of…
Browse files Browse the repository at this point in the history
… ubnt_ubvinfo on x86 using qemu-user
  • Loading branch information
petergeneric committed Oct 6, 2020
1 parent c1ecd99 commit a789509
Showing 1 changed file with 75 additions and 11 deletions.
86 changes: 75 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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. Most people should use ARM64 and run this on their Ubiquiti hardware.
Native binaries are available. The easiest way (but worst performing) is to follow the "Quick Start For Ubiquiti Hardware" section. More advanced users can follow the instructions for x86 using qemu.

Please look in the github "releases" page at https://github.com/petergeneric/unifi-protect-remux/releases for builds of the latest version.

Expand All @@ -15,27 +15,91 @@ This release supports audio, and if FFmpeg is available then it will create MP4

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):
==================================
Instructions for Cloud Key Gen 2 Plus (and other Ubiquiti hardware). Due to the relatively slow CPU and IO subsystems, running a remux this way will be somewhat slow. See below for instructions on how to run under Linux x86 below.

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```
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 "x86")
2. Upload this to your Cloud Key home folder using SSH (SCP) with ```tar -xf remux-arm64.tar.gz && rm remux-arm64.tar.gz && chmod +x remux```
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)
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 *.ubv```
8. By default, only video is extracted. If you need to extract audio too, add "--with-audio" to your command
8. By default, only video is extracted. If you need to extract audio too, add "--with-audio=true" 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.


QUICK START: FOR x86 LINUX
==========================

Dependencies: ubnt_ubvinfo from CloudKey
----------------------------------------
N.B. If you have files from a (discontinued, unsupported) x86 Protect installation, you can use the native x86 ```ubnt_ubvinfo``` tool from it - just copy that file to ```/usr/bin/ubnt_ubvinfo```. Otherwise, the following instructions will let you run the ARM binary on your x86 machine at a slight performance penalty using QEMU.
(These instructions are Ubuntu/Debian specific; pull requests welcome for CentOS/Arch equivalent)

1. On your x86 machine, install qemu-user with: ```apt install -y qemu-user gcc-aarch64-linux-gnu```
2. Copy ```/usr/share/unifi-protect/app/node_modules/.bin/ubnt_ubvinfo``` from your CloudKey to ```/usr/bin/arm-ubnt_ubvinfo``` on your x86 machine
3. Run the following:
```
sudo tee /usr/bin/ubnt_ubvinfo <<EOF
#!/bin/sh
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu
exec qemu-aarch64 /usr/bin/arm-ubnt_ubvinfo $*
EOF
chmod +x /usr/bin/ubnt_ubvinfo
```

Dependencies: FFmpeg
------------------------
(These instructions are Ubuntu/Debian specific; pull requests welcome for CentOS/Arch equivalent)

To install FFmpeg, run:
```
apt install -y ffmpeg
```

Extracting video
----------------
Once the dependencies are installed, use the following instructions to get the unifi-protect-remux tool working:

1. Go to the "releases" page at https://github.com/petergeneric/unifi-protect-remux/releases and download the latest remux x86_64 binary
2. Upload this to your Linux server and extract with ```tar -zxf remux-x86_64.tar.gz```
3. Transfer .ubv files from your CloudKey to your x86 server (on cloudkey, .ubv files are found under /srv/unifi-protect/video).
4. Run: ```remux *.ubv```
5. By default, only video is extracted. If you need to extract audio too, add "--with-audio=true" 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.
Command-line arguments
======================

```
Usage of remux:
-with-audio
If true, extract audio
-with-video
If true, extract video (default true)
-mp4
If true, will create an MP4 as output (default true)
-output-folder string
The path to output remuxed files to. "SRC-FOLDER" to put alongside .ubv files (default "./")
-version
Display version and quit
-force-rate int
If non-zero, adds a -r argument to FFmpeg invocations
```

NOTE ON x86 WITHOUT QEMU
=======================

The quickstart instructions above show how to run the AARCH64 ubnt_ubvinfo tool shipped with Unifi Protect on your x86 hardware. This relies on qemu-user. If this tool is not available on your x86 machine (and you don't have the native x86 version of ubnt_ubvinfo -- for copyright reasons I can't supply this tool) then you will need to run the ubnt_ubvinfo command on your Ubiquiti hardware, then transfer the .ubv files along with a cached output of ubnt_ubvinfo to your x86 machine for final extraction.

See the scripts folder in the repository: these scripts generate a summary .txt file that you can pull back alongside the .ubv and run ```remux``` on your x86 machine.

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
Expand Down

0 comments on commit a789509

Please sign in to comment.