Page 1 of 1

Keyframes

Posted: Wed Mar 31, 2021 3:20 pm
by mrazik
Hi everyone,

have you tried to generate keyframes (scene changes) with the H264/ffmpeg?
I'm struggling with the:
- scene change FFmpeg command
- custom filename
- list of generated jpg files

I'll be glad for any help!
Many thanks,
Mrazik

Re: Keyframes

Posted: Thu Apr 01, 2021 10:32 am
by emcodem
Hey mrazik,

What exactly are you trying to get done and where is your problem?

Here some command that i used in the past. the output files will be named like thumbs_FRAMENUM.png.

Code: Select all

ffmpeg -i F:\temp\608.mxf -vf  "select=gt(scene\,0.1), scale=640:360" -vsync vfr -frame_pts 1 "c:\temp\thumbs_%d.png"

Re: Keyframes

Posted: Tue Apr 06, 2021 11:46 am
by mrazik
Hi @emcodem,

thank you for your reply, I'm trying to get generated thumb filenames in the shape "thumb_timecode-of-the-frame.png".
So far without any luck.....

The only thing I can manage is the txt file with generated files, as I can put it as the "Command executor" processor with custom cmd.

Many thanks,
mrazik

Re: Keyframes

Posted: Tue Apr 06, 2021 3:52 pm
by emcodem
Hey,

ok, so let's split up the problems:

1) how to make ffmpeg write the timecode of the frame into the output filename. There are at the best of my knowledge 2 options for this (i might be wrong, better as ffmpeg-user chat):
a) for live recordings we can use

Code: Select all

-strftime 1 "c:\temp\prefix_%Y-%m-%d_%H-%M-%S.jpg"
b) for non live we can only put the frame number starting from 0 into the filename

Code: Select all

-frame_pts 1 "c:\temp\thumbs_%d.png"
2) the generated filenames to a text file. There are many options for that but not from inside ffmpeg itself.
a) use a batch file after transcode with dir /s /b or such, but i think you already do something like it
b) grep the generated filenames directly from ffmpeg but this is really more simple. Potentially you could add something like:

Code: Select all

-loglevel debug 2>&1|findstr Opening 2>&1 > c:\temp\list.txt
In that case c:\temp\list.txt would contain the list of generated files but with some unneccessary stuff around like:
[image2 @ 000001b281e65600] Opening 'c:\temp\thumbs_148.png' for writing

Which doesnt really make your life easier than having a batch as you do now.

Note that the requirement to put the "video timecode" into the filename of extracted images is not really a valid solution as the TC of files can wrap over at 24:00, starting from 0 again which would make ffmpeg potentially overwrite some of the exported images, so it is in general not a valid solution to work with the "video timecode" for filenames when extracting thumbs.

Re: Keyframes

Posted: Wed Apr 21, 2021 6:42 am
by mrazik
Hi @emcodem,

thank you very much, I was trying to get the frame number directly in the thumbnail filename.

So what I found out this is not possible to achieve in FFmpeg nodes, so I used command executor node with cmd:

Code: Select all

%comspec% /C "%s_ffmpegx64% -threads 1 -y -i "%s_original_full%" -vf "select=key,scale=320:-1" -an -vsync 0 -frame_pts 1 "%S_KEYFRAME_PATH%\%s_original_name%\%10d.jpg""
Anyway, thank you!
mrazik

Re: Keyframes

Posted: Wed Apr 21, 2021 10:53 am
by emcodem
Thnks for letting us know :-)