You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm loving the new video processing functionality!
Something really cool to enhance it would be to extract just significant frames with an option. I found, well GPT-4o, that there is functionality in FFMPEG to do this with a threshold argument. Had previously used the python OpenCV library to reduce the number of frames being fired into the LLM.
Running this on the CLI I wasn't getting significant frames until my threshold was around .001 so it's very sensitive. For a 10 minute video with only one significant change then you may only get a handful of images.
/*** Detects significant scene changes in a video using FFmpeg's `select` filter.** @param {string} inputPath - Path to the input video file.* @param {string} outputPattern - Output file pattern (e.g. 'frames-%04d.png').* @param {number} sceneThreshold - Float in [0,1] that determines scene-change sensitivity.*/functiondetectSceneChanges(inputPath,outputPattern,sceneThreshold=0.3){constcommand=ffmpeg(inputPath)// The `select='gt(scene, threshold)'` logic picks frames that exceed scene threshold.// The `showinfo` filter logs frame info (including scene change info) to stderr..outputOptions([`-vf`,`select='gt(scene,${sceneThreshold})',showinfo`,`-vsync`,`0`])// Save each triggered frame as an image (PNG in this example).output(outputPattern)// Optional: If you only want the scene detection info without saving images,// you can skip the output() call or output to null sink (on Linux)..on('start',commandLine=>{console.log('Spawned FFmpeg with command:',commandLine);}).on('codecData',data=>{console.log(`Input is ${data.audio} audio with ${data.video} video`);}).on('stderr',stderrLine=>{// The `showinfo` filter logs to stderr, so you can parse lines here for scene change infoconsole.log('FFmpeg stderr output:',stderrLine);}).on('end',()=>{console.log('Processing finished!');}).on('error',(err,stdout,stderr)=>{console.error('An error occurred:',err.message);console.error('ffmpeg stdout:\n',stdout);console.error('ffmpeg stderr:\n',stderr);});command.run();}
The text was updated successfully, but these errors were encountered:
Here's a brief enhancement suggestion for the feature:
Consider adding support for different image formats besides PNG, providing users with an option to specify their preferred format (e.g., JPEG, TIFF).
If performance becomes an issue, particularly with longer videos or higher sensitivity thresholds, explore optimization techniques in the FFmpeg command.
Adding support for batch processing of multiple videos could make the feature more versatile and user-friendly.
This will help broaden the utility of the significant frames extraction option.
I'm loving the new video processing functionality!
Something really cool to enhance it would be to extract just significant frames with an option. I found, well GPT-4o, that there is functionality in FFMPEG to do this with a threshold argument. Had previously used the python OpenCV library to reduce the number of frames being fired into the LLM.
Running this on the CLI I wasn't getting significant frames until my threshold was around .001 so it's very sensitive. For a 10 minute video with only one significant change then you may only get a handful of images.
The text was updated successfully, but these errors were encountered: