MacOS Automator Workflow for Dash Cam Script

  • Our merch store is back! Check out our line of quality apparel and accessories featuring the TOO logo. Let us know if you'd like something specific you don't see 👍https://teespring.com/stores/tesla-owners-online-store
  • It's OK to discuss software issues here but please report bugs to Tesla directly at servicehelpna@teslamotors.com if you want things fixed.
Joined
Nov 6, 2018
Messages
8
Location
Russellville, AR
Tesla Owner
Model 3
Country
Country
#1
Many thanks to eHendrix23 for the awesome script that merges the multiple dash cam video files into a single file for cohesive playback! If you haven't happened across that yet, find it here.

To compliment that script, I managed to piece together a workflow in the MacOS automator. The workflow automates running the (otherwise installed and functioning) eHendrix23 script on all the directories you select, eliminating the need to manually type and run the script from a terminal window.

Installation: Download and decompress/unzip the attached file (just double clicking should unzip it). Double click the unzipped file and you should get a prompt from the Quick Action Installer. Choose Install. The Quick Action Installer will place the workflow in your ~/Library/Services directory. This will make it available as a Quick Action on finder menus (the menu you see when you select one or more directories and use a "secondary click" (usually two finger tap on trackpad or right click of a mouse)).

Note that the automator workflow assumes that both the eHendrix23 tesla_dashcam python script AND the ffmpeg utility are resident in your top level user directory:

Screen Shot 2019-03-24 at 7.47.40 PM.png
If you have the tesla_dashcam script or ffmpeg located somewhere else, that's fine but you'll have to use Automator to modify the workflow's shell script to point to the right places.

Usage: With your USB drive or SSD attached to your Mac, select the directories containing saved dash cam footage you want to run the eHendrix23 script on. Use a secondary click/tap and choose "Process Tesla Dash Cam Video" from the context menu:

Screen Shot 2019-03-24 at 7.41.34 PM.png

The Automator workflow will do the following:
  1. The selected directories get copied to the Downloads directory (a good working directory everyone usually has).
  2. Once all selected directories are copied, the eHendrix23 script is invoked on them. One after another.
  3. The eHendrix23 script will produce its output file(s) on the desktop. These will appear one after the other as each directory is processed.
  4. Directories copied to the Downloads directory are removed. These are deleted one after the other as each is processed. Note that these will not appear in the trash can - they get permanently deleted. Files on your thumb drive or SSD attached to the Mac are left intact. You'll have to delete these yourself once satisfied that you've got what you want.
Additional notes: The eHendrix23 script allows several different options for merging video from the different cameras. The automator script doesn't give you choices. It's configured to use the fullscreen layout. Its doesn't use any other options (the time stamp is shown at bottom by default). If you want a different configuration, you'll have to use Automator to modify the workflow's shell script to invoke the options you want. Below is the shell script run by the Automator workflow is (f in "$@" refers to each directory in the list supplied as input):

