Page 1 of 1

How to integrate Google Drive for 4K streaming

Posted: Tue May 16, 2017 10:49 pm
by vivant
Taking advantage of the rclone (, U5pvr could set up local sync folder for Google Drive and share the content including 4K UHD recording. In addition, rclone also supports Amazon S3/Openstack Swift/Dropbox/Amazon Drive/Microsoft OneDrive/Yandex etc.

All the following steps will be carried out on your laptop SSH by login to U5pvr with any SSH application with root/u5pvr.

1. Installing rclone

First, rclone uses the fuse file system to mount the file system which should be installed first. And the unzip package to unzip the zip files.

Apt-get install fuse unzip

Next, download the rclone binary from


To unzip the received file, type the following command:

# Unzip Enter rclone and press TAB key to autocomplete.
Cd cd rclone-v1.35-linux-arm

Once you unzip and navigate to the folder, move the binary file to the directory that is contained in your PATH environment variable so that it is convenient to run. It is moved to / usr / bin here as an example.

Cp rclone / usr / bin

# Permission is required, so set permissions below.
Chmod a + x / usr / bin / rclone

Next, check whether rclone runs normally.

If it is as below, it is installed normally.

Root @ u5pvr-debian: ~ # rclone version
2017/03/17 22:29:22 Config file "/root/.rclone.conf" not found - using defaults
Rclone v1.35

2. Link Google Drive

To create a mount folder, create a folder called / mnt / gdrive.

Mkdir / mnt / gdrive

Use the command below to connect Google Drive.

Root @ u5pvr-debian: ~ # rclone config
2017/03/17 22:32:17 Config file "/root/.rclone.conf" not found - using defaults
No remotes found - make a new one
N) New remote
S) Set configuration password
Q) Quit config
N / s / q> n
# Enter n as you need to create a new access point.

Name> Vivant (Enter any name preferred)

Type of storage to configure.
Choose a number from below, or type in your own value
1 / Amazon Drive
\ "Amazon cloud drive"
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
\ "S3 \"
3 / Backblaze B2
\ "B2 \"
4 / Dropbox
\ "Dropbox \"
5 / Encrypt / Decrypt a remote
\ "Crypt"
6 / Google Cloud Storage (this is not Google Drive)
\ "Google cloud storage \"
7 / Google Drive
\ "Drive"
8 / Hubic
\ "Hubic \"
9 / Local Disk
\ "Local \"
10 / Microsoft OneDrive
\ "Onedrive"
11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "Swift \"
12 / Yandex Disk
\ "Yandex \"
Storage> 7
Google Application Client Id - leave blank normally.
Google Application Client Secret - leave blank normally.
# Leave Client_id and Client_secret blank.

Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y did not work
Y) Yes
N) No
Y / n> n
# Choose "No"

If your browser does not open automatically, go to ... Aoauth%3A2. 0% 3Aoob & response_type = code & scope = https% 3A% 2F% 2Fauth% 2Fdrive & state = b02c34056754881ab1b1d15b4e5bf67d
Log in and authorize rclone for access
Enter verification code>

# Copy the link that appears on your screen and paste it to a browser if your browser does not open automatically. Login with your Google Drive username and password.

Screen should show to grant access to this point:

Copy and paste the code below.

If your browser does not open automatically, go to ... Aoauth%3A2. 0% 3Aoob & response_type = code & scope = https% 3A% 2F% 2Fauth% 2Fdrive & state = b02c34056754881ab1b1d15b4e5bf67d
Log in and authorize rclone for access
Enter verification code> ----------------------------------------------
# Paste the code you copied from your browser.

Client_id =
Client_secret =
Token = {"access_token": "------------------------------------------ -------------------------------------------------- -------------------------------------------------- ----------------- "," token_type ":" Bearer "," refresh_token ":" ------------------ ---------------------------- "," expiry ":" 2017-03-17T23: 39: 37.623176291 + 09: 00 "}
Y) Yes this is OK
E) Edit this remote
D) Delete this remote
Y / e / d> y
# Press y to confirm the setting.

Current remotes:

Name Type
==== ====
Vivant drive

E) Edit existing remote
N) New remote
D) Delete remote
S) Set configuration password
Q) Quit config
E / n / d / s / q> q
# When the setting is finished, press q to quit.

Root @ u5pvr-debian: ~ #

3. Mount Google Drive

Mount it with the command below.

# Share name set in last 2: (Skip) Enter the folder to mount.
# It is not in daemon format, so use nohup and & to keep it running even if the user shell exits.

Nohup rclone mount --allow-non-empty --allow-other --uid 1023 --gid 1028 --max-read-ahead 2G --acd-templink-threshold 0 --checkers 16 --quiet --stats 0 Djj9405: / mnt / gdrive / &

# On the other hand, uid and gid must be 1023 1028 because you have to match the Android file permissions.

The result of executing with the above command is as follows:

If you have any problems and you are forced to terminate the program, please refer to nohup.out in the current working folder to check the error contents.

Root @ u5pvr-debian: ~ # nohup rclone mount --allow-non-empty --allow-other --uid 1023 --gid 1028 --max-read-ahead 2G --acd-templink-threshold 0 --checkers 16 --quiet --stats 0 Vivant : / mnt / gdrive / &
[1] 29639
Root @ u5pvr-debian: ~ # nohup: ignoring input and appending output to 'nohup.out'

Root @ u5pvr-debian: ~ #

Root @ u5pvr-debian: / mnt / gdrive # ls
Call_record imei ?????? Torrent ????????? ?????? ???????????????????????????????? ?????????????????????????
# You will see files on Google Drive as normal.

(Note) Replace "Vivant" with the name you created.

4. Test Google Drive with U5pvr

By default, Linux firmware has built-in FTP and could be used to test.


Files should be synced to the internal HDD:


Try to download file from U5pvr to computer with FTP:


Try to upload files from computer to U5pvr by FTP:


The normal CPU usage is as follows.


Playback of files synced to Google Drive:



The following is test in Kodi:


The file is normally displayed as shown below.

I also tried to run this pink video. (4K VP9 60FPS)



5. Automount of Google Drive in U5pvr

This is an unstable method for those who do not have a wired LAN.
In case of wireless LAN, there is a delay until the connection is made, so if there is no network in the process of booting Linux, an error occurs.
However, in case of wired LAN, there is no problem because the network is attached before Linux booting.
(We'll create a script that checks for network status later in the process.)

By default, the /etc/rc.local file is used to enable autorun at boot time.

Nano /etc/rc.local

#! / Bin / sh -e
# Rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# Value on error.
# In order to enable or disable this script just change the execution
# Bits.
# By default this script does nothing.

# Hostname
/etc/init.d/ start

# Google drive mount
Mkdir / mnt / gdrive
Su root -c "nohup rclone mount --allow-non-empty --allow-other --uid 1023 --gid 1028 --max-read-ahead 10G --acd-templink-threshold 0 --che $

Exit 0