Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Blackvue 900 dashcam video script

This site may earn commission on affiliate links.

BigD0g

Active Member
Jan 12, 2017
2,019
4,431
Somewhere
I installed a pair of BlackVue 900s in my car and wrote a script to download
the files and store them on my array.

The script will download all files to a root directory, the date and finally front or rear.

Note this script is for a quad channel set up aka 2 dual blackvue dash cams. Each
folder for the given location will have both dash cam channels for that camera.

So, with my particular setup the front folder will have the front dashcam video and the passenger right video.
The rear folder will have the rear dash cam and the passenger left video.

I pieced this together from a few internet sources and mixed and matched between them to improve the solution and allow for better throughput and better storage arragement

Sources:
Dashcam file auto download script
https://www.bjornsblog.nl/tips-and-...-from-blackvue-dashcam-to-your-synology-wifi/

If you have any questions feel free to ask, just offering this back to the community and hope it helps others.

I have this setup on a cronjob to run every night at 1am and 4am ( in case of broken connections), but the script will not duplicate files, so you can have this run more often if needed, it will also resume downloaded files that haven't finished automatically when run again for the same day in case the dash cam drops the connection which happens occasionally I found.

Code:
#!/bin/bash

#################################################################################################
#   This script is used to download blackvue dashcam files to the specified root storage directory.
#   No warranty express or implied comes with this script, and improvements or bugs for this script
#   please let the OP know so all can recieve the fix.
#
#    Files will be downloaded to the root directory then the date the file was captured and then a front
#    and rear folder will be created if dual dashcasm's are installed.
#
#    This script ONLY works with blackvue dashcams (tested on 900S, but should work on 600 and later models)
#
#    -- BigD0g
#################################################################################################

#The top level directory of where to store your dashcam files
DASHCAM_ROOT_STORAGE=~/jarvis-dashcam

#The IP Address of the FRONT blackvue dashcam
DASHCAM_FRONT_IP=192.168.0.21

#The IP Address of the REAR blackvue dashcam if installed aka 4 channel install 2 seperate blackvues
DASHCAM_REAR_IP=192.168.0.22

export BVDATE=`date +%Y%m%d`
echo $BVDATE

function downloadTodaysFiles() {
    
    count=$(ping -c4 $1 | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}')

    if [ $count -eq 4 ]; then
        echo "Successful connection! for " $1
        cd $DASHCAM_ROOT_STORAGE/$BVDATE/$2
        for file in `curl http://$1/blackvue_vod.cgi | sed 's/^n://' | sed 's/F.mp4//' | sed 's/R.mp4//' | sed 's/,s:1000000//' | sed $'s/\r//' | grep $BVDATE`; do
            wget -c http://$1$file\F.mp4;
            wget -c http://$1$file\R.mp4;
            wget -nc http://$1$file\F.thm;
            wget -nc http://$1$file\R.thm;
            wget -nc http://$1$file.gps;
            wget -nc http://$1$file.3gf;
        done
    fi
    
}

#Setup directories for todays files
if [ ! -d "$DASHCAM_ROOT_STORAGE/$BVDATE" ]; then
  mkdir -p $DASHCAM_ROOT_STORAGE/$BVDATE/front
  mkdir $DASHCAM_ROOT_STORAGE/$BVDATE/rear
fi

#Set this one off into the background so we can do both cameras at the sametime.
downloadTodaysFiles $DASHCAM_FRONT_IP front &

#If you do not have a second blackvue installed delete this next line
downloadTodaysFiles $DASHCAM_REAR_IP rear &

exit 0
 
Can you comment on the file sizes of your new 4k camera? Also, how long will you keep files on your array?

Just curious why download them all instead of have the dashcam loop over the oldest recordings when it gets full?
 
Apologies! found some bugs, new code, and now it's serialized, just use 2 crontab one for each dash cam less error prone.

Code:
#!/bin/bash

#################################################################################################
#   This script is used to download blackvue dashcam files to the specified root storage directory.
#   No warranty express or implied comes with this script, and improvements or bugs for this script
#   please let the OP know so all can recieve the fix.
#
#   The script will download yesterday and today's files and due to the use of wget will not duplicate
#   file downloads.
#
#   Files will be downloaded to the root directory then the date the file was captured and then a front
#   and rear folder will be created if dual dashcasm's are installed.
#
#   This script ONLY works with blackvue dashcams (tested on 900S, but should work on 600 and later models)
#
#    -- BigD0g
#################################################################################################

#The top level directory of where to store your dashcam files
DASHCAM_ROOT_STORAGE=/media/shared/tesla/dashcam

#The IP Address of the FRONT blackvue dashcam
DASHCAM_FRONT_IP=192.168.0.21

#The IP Address of the REAR blackvue dashcam if installed aka 4 channel install 2 seperate blackvues
DASHCAM_REAR_IP=192.168.0.22

export BVDATE=`date '+%Y%m%d'`
echo $BVDATE

export YESTERDAYDATE=`date -d "1 day ago" '+%Y%m%d'`
echo $YESTERDAYDATE

