Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene-Sackers committed Jul 28, 2023
2 parents b1a632f + 493972c commit 4a40a54
Show file tree
Hide file tree
Showing 19 changed files with 202 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ jobs:
name: release-sc
path: "./publish/${{env.ZIP_FILE_NAME}}"

# Self contained version is larger than self-contained + compressed, no need to build this version
windows-dependant:
runs-on: ubuntu-latest
if: false
needs: version
env:
VERSION: ${{needs.version.outputs.VERSION}}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,5 @@ FodyWeavers.xsd
*.sln.iml

*.css
.idea/
.idea/
appsettings.*.json
75 changes: 59 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,41 @@ First release, still needs some work, but functional and might be just what you

### Implemented

* Infinite scrolling list of events (virtualized)
* Icons to easily identify events (sentry/dashcam/honk/movement detected/manual save)
* Calendar to easily go to a certain date
* Auto scaling viewer
* Supports MCU-1 (3 camera, missing back cam) and/or missing/corrupt angles
- Infinite scrolling list of events (virtualized)
- Icons to easily identify events (sentry/dashcam/honk/movement detected/manual save)
- Calendar to easily go to a certain date
- Auto scaling viewer
- Supports MCU-1 (3 camera, missing back cam) and/or missing/corrupt angles
- Event time marker on timeline
- Filtering events
- RecentClips viewing

### TODO/missing

* Event time marker on timeline
* Mobile viewport support
* Progress bar for loading. Initial load checks the length of each video file, this may take a moment.
* Filtering events
* RecentClips viewing
* Map for event location
* Exporting clips
* General small issues
- Mobile viewport support
- Progress bar for loading. Initial load checks the length of each video file, this may take a moment.
- Map for event location
- Exporting clips
- General small issues

## Windows

The Windows build is a self-contained .exe, you do not need to install .NET, as it's compiled into the executable.

Download the latest version from [releases](https://github.com/Rene-Sackers/TeslaCamPlayer/releases/tag/v2023.7.23.1431) (teslacamplayer-win-x64-\*.zip) and extract the zip.

Modify `appsettings.json`, change the value for `ClipsRootPath`, set it to the path that contains your TeslaCam videos, and escape the \\ directory character with another \\ For example:

```json
{
...
"AllowedHosts": "*",
"ClipsRootPath": "D:\\Some\\Folder\\TeslaCam"
}

```

Run `TeslaCamPlayer.BlazorHosted.Server.exe` and navigate to `http://localhost:5000` in your browser.

## Docker

Expand All @@ -41,9 +60,9 @@ docker run \

### Environment variables

| Variable | Example | Description |
| ------------- | --------- | -------------------------------------------------------- |
| ClipsRootPath | /TeslaCam | The path to the root of the clips mount in the container |
| Variable | Example | Description |
| ------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| ClipsRootPath | /TeslaCam | The path to the root of the clips mount in the container. This is set by default, you do not need to change it if you mount the volume to this path. |

### Volumes

Expand All @@ -56,3 +75,27 @@ docker run \
| Port | Description |
| ---- | --------------------------- |
| 80 | The HTTP web interface port |

# Legal

pls no sue kthx

## Tesla

This software is in no way, shape or form affiliated with Tesla, Inc. (https://www.tesla.com/), or its products.
This software is not:

- An official Tesla product
- Licensed by Tesla
- Built by or in conjunction with Tesla
- Commisioned by Tesla

It does not directly impact Tesla products. It is an aftermarket piece of software that processes data produced by Tesla vehicles.

## FFmpeg

This software uses libraries from the FFmpeg project under the LGPLv2.1
The Windows build of this software includes a copy of ffprobe.exe, compiled by: https://github.com/BtbN/FFmpeg-Builds/releases
More info and sources for FFmpeg can be found on: https://ffmpeg.org/

[def]: releases
10 changes: 5 additions & 5 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS publish
COPY . /src
WORKDIR "/src/TeslaCamPlayer.BlazorHosted/Server"
RUN dotnet restore .
RUN dotnet build *.csproj -c Release -o /app/build /p:DefineConstants=DOCKER

FROM build AS publish
RUN dotnet publish *.csproj -c Release -o /app/publish /p:DefineConstants=DOCKER
# Remove ffprobe.exe from docker builds. It relies on an apt package instead.
RUN rm -r /app/publish/lib/

FROM node:17 AS gulp
WORKDIR /src
Expand All @@ -17,9 +16,10 @@ RUN npm install -g gulp
RUN gulp default

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS final
RUN apt-get update && apt-get install -y ffmpeg
RUN apt-get update && apt-get install -y ffmpeg --no-install-recommends
WORKDIR /app
ENV ClipsRootPath=/TeslaCam
EXPOSE 80/tcp
COPY --from=publish /app/publish .
COPY --from=gulp /src/wwwroot/css/ ./wwwroot/css/

Expand Down
21 changes: 12 additions & 9 deletions src/TeslaCamPlayer.BlazorHosted/Client/Components/ClipViewer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
<MudIconButton Icon="@(_isPlaying ? Icons.Material.Filled.PauseCircleOutline : Icons.Material.Filled.PlayCircleOutline)" Size="Size.Large" OnClick="PlayPauseClicked" />
<MudIconButton Icon="@Icons.Material.Filled.SkipNext" Size="Size.Medium" OnClick="@NextButtonClicked" />
</div>
<MudSlider
T="double"
@ref="_timelineSlider"
Max="@_timelineMaxSeconds"
Step="0.1"
@bind-Value="@TimelineValue"
Variant="Variant.Filled"
@onpointerdown="@TimelineSliderMouseDown"
@onpointerup="@TimelineSliderMouseUp"/>
<div class="seeker-slider-container">
<MudSlider
T="double"
@ref="_timelineSlider"
Max="@_timelineMaxSeconds"
Step="0.01"
@bind-Value="@TimelineValue"
Variant="Variant.Filled"
@onpointerdown="@TimelineSliderMouseDown"
@onpointerup="@TimelineSliderMouseUp"/>
<div class="event-marker" style="@EventMarkerStyle()"></div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private double TimelineValue

protected override void OnInitialized()
{
_setVideoTimeDebounceTimer = new(100);
_setVideoTimeDebounceTimer = new(500);
_setVideoTimeDebounceTimer.Elapsed += ScrubVideoDebounceTick;
}

Expand Down Expand Up @@ -194,6 +194,16 @@ private async Task ScrubToSliderTime()
{
// ignore, happens sometimes
}

}

private string EventMarkerStyle()
{
if (_clip?.Event?.Timestamp == null)
return "display: none";

var percentageOfClipAtTimestamp = Math.Round(_clip.Event.Timestamp.Subtract(_clip.StartDate).TotalSeconds / _clip.TotalSeconds * 100, 2);
percentageOfClipAtTimestamp = Math.Clamp(percentageOfClipAtTimestamp, 0, 100);

return $"left: {percentageOfClipAtTimestamp}%";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
class="@Class
@(string.IsNullOrWhiteSpace(Src) ? "d-none" : null)"
@onended="@VideoEndedHandler"
@ontimeupdate="@TimeUpdateHandler"></video>
@ontimeupdate="@TimeUpdateHandler"
disableremoteplayback></video>

@code {
[Inject]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,28 @@ public class EventFilterValues

public bool IsInFilter(Clip clip)
{
if (DashcamHonk && clip.Event.Reason == CamEvents.UserInteractionHonk)
if (Recent && clip.Type == ClipType.Recent)
return true;

if (DashcamHonk && clip.Event?.Reason == CamEvents.UserInteractionHonk)
return true;

if (DashcamSaved && (clip.Event.Reason == CamEvents.UserInteractionDashcamPanelSave || clip.Event.Reason == CamEvents.UserInteractionDashcamIconTapped))
if (DashcamSaved && clip.Event?.Reason is CamEvents.UserInteractionDashcamPanelSave or CamEvents.UserInteractionDashcamIconTapped)
return true;

if (DashcamOther && clip.Type == ClipType.Saved)
return true;

if (SentryObjectDetection && clip.Event.Reason == CamEvents.SentryAwareObjectDetection)
if (SentryObjectDetection && clip.Event?.Reason == CamEvents.SentryAwareObjectDetection)
return true;

if (SentryAccelerationDetection && clip.Event.Reason.StartsWith(CamEvents.SentryAwareAccelerationPrefix))
if (SentryAccelerationDetection && clip.Event?.Reason?.StartsWith(CamEvents.SentryAwareAccelerationPrefix) == true)
return true;

if (SentryOther && clip.Type == ClipType.Sentry)
return true;

return Recent && clip.Type == ClipType.Recent;
return false;
}
}
}
2 changes: 1 addition & 1 deletion src/TeslaCamPlayer.BlazorHosted/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ else
}
</div>
<div class="date">
@context.Event.Timestamp.ToString("yyyy-MM-dd HH:mm:ss")
@((context.Event?.Timestamp ?? context.StartDate).ToString("yyyy-MM-dd HH:mm:ss"))
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</ItemGroup>

