Splitting an image sequence to folders by scene change

Questions involving a Windows version of FFmpeg.
Post Reply
Bassquake
Posts: 3
Joined: Thu Jun 27, 2019 8:56 am

Splitting an image sequence to folders by scene change

Post by Bassquake » Thu Jun 27, 2019 9:09 am

As title really. Is there a way to split an image sequence to individual folders based on scene changes?

I tried this as a test:

Code: Select all

ffmpeg -i "SAM_%05d.JPG" -vf select='gt(scene\,0.4)' -vsync vfr "SAM_%d.JPG"
But it says Output file is empty, nothing was encoded.

Ideally I want it to copy the frames into folders, not recompress to another file format. The numbering can stay the same.

Like so:

/Original folder
SAM_00001.JPG
SAM_00002.JPG
SAM_00003.JPG
SAM_00004.JPG
SAM_00005.JPG
SAM_00006.JPG
SAM_00007.JPG
SAM_00008.JPG
SAM_00009.JPG

Run the command which would output:

Original folder/scene01
SAM_00001.JPG
SAM_00002.JPG
SAM_00003.JPG
SAM_00004.JPG

Original folder/scene02
SAM_00005.JPG
SAM_00006.JPG
SAM_00007.JPG
SAM_00008.JPG
SAM_00009.JPG

Where image 5 detects a scene change.

Hope that makes sense! Many thanks.

firesalamander
Posts: 2
Joined: Tue Jan 15, 2019 9:19 pm

Re: Splitting an image sequence to folders by scene change

Post by firesalamander » Mon Jul 15, 2019 9:22 pm

I'm looking for the same thing, but instead of movie-to-stills, I'm trying to get mastermovie.mp4 to scene_01.mp4, scene02.mp4, etc.

This (ffmpeg -i foo.mp4 -vf select='gt(scene\,0.4)' -vsync vfr frame%d.png) splits to frames. Is there a way to split one clip into multiple scenes with video/audio?

pandy
Posts: 223
Joined: Mon Feb 24, 2014 1:46 pm

Re: Splitting an image sequence to folders by scene change

Post by pandy » Wed Jul 17, 2019 8:52 pm

IMHO your question seem to be invalid, every new image is scene change thus seem concept folders grouping "scene" provided by you seem to be not possible with this filter - how i understand purpose of 'gt(scene\,0.4)' filter - compare difference between current and previous video frame i.e. if delta equal/higher than specified (0.4) threshold then new scene flag is raised and frame is passed to next step (in your case directly to muxer).
Tested many times bellow script and behaviour seem to be quite obvious.

Code: Select all

@set filename=%1
@ffmpeg -y -hide_banner -loglevel 32 -i %filename% -vf select='gt(scene\,0.5)' -vsync vfr -f image2 "%filename%_%%06d.jpeg"

Bassquake
Posts: 3
Joined: Thu Jun 27, 2019 8:56 am

Re: Splitting an image sequence to folders by scene change

Post by Bassquake » Tue Oct 08, 2019 11:44 am

I had to compromise and have ffmpeg create thumbnails with the frame number stamped on it so i could see where to split the files up to folders manually.

Command is as so:

Code: Select all

ffmpeg -y -hide_banner -framerate 18 -i "images/SAM_%05d.JPG" -an -f image2 -vf "vflip, crop=1656:1242:776:372, curves=preset=lighter, select='gt(scene\,0.15)', drawtext=fontsize=100:fontfile='c\:/Windows/Fonts/Arial.ttf':text='Frame %{eif\:t*18\:d}':x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000099: boxborderw=20, scale=1440:-1" -vsync 0 -q:v 20 "SAM_%02d.jpg"
The reason I got no output before was the detection value was too high so lowered it to 0.15 for correct results.

I set a crop and resize as they're images from captured telecine and best to crop out the sprocket holes.

The frame rate must be the same in eif\:t*18\:d to the frame rate for the number to be correct in the thumbnails.

Works pretty well.

pandy
Posts: 223
Joined: Mon Feb 24, 2014 1:46 pm

Re: Splitting an image sequence to folders by scene change

Post by pandy » Mon Oct 14, 2019 5:10 pm

Yes, this can be workaround however your question was a bit contradictory...

Post Reply
'