@@ -53,6 +53,13 @@ function localManifestPath(written: string[], manifestRemotePath: string): strin
5353
5454// ── Flags ──────────────────────────────────────────────────────
5555
56+ type Compute = "auto" | "cpu" | "gpu" ;
57+ const COMPUTE_MODES : readonly Compute [ ] = [ "auto" , "cpu" , "gpu" ] ;
58+
59+ function isCompute ( value : string ) : value is Compute {
60+ return ( COMPUTE_MODES as readonly string [ ] ) . includes ( value ) ;
61+ }
62+
5663interface GlobalFlags {
5764 json : boolean ;
5865 urlOnly : boolean ;
@@ -62,6 +69,7 @@ interface GlobalFlags {
6269 output : string | null ;
6370 outputDir : string | null ;
6471 timeout : number ;
72+ compute : Compute | null ;
6573}
6674
6775function extractGlobalFlags ( ) : GlobalFlags {
@@ -75,6 +83,7 @@ function extractGlobalFlags(): GlobalFlags {
7583 output : null ,
7684 outputDir : null ,
7785 timeout : 120 ,
86+ compute : null ,
7887 } ;
7988 for ( let i = 0 ; i < argv . length ; i ++ ) {
8089 const arg = argv [ i ] ;
@@ -94,6 +103,14 @@ function extractGlobalFlags(): GlobalFlags {
94103 const val = parseInt ( argv [ i + 1 ] ! , 10 ) ;
95104 if ( ! Number . isNaN ( val ) && val > 0 ) flags . timeout = Math . min ( val , 900 ) ;
96105 i ++ ;
106+ } else if ( arg === "--compute" && i + 1 < argv . length ) {
107+ const val = argv [ i + 1 ] ! ; // Guarded by i + 1 < argv.length
108+ if ( ! isCompute ( val ) ) {
109+ process . stderr . write ( pc . red ( ` ✗ Invalid --compute value "${ val } ". Expected one of: auto, cpu, gpu.\n` ) ) ;
110+ process . exit ( 2 ) ;
111+ }
112+ flags . compute = val ;
113+ i ++ ;
97114 }
98115 }
99116 return flags ;
@@ -104,7 +121,7 @@ function extractFfmpegArgs(): string[] {
104121 const ffmpegIdx = argv . indexOf ( "ffmpeg" ) ;
105122 if ( ffmpegIdx === - 1 ) return [ ] ;
106123 const globalFlags = new Set ( [ "--json" , "--url-only" , "--quiet" , "--no-wait" , "--no-download" ] ) ;
107- const globalFlagsWithValue = new Set ( [ "--timeout" , "--output" , "--output-dir" ] ) ;
124+ const globalFlagsWithValue = new Set ( [ "--timeout" , "--output" , "--output-dir" , "--compute" ] ) ;
108125 const result : string [ ] = [ ] ;
109126 for ( let i = ffmpegIdx + 1 ; i < argv . length ; i ++ ) {
110127 const arg = argv [ i ] ! ;
@@ -135,6 +152,7 @@ ${pc.bold("Flags:")}
135152 --quiet No output, exit code only
136153 --no-wait Submit and exit immediately (prints job ID)
137154 --timeout N Max execution time in seconds (default: 120, max: 900)
155+ --compute <mode> Run on cpu or gpu hardware (auto, cpu, gpu; gpu needs Pro)
138156
139157${ pc . dim ( "Outputs download to your folder by default — like running ffmpeg locally." ) }
140158${ pc . dim ( "Local files are auto-uploaded before job submission." ) }
@@ -224,7 +242,10 @@ export default defineCommand({
224242
225243 const job = await steps . step ( "Submitting" , async ( ) => {
226244 return client . jobs . create (
227- { type : "ffmpeg" , params : { command, timeout : flags . timeout } } ,
245+ {
246+ type : "ffmpeg" ,
247+ params : { command, timeout : flags . timeout , ...( flags . compute ? { compute : flags . compute } : { } ) } ,
248+ } ,
228249 { signal : controller . signal } ,
229250 ) ;
230251 } ) ;
0 commit comments