Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Initialize 'audio_details' and 'video_details' properties and update codecData documentation #1301

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DongSeonYoo
Copy link

@DongSeonYoo DongSeonYoo commented Oct 14, 2024

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:

  1. Lack of code consistency: The 'audio' property is initialized, but 'audio_details' is not.
  2. Lack of code consistency: The 'video' property is initialized, but 'video_details' is not.
  3. 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');

@DongSeonYoo DongSeonYoo changed the title Feat: add missed properties fix: Initialize audio_details and update codecData documentation Oct 14, 2024
@DongSeonYoo DongSeonYoo changed the title fix: Initialize audio_details and update codecData documentation fix: Initialize audio_details property and update codecData documentation Oct 14, 2024
@DongSeonYoo DongSeonYoo changed the title fix: Initialize audio_details property and update codecData documentation fix: Initialize 'audio_details' property and update codecData documentation Oct 14, 2024
@DongSeonYoo DongSeonYoo changed the title fix: Initialize 'audio_details' property and update codecData documentation Fix: Initialize 'audio_details' and 'video_details' properties and update codecData documentation Oct 15, 2024
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.

1 participant