-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #780 from HaveAGitGat/encoders
chore: export checkHardware()
- Loading branch information
Showing
2 changed files
with
83 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,52 @@ | ||
import { getEncoder } from './hardwareUtils'; | ||
|
||
const run = async () => { | ||
const encoderProperties = await getEncoder({ | ||
targetCodec: 'h264', | ||
hardwareEncoding: true, | ||
hardwareType: 'auto', | ||
// @ts-expect-error type | ||
args: { | ||
workerType: 'transcodegpu', | ||
ffmpegPath: 'ffmpeg', | ||
jobLog: (t:string) => { | ||
// eslint-disable-next-line no-console | ||
console.log(t); | ||
}, | ||
import { getEncoder, IgetEncoder } from './hardwareUtils'; | ||
|
||
const baseInput = { | ||
targetCodec: 'h264', | ||
hardwareEncoding: true, | ||
hardwareType: 'auto', | ||
args: { | ||
workerType: 'transcodegpu', | ||
ffmpegPath: 'ffmpeg', | ||
jobLog: () => { | ||
// | ||
}, | ||
}); | ||
}, | ||
}; | ||
|
||
interface IcheckHardware { | ||
targetCodec:string | undefined, | ||
hardwareEncoding:boolean | undefined, | ||
hardwareType:string | undefined, | ||
ffmpegPath:string | undefined, | ||
} | ||
|
||
const checkHardware = async (settings:IcheckHardware):Promise<IgetEncoder> => { | ||
const input = JSON.parse(JSON.stringify(baseInput)); | ||
|
||
input.args.jobLog = () => { | ||
// eslint-disable-next-line no-console | ||
// console.log(t); | ||
}; | ||
|
||
if (settings.targetCodec) { | ||
input.targetCodec = settings.targetCodec; | ||
} | ||
|
||
if (settings.hardwareEncoding) { | ||
input.hardwareEncoding = settings.hardwareEncoding; | ||
} | ||
|
||
if (settings.hardwareType) { | ||
input.hardwareType = settings.hardwareType; | ||
} | ||
|
||
if (settings.ffmpegPath) { | ||
input.args.ffmpegPath = settings.ffmpegPath; | ||
} | ||
|
||
const encoderProperties = await getEncoder(input); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log({ | ||
encoderProperties, | ||
}); | ||
return encoderProperties; | ||
}; | ||
|
||
void run(); | ||
export default checkHardware; |