for f in "$@"​
do​
~/tesla_dashcam --layout FULLSCREEN --ffmpeg ~/ffmpeg --output ~/Desktop/${f##*/} ~/Downloads/${f##*/}​
rm -f ~/Downloads/${f##*/}/*​
rmdir ~/Downloads/${f##*/}​
done​

Depending on the video(s) you’re processing, it could take a while to run. You can always tell it’s running by a spinning gear icon in the menu bar at the top of the screen (near the clock and WiFi signal strength of those are shown on your system).

I built this intending to process the many sub-directories found under "TeslaCam\SavedClips" on my Dash Cam USB stick. Hopefully this helps some others efficiently look at their similar footage. Sorry its limited to MacOS users only....thats just what I have.
 

Attachments

Last edited:

GDN

Moderator
Moderator
TOO Supporting Member
Joined
Oct 30, 2017
Messages
3,404
Location
Far North Dallas, TX
Tesla Owner
Model 3
Country
Country
#3
Very nice job - thanks !! I installed and actually duplicated it so that I could add "--speed 10" as an option. I first process the video at speed, if anything happens then I rerun the automator at normal speed to more closely evaluate anything I couldn't see the first time.
 

SR22pilot

Top-Contributor
Joined
Aug 15, 2018
Messages
495
Location
Alpharetta, GA
Tesla Owner
Model 3
Country
Country
#5
Note that the automator workflow assumes that both the eHendrix23 tesla_dashcam python script AND the ffmpeg utility are resident in your top level user directory:
Any particular reason you didn't look for the ffmpeg and eHendrix23 script in Applications?

Oh yes, a big "Thank you" for the script.
 
Last edited:

MelindaV

☰ > 3
Moderator
Joined
Apr 2, 2016
Messages
9,046
Location
Vancouver, WA
Tesla Owner
Model 3
Country
Country
#6
Many thanks to eHendrix23 for the awesome script that merges the multiple dash cam video files into a single file for cohesive playback! If you haven't happened across that yet, find it here.

To compliment that script, I managed to piece together a workflow in the MacOS automator. The workflow automates running the (otherwise installed and functioning) eHendrix23 script on all the directories you select, eliminating the need to manually type and run the script from a terminal window.

Installation: Download and decompress/unzip the attached file (just double clicking should unzip it). Double click the unzipped file and you should get a prompt from the Quick Action Installer. Choose Install. The Quick Action Installer will place the workflow in your ~/Library/Services directory. This will make it available as a Quick Action on finder menus (the menu you see when you select one or more directories and use a "secondary click" (usually two finger tap on trackpad or right click of a mouse)).

Note that the automator workflow assumes that both the eHendrix23 tesla_dashcam python script AND the ffmpeg utility are resident in your top level user directory:

View attachment 23826
If you have the tesla_dashcam script or ffmpeg located somewhere else, that's fine but you'll have use Automator to modify the workflow's shell script to point to the right places.

Usage: With your USB drive or SSD attached to your Mac, select the directories containing saved dash cam footage you want to run the eHendrix23 script on. Use a secondary click/tap and choose "Process Tesla Dash Cam Video" from the context menu:

View attachment 23830

The Automator workflow will do the following:
  1. The selected directories get copied to the Downloads directory (a good working directory everyone usually has).
  2. Once all selected directories are copied, the eHendrix23 script is invoked on them. One after another.
  3. The eHendrix23 script will produce its output file(s) on the desktop. These will appear one after the other as each directory is processed.
  4. Directories copied to the Downloads directory are removed. These are deleted one after the other as each is processed. Note that these will not appear in the trash can - they get permanently deleted. Files on your thumb drive or SSD attached to the Mac are left intact. You'll have to delete these yourself once satisfied that you've got what you want.
Additional notes: The eHendrix23 script allows several different options for merging video from the different cameras. The automator script doesn't give you choices. It's configured to use the fullscreen layout. Its doesn't use any other options (the time stamp is shown at bottom by default). If you want a different configuration, you'll have to use Automator to modify the workflow's shell script to invoke the options you want. Below is the shell script run by the Automator workflow is (f in "$@" refers to each directory in the list supplied as input):

for f in "$@"​
do​
~/tesla_dashcam --layout FULLSCREEN --ffmpeg ~/ffmpeg --output ~/Desktop/${f##*/} ~/Downloads/${f##*/}​
rm -f ~/Downloads/${f##*/}/*​
rmdir ~/Downloads/${f##*/}​
done​

I built this intending to process the many sub-directories found under "TeslaCam\SavedClips" on my Dash Cam USB stick. Hopefully this helps some others efficiently look at their similar footage. Sorry its limited to MacOS users only....thats just what I have.
first, thanks for sharing with everyone :)

now, for my issue(s).... I'm sure this is an edge case, but thought I'd mention it. For a reason I can not remember, I have "main" as part of my user profile name, and this seems to muck up what automator is looking for (or the eHendrix23 script). Creating a new test profile, all works perfectly. (maybe that is my cue to clean things up....)

on my "Melinda main" profile, I am getting the following error after it copies the folder from the flash drive to the Downloads folder:
Code:
tesla_dashcam: error: unrecognized arguments: /Users/melindav main/Downloads/2019-04-12_20-49-11
rm: /Users/melindav: Permission denied
rmdir: /Users/melindav: Not a directory
rmdir: main/Downloads/2019-04-12_20-49-11: No such file or directory”
It appears in some areas it is looking for "melindav main", others just "melindav" and one "main".
 

GDN

Moderator
Moderator
TOO Supporting Member
Joined
Oct 30, 2017
Messages
3,404
Location
Far North Dallas, TX
Tesla Owner
Model 3
Country
Country
#7
This is interesting, will learn from the linux experts here, but I believe you need some quotes around that directory so that it doesn't misinterpret the space between your name and main, but since it is being called in as a system variable not sure how you get the quotes around it. You sure as heck don't want it completing the command rm /users/melindav - that could be a disaster if it existed.
 

sduck

Active Member
Joined
Nov 22, 2017
Messages
137
Location
Nashville TN
Country
Country
#8
I think you need to add an "_" or delete that space between melindav and main. That space is going to throw it off. Changing user directory names in mac os x isn't as straightforward as you'd think - see this https://support.apple.com/en-us/HT201548 - but it might be worth it to do so if you want to get this working. User folders aren't supposed to have spaces in them, so it got added somehow after the fact.

And I've got this running now, and it seems to work well! Thanks! And to GDN, if you use quicktime to play back the files, or just about any other player, you can easily speed up the playback by clicking the right facing arrow while playing back - no need to process twice. You get the choices of 2, 5 and 10 times normal.

Warning: it's not a very fast process, can take several minutes to glue everything together. Be patient! Especially if you use it on the recent clips folder, with an hour of driving on it - I typed all of this post while it was doing that. The saved clips sentry mode folders go quicker.
 

GDN

Moderator
Moderator
TOO Supporting Member
Joined
Oct 30, 2017
Messages
3,404
Location
Far North Dallas, TX
Tesla Owner
Model 3
Country
Country
#9
And I've got this running now, and it seems to work well! Thanks! And to GDN, if you use quicktime to play back the files, or just about any other player, you can easily speed up the playback by clicking the right facing arrow while playing back - no need to process twice. You get the choices of 2, 5 and 10 times normal.
Big brain fart there - never thought about using the play back controls in Quicktime to process the regular video, wasn't even on my mind. However there is a big advantage of combining the files with "--speed 10" as it truly takes a fraction of the time to combine and process as it takes to combine the full videos at normal speed. Over the years I figure there won't be that many videos I need to really combine at normal speed to see what happened to the car. So combining at speed and watching saves CPU and a lot of time and I get what I need for about 98% of the cases.
 

sduck

Active Member
Joined
Nov 22, 2017
Messages
137
Location
Nashville TN
Country
Country
#10
Any particular reason you didn't look for the ffmpeg and eHendrix23 script in Applications?
It's pretty easy to modify the automator script to point it wherever to look for those files (as mentioned in the first post), if you feel the need to keep things neat (I will most likely do that at some point).
 

SR22pilot

Top-Contributor
Joined
Aug 15, 2018
Messages
495
Location
Alpharetta, GA
Tesla Owner
Model 3
Country
Country
#11
I am seeing a couple of issues. First, videos are flipped left to right. Just look at names on buildings. The read backwards but don't on the originals. Also, the video on the right side in the output files has issues. Besides getting very pixelated sometimes, it will go totally black. At first I was going to schedule a service appointment and have the camera looked at but so far the original video files seem fine. Screen Shot 2019-04-14 at 10.30.56 PM.png
 

GDN

Moderator
Moderator
TOO Supporting Member
Joined
Oct 30, 2017
Messages
3,404
Location
Far North Dallas, TX
Tesla Owner
Model 3
Country
Country
#12
I am seeing a couple of issues. First, videos are flipped left to right. Just look at names on buildings. The read backwards but don't on the originals. Also, the video on the right side in the output files has issues. Besides getting very pixelated sometimes, it will go totally black. At first I was going to schedule a service appointment and have the camera looked at but so far the original video files seem fine. View attachment 24815
The automator does a lot to handle the video file, cleaning up the intermediate files and presenting you with a very cool put together file. However my files that are blank are blank in the original as well. I had no problems for a few days and then pulled the SSD and put it back in and now I'm having problems with video recorded from the right repeater. I figure it is just the version of SW the car is on and will improve with the next release or two.

If you want to flip video and speed it up or present it different you need to edit the automator which is just executing the script written by @ehendrix23. Go to this post to see all of the options and what you can add for making them look like you are looking out the mirror or rear or widescreen, the options are listed here - https://teslaownersonline.com/threads/dashcam-video-script.11481/post-222823

Go to the top of that thread to see some of the different options. To use them with the automator, open the automator and add the options to the execution that meet your needs. I added a speed setting and --rear in what I execute. You can play and make it combine the videos for just how you like them.
 

batzman

Active Member
TOO Supporting Member
Joined
May 30, 2018
Messages
49
Location
Denver
Tesla Owner
Model 3
Country
Country
#13
I missed something somewhere and I am receiving an error. 1555300667152.png

As I am new to Automator, what am I missing from running the Automator from @atomitod?
 

GDN

Moderator
Moderator
TOO Supporting Member
Joined
Oct 30, 2017
Messages
3,404
Location
Far North Dallas, TX
Tesla Owner
Model 3
Country
Country
#14
Did you download and install the meat behind the automator? You must have the python and ffmpeg tools from @ehendrix23 installed as well. Go to post 1 of this thread and click on the Link to read through his thread. On page 4 or 5 of his thread you will find the latest download. You'll need that for the automator to work.
 

batzman

Active Member
TOO Supporting Member
Joined
May 30, 2018
Messages
49
Location
Denver
Tesla Owner
Model 3
Country
Country
#15
Ok, got it figured. I was asking to Automator to process two folders... one of which didn't have content (didn't know that). When I selected only one folder, which had content, everything worked fine. Nice set up. :) Thank you all.
 

batzman

Active Member
TOO Supporting Member
Joined
May 30, 2018
Messages
49
Location
Denver
Tesla Owner
Model 3
Country
Country
#16
Some items to note for my situation... although everything works... it only works when I select one folder that has content and then it saves the completed .mp4 in the same folder as the original files (on the thumbdrive) and not into the downloads folder.

If I select more than one folder it doesn't work and errors out as before.
If I select a folder that is not on my thumbdrive, then I do not have the ability (doesn't show up) to launch the automator

Thoughts?
 

garsh

Dis Member
Moderator
TOO Supporting Member
Joined
Apr 4, 2016
Messages
10,608
Location
Pittsburgh PA
Tesla Owner
Model 3
Country
Country
#17
I am seeing a couple of issues. First, videos are flipped left to right. Just look at names on buildings. The read backwards but don't on the originals.
I had assumed that this was being done on-purpose, to simulate a view from a side-view mirror.
 
Joined
Nov 6, 2018
Messages
8
Location
Russellville, AR
Tesla Owner
Model 3
Country
Country
#19
Some items to note for my situation... although everything works... it only works when I select one folder that has content and then it saves the completed .mp4 in the same folder as the original files (on the thumbdrive) and not into the downloads folder.

If I select more than one folder it doesn't work and errors out as before.
If I select a folder that is not on my thumbdrive, then I do not have the ability (doesn't show up) to launch the automator

Thoughts?
@batzman Did you modify the script or Automator workflow when you installed? As initially written, it would only copy directories you selected from their source location to your Downloads directory. The ehendrix23 script would then be executed on the those copied directories in Downloads. The Automator workflow included explicit instruction to the script to put the final video on the Desktop. I know the current ehendrix23 script functionality also now puts temporary files in the output directory (Desktop) that get cleaned up after execution. I don’t know of any reason the final video would end up anywhere other than the Desktop though, unless the Automator workflow’s shell commands were changed. Same for any writing to your Thumb drive. That shouldn’t be happening unless the Automator workflow or its shell commands changed somehow.
 

SR22pilot

Top-Contributor
Joined
Aug 15, 2018
Messages
495
Location
Alpharetta, GA
Tesla Owner
Model 3
Country
Country
#20
No particular reason. Just not where I tend to put those kind of programs.
I prefer to keep my top level directory clean and put executables in Applications but that is me. I haven't played with Automator before. I'll have a look.

I guess the rear view mirror comment made by someone makes some sense.

The blank screen I showed doesn't exist on the original. I'll check more files. I a only checked one. It is rather tedious to find the exact file to look at. It is always the right side image. It is also often noisy. I am doing this on a Macbook with a core i7 although 2 cores are assigned to Parallels. I'll run again and make sure Parallels isn't running.