MCPcopy Create free account
hub / github.com/AS-AIGC/TranscriptHub / get_media_duration_callback

Function get_media_duration_callback

apps/backend/utils.js:97–126  ·  view source on GitHub ↗

* @brief Get media file duration and metadata (callback version) * * @param file_path [in] Path to media file * @param callback [in] Function(err, result) * - err: Error if operation failed * - result: Object with duration, file_type, mime_type * * @note Uses ffprobe for metadata ex

(file_path, callback)

Source from the content-addressed store, hash-verified

95 * @note Validates media type before processing
96 */
97function get_media_duration_callback(file_path, callback) {
98 is_media_file_callback(file_path, (err, is_media) => {
99 if (err) {
100 return callback(err);
101 }
102
103 if (!is_media) {
104 return callback(new Error('Not a supported media file'));
105 }
106
107 ffprobe.ffprobe(file_path, (err, metadata) => {
108 if (err) {
109 console.error('FFprobe Error:', {
110 message: err.message,
111 code: err.code,
112 file_path: file_path
113 });
114 return callback(err);
115 }
116
117 const duration = metadata.format?.duration || 0;
118
119 callback(null, {
120 duration: duration,
121 file_type: path.extname(file_path),
122 mime_type: mime.lookup(file_path)
123 });
124 });
125 });
126}
127
128
129

Callers 1

runFunction · 0.85

Calls 1

is_media_file_callbackFunction · 0.85

Tested by

no test coverage detected