Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
/remote
/.idea

/ffmpeg/ffmpeg
/ffmpeg/ffprobe

/ffmpeg/ffmpeg.exe
/ffmpeg/ffprobe.exe

*.js
*.js.map
*.log
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ See [issues](https://github.com/whyboris/Video-Hub-App/issues) for what is in pr

⚠ The repository is usually ahead of the publicly [released version](https://github.com/whyboris/Video-Hub-App/releases) - it is 🚧 WIP and may have bugs in it.

⚠ For screenshot generation to work, download and place `ffmpeg` and `ffprobe` executable into the `ffmpeg` folder. You can download the files from [FFmpeg](https://ffmpeg.org/download.html). For [windows](https://www.gyan.dev/ffmpeg/builds/) you can download `release-full` which will include hardware acceleration for nvidia (to enable, toggle `nvidiaBuild` variable in `main-extract.ts`).

How to start:

- `npm install --legacy-peer-deps` to install
Expand Down
4 changes: 4 additions & 0 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"!tslint.json"
],
"extraResources": [
{
"from": "ffmpeg",
"to": "ffmpeg"
},
{
"from": "src/assets/icons/mac/touch-bar",
"to": "assets"
Expand Down
27 changes: 26 additions & 1 deletion node/main-extract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { app } from "electron";

/**
* This file contains all the logic for extracting:
* first thumbnail,
Expand Down Expand Up @@ -25,7 +27,7 @@ const fs = require('fs');
import * as path from 'path';
const spawn = require('child_process').spawn;

const ffmpegPath = require('ffmpeg-static').replace('app.asar', 'app.asar.unpacked');
const ffmpegPath: string = app.isPackaged ? (process.resourcesPath + '/ffmpeg/ffmpeg') : './ffmpeg/ffmpeg';

import { GLOBALS } from './main-globals';

Expand All @@ -36,6 +38,20 @@ import type { ImageElement, ScreenshotSettings } from '../interfaces/final-objec
// FFMPEG arg generating functions
// ========================================================================================

/**
* nVidia-accelerated GPU decoding for screenshot generation
* added conditionally on `nvidiaBuild` variable
*/
const prependNvidiaAccelerationArgumentsIfEnabled = (args: string[]): string[] => {

if (GLOBALS.nvidiaBuild) {
args.push('-hwaccel');
args.push('cuda');
}

return args;
}

/**
* Generate the ffmpeg args to extract a single frame according to settings
* @param pathToVideo
Expand All @@ -52,7 +68,12 @@ const extractSingleFrameArgs = (

const ssWidth: number = screenshotHeight * (16 / 9);

const nvidia: string[] = [];

prependNvidiaAccelerationArgumentsIfEnabled(nvidia);

const args: string[] = [
...nvidia,
'-ss', (duration / 10).toString(),
'-i', pathToVideo,
'-frames', '1',
Expand Down Expand Up @@ -88,6 +109,8 @@ const generateScreenshotStripArgs = (
const totalCount = numberOfScreenshots;
const step: number = duration / (totalCount + 1);
const args: string[] = [];
prependNvidiaAccelerationArgumentsIfEnabled(args);

let allFramesFiltered = '';
let outputFrames = '';

Expand Down Expand Up @@ -137,6 +160,8 @@ const generatePreviewClipArgs = (
const totalCount = clipSnippets;
const step: number = duration / (totalCount + 1);
const args: string[] = [];
prependNvidiaAccelerationArgumentsIfEnabled(args);

let concat = '';

// make the magic filter
Expand Down
7 changes: 5 additions & 2 deletions node/main-globals.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import type { ScreenshotSettings, InputSources } from '../interfaces/final-object.interface';

// For release, update 4 values: <---- !!! RELEASE !!!
// For release, update 5 values: <---- !!! RELEASE !!!
//
// `demo: true,` -- below
// `version: 'X.X.X',` -- below
// `nvidiaBuild: true, -- below (separate build, requires nvidia FFmpeg)
// `"version": "X.X.X",` -- package.json
// `"productName": "... Demo" -- electron-builder.json

export const GLOBALS: VhaGlobals = {
angularApp: null, // reference used to send messages back to Angular App
currentlyOpenVhaFile: '', // OFFICAL DECREE IN NODE WHICH FILE IS CURRENTLY OPEN !!!
debug: false,
nvidiaBuild: false, // make sure to use FFmpeg with nvidia cuda abilities <---- !!! RELEASE !!!
demo: false, // change to `true` during release <---- !!! RELEASE !!!
hubName: 'untitled', // in case user doesn't name their hub any name
macVersion: false, // auto updated by `main.ts`
macVersion: true, // auto updated by `main.ts`
readyToQuit: false, // hack to quit gracefully
selectedOutputFolder: '',
selectedSourceFolders: {},
Expand All @@ -40,6 +42,7 @@ export interface VhaGlobals {
demo: boolean;
hubName: string;
macVersion: boolean;
nvidiaBuild: boolean;
readyToQuit: boolean;
screenshotSettings: ScreenshotSettings;
selectedOutputFolder: string;
Expand Down
6 changes: 5 additions & 1 deletion node/main-support.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { app } from "electron"

/*
* This whole file is meant to contain only PURE functions
*
Expand All @@ -12,7 +14,9 @@ import { GLOBALS } from './main-globals'; // TODO -- eliminate dependence on `GL
import * as path from 'path';

const exec = require('child_process').exec;
const ffprobePath = require('@ffprobe-installer/ffprobe').path.replace('app.asar', 'app.asar.unpacked');

const ffprobePath: string = app.isPackaged ? (process.resourcesPath + '/ffmpeg/ffprobe') : './ffmpeg/ffprobe';

const fs = require('fs');
const hash = require('object-hash');
const hasher = require('crypto').createHash;
Expand Down
Loading
Loading