<ItemGroup>
<Folder Include="ExtensionMethods\" />
<Folder Include="wwwroot\css\" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@
align-items: center;
}

.mud-slider {
.seeker-slider-container {
position: relative;
display: flex;
width: 80%;

.event-marker {
$size: 20px;
width: $size;
height: $size;
border-radius: calc($size / 2);
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
background-color: adjust-color(#f64e62ff, $alpha: -0.5);
pointer-events: none;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Web;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using TeslaCamPlayer.BlazorHosted.Server.Providers.Interfaces;
using TeslaCamPlayer.BlazorHosted.Server.Services.Interfaces;
using TeslaCamPlayer.BlazorHosted.Shared.Models;
Expand Down
12 changes: 12 additions & 0 deletions src/TeslaCamPlayer.BlazorHosted/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@

var app = builder.Build();

var clipsRootPath = app.Services.GetService<ISettingsProvider>()!.Settings.ClipsRootPath;
try
{
if (!Directory.Exists(clipsRootPath))
throw new Exception("Configured clips root path doesn't exist, or no permission to access: " + clipsRootPath);
}
catch (Exception e)
{
Log.Fatal(e, e.Message);
return;
}

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ClipsRootPath": "D:\\TeslaCam\\MCU-2\\TeslaCam"
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
Expand All @@ -15,8 +14,7 @@
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ClipsRootPath": "D:\\TeslaCam"
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
Expand All @@ -26,8 +24,7 @@
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ClipsRootPath": "D:\\TeslaCam\\MCU-2\\TeslaCam"
"ASPNETCORE_ENVIRONMENT": "Development"
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class SettingsProvider : ISettingsProvider

private static Settings SettingsValueFactory() =>
new ConfigurationBuilder()
.AddJsonFile(Path.Combine(AppContext.BaseDirectory, "appsettings.json"), optional: true)
.AddJsonFile(Path.Combine(AppContext.BaseDirectory, "appsettings.Development.json"), optional: true)
.AddEnvironmentVariables()
.Build()
.Get<Settings>();
Expand Down
Loading

0 comments on commit 4a40a54

Please sign in to comment.