Skip to content

Conversation

Jonham
Copy link

@Jonham Jonham commented Aug 17, 2025

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');

@Jonham Jonham deleted the branch ts-ffmpeg:master August 24, 2025 15:18
@Jonham Jonham closed this Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants