Fix: Initialize 'audio_details' and 'video_details' properties and update codecData documentation #7
+2
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Forked from: fluent-ffmpeg#1301 by @DongSeonYoo
When uploading a video without audio, the 'data' parameter passed to the callback function in the codecData event is as follows.
const command = Ffmpeg(inputFilePath)
.setFfmpegPath(ffmpegInstall.path)
.outputOptions([
'-profile:v baseline',
'-level 3.0',
'-start_number 0',
'-hls_time 10',
'-hls_list_size 0',
'-f hls',
]);
command.on('codecData', (data) => {
console.log('codecData: ', data);
});
Output Result
codecData: {
format: 'mov,mp4,m4a,3gp,3g2,mj2',
audio: '',
video: 'h264 (Constrained Baseline) (avc1 / 0x31637661)',
duration: '00:00:05.00',
video_details: [
'h264 (Constrained Baseline) (avc1 / 0x31637661)',
'yuv420p',
'600x336 [SAR 1:1 DAR 25:14]',
'127 kb/s',
'10 fps',
'10 tbr',
'10240 tbn',
'20 tbc (default)'
]
}
As shown in the example above, the 'audio' property is initialized as an empty string. However, upon examining the original code, we notice an inconsistency: while the 'audio' property is initialized with an empty string, the 'audio_details' property is not initialized at all. This situation presents two issues:
Lack of code consistency: The 'audio' property is initialized, but 'audio_details' is not.
Lack of code consistency: The 'video' property is initialized, but 'video_details' is not.
Discrepancy with @types/fluent-ffmpeg: In the type definitions of @types/fluent-ffmpeg, 'audio_details' is defined as a required string[], not an optional one.
These inconsistencies can lead to confusion among developers and may cause unexpected errors during type checking. Furthermore, it creates a mismatch between the actual implementation and the type definitions, potentially leading to runtime errors that are not caught during development.
Therefore, I have added an initialization statement for audio_details as follows
inputStack[inputIndex] = { format: format[1], audio: '', audio_details: '', video: '', video_details: '', duration: '' };
Add duration property to codecData JSDoc
@param {String} codecData.duration input video duration
Remove unused varibales
var path = require('path');
var fs = require('fs');