@@ -6,6 +6,8 @@ const os = require("os");
66const path = require ( "path" ) ;
77const { getMuxOriginalAudioArgs, getOutputStreamArgs } = require ( "./ffmpegArgs.cjs" ) ;
88const { parseMacGpuUsageFromIoreg } = require ( "./gpuUsage.cjs" ) ;
9+ const { deriveStartTimeMs } = require ( "./mediaStartTime.cjs" ) ;
10+ const { checkForUpdate } = require ( "./updateChecker.cjs" ) ;
911const {
1012 getFilterThreadCount,
1113 getSegmentCount,
@@ -471,9 +473,16 @@ function formatBytes(bytes) {
471473 return `${ size . toFixed ( size >= 10 || index === 0 ? 0 : 1 ) } ${ units [ index ] } ` ;
472474}
473475
474- function getFileMetadata ( filePath ) {
476+ async function getFileMetadata ( filePath ) {
475477 const stats = fs . statSync ( filePath ) ;
476478 const modifiedAtMs = Number . isFinite ( stats . mtimeMs ) ? stats . mtimeMs : Date . now ( ) ;
479+ let mediaInfo = null ;
480+
481+ try {
482+ mediaInfo = await probeMediaInfo ( filePath ) ;
483+ } catch {
484+ mediaInfo = null ;
485+ }
477486
478487 return {
479488 id : crypto . randomUUID ( ) ,
@@ -483,7 +492,7 @@ function getFileMetadata(filePath) {
483492 sizeLabel : formatBytes ( stats . size ) ,
484493 modifiedAt : new Date ( modifiedAtMs ) . toISOString ( ) ,
485494 modifiedAtMs,
486- startTimeMs : modifiedAtMs ,
495+ startTimeMs : deriveStartTimeMs ( { mediaInfo , modifiedAtMs } ) ,
487496 status : "queued" ,
488497 progress : 0
489498 } ;
@@ -560,15 +569,17 @@ async function probeMediaInfo(inputPath) {
560569 "-select_streams" ,
561570 "v:0" ,
562571 "-show_entries" ,
563- "stream=width,height,avg_frame_rate,r_frame_rate:format=duration" ,
572+ "stream=width,height,avg_frame_rate,r_frame_rate:stream_tags: format=duration:format_tags " ,
564573 "-of" ,
565574 "json" ,
566575 inputPath
567576 ] ) ;
568577
569578 const parsed = JSON . parse ( stdout || "{}" ) ;
570- const stream = Array . isArray ( parsed . streams ) ? parsed . streams [ 0 ] || { } : { } ;
571- const duration = Number ( parsed . format ?. duration ) ;
579+ const streams = Array . isArray ( parsed . streams ) ? parsed . streams : [ ] ;
580+ const format = parsed . format || { } ;
581+ const stream = streams [ 0 ] || { } ;
582+ const duration = Number ( format . duration ) ;
572583 const width = Number ( stream . width ) ;
573584 const height = Number ( stream . height ) ;
574585
@@ -577,7 +588,9 @@ async function probeMediaInfo(inputPath) {
577588 width : Number . isFinite ( width ) && width > 0 ? width : null ,
578589 height : Number . isFinite ( height ) && height > 0 ? height : null ,
579590 avgFrameRate : stream . avg_frame_rate || null ,
580- rFrameRate : stream . r_frame_rate || null
591+ rFrameRate : stream . r_frame_rate || null ,
592+ format,
593+ streams
581594 } ;
582595}
583596
@@ -1288,7 +1301,7 @@ ipcMain.handle("videos:select", async () => {
12881301 return [ ] ;
12891302 }
12901303
1291- return result . filePaths . map ( getFileMetadata ) ;
1304+ return Promise . all ( result . filePaths . map ( getFileMetadata ) ) ;
12921305} ) ;
12931306
12941307ipcMain . handle ( "output:select-directory" , async ( ) => {
@@ -1304,6 +1317,13 @@ ipcMain.handle("output:select-directory", async () => {
13041317ipcMain . handle ( "system:get-capabilities" , async ( ) => getCapabilities ( ) ) ;
13051318ipcMain . handle ( "system:get-usage" , async ( ) => latestUsage || buildUsageSnapshot ( ) ) ;
13061319
1320+ ipcMain . handle ( "updates:check" , async ( ) =>
1321+ checkForUpdate ( {
1322+ currentVersion : app . getVersion ( ) ,
1323+ platform : process . platform
1324+ } )
1325+ ) ;
1326+
13071327ipcMain . handle ( "transcode:start-batch" , async ( _event , payload ) => {
13081328 if ( queueBusy ) {
13091329 throw new Error ( "A batch is already running." ) ;
@@ -1393,3 +1413,13 @@ ipcMain.handle("shell:open-path", async (_event, targetPath) => {
13931413 }
13941414 return "Path does not exist." ;
13951415} ) ;
1416+
1417+ ipcMain . handle ( "shell:open-external" , async ( _event , targetUrl ) => {
1418+ const url = String ( targetUrl || "" ) ;
1419+ if ( ! / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ i n f e r a - A I \/ D L - E d i t o r \/ r e l e a s e s (?: \/ | $ ) / . test ( url ) ) {
1420+ throw new Error ( "Unsupported update URL." ) ;
1421+ }
1422+
1423+ await shell . openExternal ( url ) ;
1424+ return { opened : true } ;
1425+ } ) ;
0 commit comments