Skip to content

Commit

Permalink
wip: linux support
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jun 27, 2023
1 parent 8799151 commit c74b685
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export class AppContainer {
: '',
]
}
if (process.execPath.match(/node.exe$/)) {
if (process.execPath.match(/node.exe$/) || process.execPath.match(/node$/)) {
// Process runs as a node process, we're probably in development mode.
this.availableApps['worker'] = {
file: process.execPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function getAccessorStaticHandle(accessor: AccessorOnPackage.Any) {
} else if (accessor.type === Accessor.AccessType.HTTP_PROXY) {
return HTTPProxyAccessorHandle
} else if (accessor.type === Accessor.AccessType.FILE_SHARE) {
if (process.platform !== 'win32') throw new Error(`FileShareAccessor: not supported on ${process.platform}`)
return FileShareAccessorHandle
} else if (accessor.type === Accessor.AccessType.QUANTEL) {
return QuantelAccessorHandle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { GenericFileAccessorHandle, LocalFolderAccessorHandleType } from './lib/
import { MonitorInProgress } from '../lib/monitorInProgress'
import { compareResourceIds } from '../workers/windowsWorker/lib/lib'
import { defaultCheckHandleRead, defaultCheckHandleWrite } from './lib/lib'
import { mkdirp } from 'mkdirp'
import mkdirp from 'mkdirp'

const fsStat = promisify(fs.stat)
const fsAccess = promisify(fs.access)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,28 @@ export function previewFFMpegArguments(input: string, seekableSource: boolean, m
return [
'-hide_banner',
'-y', // Overwrite output files without asking.
seekableSource ? undefined : '-seekable 0',
`-i "${input}"`, // Input file path
'-f webm', // format: webm
seekableSource ? undefined : '-seekable',
seekableSource ? undefined : '0',
`-i`,
input, // Input file path
'-f',
'webm', // format: webm
'-an', // blocks all audio streams
'-c:v libvpx-vp9', // encoder for video (use VP9)
`-b:v ${metadata.version.bitrate || '40k'}`,
'-auto-alt-ref 1',
`-vf scale=${metadata.version.width || 320}:${metadata.version.height || -1}`, // Scale to resolution
'-c:v',
'libvpx-vp9', // encoder for video (use VP9)
`-b:v`,
`${metadata.version.bitrate || '40k'}`,
'-auto-alt-ref',
'1',
`-vf`,
`scale=${metadata.version.width || 320}:${metadata.version.height || -1}`, // Scale to resolution

'-threads 1', // Number of threads to use
'-cpu-used 5', // Sacrifice quality for speed, used in combination with -deadline realtime
'-deadline realtime', // Encoder speed/quality and cpu use (best, good, realtime)
'-threads',
'1', // Number of threads to use
'-cpu-used',
'5', // Sacrifice quality for speed, used in combination with -deadline realtime
'-deadline',
'realtime', // Encoder speed/quality and cpu use (best, good, realtime)
].filter(Boolean) as string[] // remove undefined values
}

Expand All @@ -341,12 +351,18 @@ interface ThumbnailMetadata {
export function thumbnailFFMpegArguments(input: string, metadata: ThumbnailMetadata, seekTimeCode?: string): string[] {
return [
'-hide_banner',
seekTimeCode ? `-ss ${seekTimeCode}` : undefined,
`-i "${input}"`,
`-f image2`,
'-frames:v 1',
`-vf ${!seekTimeCode ? 'thumbnail,' : ''}scale=${metadata.version.width}:${metadata.version.height}`,
'-threads 1',
seekTimeCode ? `-ss` : undefined,
seekTimeCode ? `${seekTimeCode}` : undefined,
`-i`,
input,
`-f`,
`image2`,
'-frames:v',
'1',
`-vf`,
`${!seekTimeCode ? 'thumbnail,' : ''}scale=${metadata.version.width}:${metadata.version.height}`,
'-threads',
'1',
].filter(Boolean) as string[] // remove undefined values
}

Expand All @@ -360,10 +376,13 @@ export function proxyFFMpegArguments(
'-hide_banner',
'-y', // Overwrite output files without asking.
seekableSource ? undefined : '-seekable 0',
`-i "${input}"`, // Input file path
`-i`,
input, // Input file path

'-c copy', // Stream copy, no transcoding
'-threads 1', // Number of threads to use
'-c',
'copy', // Stream copy, no transcoding
'-threads',
'1', // Number of threads to use
]

// Check target to see if we should tell ffmpeg which format to use:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function scanWithFFProbe(
}
const file = process.platform === 'win32' ? 'ffprobe.exe' : 'ffprobe'
// Use FFProbe to scan the file:
const args = ['-hide_banner', `-i "${inputPath}"`, '-show_streams', '-show_format', '-print_format', 'json']
const args = ['-hide_banner', `-i`, inputPath, '-show_streams', '-show_format', '-print_format', 'json']
let ffProbeProcess: ChildProcess | undefined = undefined
onCancel(() => {
ffProbeProcess?.stdin?.write('q') // send "q" to quit, because .kill() doesn't quite do it.
Expand Down Expand Up @@ -164,8 +164,10 @@ export function scanFieldOrder(
const file = getFFMpegExecutable()
const args = [
'-hide_banner',
'-filter:v idet',
`-frames:v ${targetVersion.fieldOrderScanDuration || 200}`,
'-filter:v',
'idet',
`-frames:v`,
`${targetVersion.fieldOrderScanDuration || 200}`,
'-an',
'-f',
'rawvideo',
Expand Down Expand Up @@ -261,7 +263,7 @@ export function scanMoreInfo(
if (filterString) {
filterString += ','
}
filterString += `"select='gt(scene,${targetVersion.sceneThreshold || 0.4})',showinfo"`
filterString += `select='gt(scene,${targetVersion.sceneThreshold || 0.4})',showinfo`
}

const args = ['-hide_banner']
Expand All @@ -270,8 +272,8 @@ export function scanMoreInfo(

args.push('-filter:v', filterString)
args.push('-an')
args.push('-f null')
args.push('-threads 1')
args.push('-f', 'null')
args.push('-threads', '1')
args.push('-')

let ffMpegProcess: ChildProcess | undefined = undefined
Expand Down Expand Up @@ -652,21 +654,21 @@ async function getFFMpegInputArgsFromAccessorHandle(
): Promise<string[]> {
const args: string[] = []
if (isLocalFolderAccessorHandle(sourceHandle)) {
args.push(`-i "${sourceHandle.fullPath}"`)
args.push(`-i`, sourceHandle.fullPath)
} else if (isFileShareAccessorHandle(sourceHandle)) {
await sourceHandle.prepareFileAccess()
args.push(`-i "${sourceHandle.fullPath}"`)
args.push(`-i`, sourceHandle.fullPath)
} else if (isHTTPAccessorHandle(sourceHandle)) {
args.push(`-i "${sourceHandle.fullUrl}"`)
args.push(`-i`, sourceHandle.fullUrl)
} else if (isHTTPProxyAccessorHandle(sourceHandle)) {
args.push(`-i "${sourceHandle.fullUrl}"`)
args.push(`-i`, sourceHandle.fullUrl)
} else if (isQuantelClipAccessorHandle(sourceHandle)) {
const httpStreamURL = await sourceHandle.getTransformerStreamURL()

if (!httpStreamURL.success) throw new Error(`Source Clip not found (${httpStreamURL.reason.tech})`)

args.push('-seekable 0')
args.push(`-i "${httpStreamURL.fullURL}"`)
args.push('-seekable', '0')
args.push(`-i`, httpStreamURL.fullURL)
} else {
assertNever(sourceHandle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export class WindowsWorker extends GenericWorker {
sendMessageToManager: ExpectationManagerWorkerAgent.MessageFromWorker
) {
super(logger.category('WindowsWorker'), agentAPI, sendMessageToManager, WindowsWorker.type)
if (process.platform !== 'win32' && process.env.JEST_WORKER_ID === undefined) {
throw new Error('The Worker is a Windows-only application')
}
// if (process.platform !== 'win32' && process.env.JEST_WORKER_ID === undefined) {
// throw new Error('The Worker is a Windows-only application')
// }
this.logger.debug(`Worker started`)
}
async doYouSupportExpectation(exp: Expectation.Any): Promise<ReturnTypeDoYouSupportExpectation> {
Expand Down

0 comments on commit c74b685

Please sign in to comment.