function downloadSpecifiedFileDates() {

    #Setup directories for files by date
    if [ ! -d "$DASHCAM_ROOT_STORAGE/$YESTERDAYDATE" ]; then
        mkdir -p $DASHCAM_ROOT_STORAGE/$YESTERDAYDATE/front
        mkdir $DASHCAM_ROOT_STORAGE/$YESTERDAYDATE/rear
    fi

    if [ ! -d "$DASHCAM_ROOT_STORAGE/$BVDATE" ]; then
        mkdir -p $DASHCAM_ROOT_STORAGE/$BVDATE/front
        mkdir $DASHCAM_ROOT_STORAGE/$BVDATE/rear
    fi

    count=$(ping -c4 $1 | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}')

    if [ $count -eq 4 ]; then
        echo "Successful connection! for " $1
        for file in `curl http://$1/blackvue_vod.cgi | sed 's/^n://' | sed 's/F.mp4//' | sed 's/R.mp4//' | sed 's/,s:1000000//' | sed $'s/\r//' | grep $2`; do
            wget -P $DASHCAM_ROOT_STORAGE/$2/$3 -c http://$1$file\F.mp4;
            wget -P $DASHCAM_ROOT_STORAGE/$2/$3 -c http://$1$file\R.mp4;
            wget -P $DASHCAM_ROOT_STORAGE/$2/$3 -nc http://$1$file\F.thm;
            wget -P $DASHCAM_ROOT_STORAGE/$2/$3 -nc http://$1$file\R.thm;
wget -P $DASHCAM_ROOT_STORAGE/$2/$3 -nc http://$1$file.gps;
            wget -P $DASHCAM_ROOT_STORAGE/$2/$3 -nc http://$1$file.3gf;
        done
    fi

}

#Set this one off into the background so we can do both cameras at the sametime.
downloadSpecifiedFileDates $DASHCAM_FRONT_IP $YESTERDAYDATE front
downloadSpecifiedFileDates $DASHCAM_FRONT_IP $BVDATE front

#downloadSpecifiedFileDates $DASHCAM_REAR_IP $YESTERDAYDATE rear
#downloadSpecifiedFileDates $DASHCAN_REAR_IP $BVDATE rear

exit 0
 
  • Love
Reactions: johndorian
Can you comment on the file sizes of your new 4k camera? Also, how long will you keep files on your array?

Just curious why download them all instead of have the dashcam loop over the oldest recordings when it gets full?

Roughly 237mb / 3 min segment

I'm going to keep them for two weeks before the system auto deletes them unless I purposely move them to a save directory.

I'm definitely letting the dash cam loop over them, but the blackvue cloud doesn't allow you to have a unified view of the dual dash cams without paying there subscription fee, so this allows me to have a central location to review the full 360 view of the car if needed.

Hopefully, it will never be needed, but it was fun to geek out while folks were napping, hence the silly bugs that have gone unnoticed until I published this.... :D:eek:
 
I can't seem to be able to get this working, anyone able to lend a hand ? I'm not used to working with scrips and I'm not sure how to get this working properly. I've successfully set a static-IP for my BlackVue 750, and I'm trying to get it to auto-download to a directory on an external HD on my Mac whenever I run the script. Running the script with terminal yields a few errors: "mkdir: Permission denied," and quite a few line errors "wget: command not found." Am I doing something completely wrong? Thanks to anyone willing to help walk a noob through this.
 
I can't seem to be able to get this working, anyone able to lend a hand ? I'm not used to working with scrips and I'm not sure how to get this working properly. I've successfully set a static-IP for my BlackVue 750, and I'm trying to get it to auto-download to a directory on an external HD on my Mac whenever I run the script. Running the script with terminal yields a few errors: "mkdir: Permission denied," and quite a few line errors "wget: command not found." Am I doing something completely wrong? Thanks to anyone willing to help walk a noob through this.

brew install wget

As for your permission errors, that’s the script not being able to write / create the directories, make sure the path exists and the user running the script has full permissions
 
I absolutely love BigD0g's script. It opened up a whole new world for me - and I am NOT that technical..
I pull in the garage, the files dump to a server. Another script grabs screen shots of every 500th frame from the files and puts them in another folder. Media player constantly cycles through those screen shots on my kitchen tablet sitting on the counter - 24X7.
Screen grabs and the 3-minute BlackVue files older than 45 days get deleted each night.

I thought it would be handy to catch any incident/accident/event such as theft, vandalism, etc..
Turned out to be fantastic entertainment instead!
Skateborder hitting a lamp post
Construction worker peeing into a bucket while he's up on a lift
Ex-girlfriend driving up to my car and thinking about what to do next
Bear stepping out of the woods to take a dump!
So much more..

I've actually come to think of this as a feature of my MS. In truth it has nothing to do with the make of car.
Someday, BlackVue or some other company is going to turn this into a standard feature!
 
  • Like
Reactions: BigD0g
I absolutely love BigD0g's script. It opened up a whole new world for me - and I am NOT that technical..
I pull in the garage, the files dump to a server. Another script grabs screen shots of every 500th frame from the files and puts them in another folder. Media player constantly cycles through those screen shots on my kitchen tablet sitting on the counter - 24X7.
Screen grabs and the 3-minute BlackVue files older than 45 days get deleted each night.

I thought it would be handy to catch any incident/accident/event such as theft, vandalism, etc..
Turned out to be fantastic entertainment instead!
Skateborder hitting a lamp post
Construction worker peeing into a bucket while he's up on a lift
Ex-girlfriend driving up to my car and thinking about what to do next
Bear stepping out of the woods to take a dump!
So much more..

I've actually come to think of this as a feature of my MS. In truth it has nothing to do with the make of car.
Someday, BlackVue or some other company is going to turn this into a standard feature!

Glad you like it and it's adding value!
 
I keep getting a weird error over and over... what am I doing wrong?

Cannot write to ‘/Documents/BlackVue/Shared/20190420/front/20190420_092058_E.gps’ (No such file or directory).

--2019-04-20 13:51:27-- http://192.168.87.66/Record/20190420_092058_E.3gf

Connecting to 192.168.87.66:80...

connected.

HTTP request sent, awaiting response... 200 OK

Length: 5930 (5.8K) [text/plain]

/Documents/BlackVue/Shared/20190420/front: No such file or directory

/Documents/BlackVue/Shared/20190420/front/20190420_092058_E.3gf: No such file or directory