File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -441,15 +441,13 @@ function getBestStream(metadata) {
441441 * Return the duration from file by parsing metadata
442442 * @param metadata
443443 */
444- function getFileDuration ( metadata ) {
445- try {
444+ function getFileDuration ( metadata ) : number {
445+ if ( metadata && metadata . streams && metadata . streams [ 0 ] && metadata . streams [ 0 ] . duration ) {
446446 return metadata . streams [ 0 ] . duration ;
447- } catch ( e1 ) {
448- try {
449- return metadata . format . duration ;
450- } catch ( e2 ) {
451- return 0 ;
452- }
447+ } else if ( metadata && metadata . format && metadata . format . duration ) {
448+ return metadata . format . duration ;
449+ } else {
450+ return 0 ;
453451 }
454452}
455453
@@ -474,7 +472,7 @@ function extractMetadataForThisONEFile(
474472 } else {
475473 const metadata = JSON . parse ( data ) ;
476474 const stream = getBestStream ( metadata ) ;
477- const fileDuration = getFileDuration ( metadata ) ;
475+ const fileDuration : number = getFileDuration ( metadata ) ;
478476
479477 const duration = Math . round ( fileDuration ) || 0 ;
480478 const origWidth = stream . width || 0 ; // ffprobe does not detect it on some MKV streams
You can’t perform that action at this time.
0 commit comments