Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 27th June 2022, 13:51   #1  |  Link
RainbowThief
Registered User
 
Join Date: Sep 2019
Location: London
Posts: 11
ffmpeg - remove last frame before every scene change

I have a ProRes 422 HQ file taken from a 2 perf film negative. It has visible negative cuts, bottom frame, at the end of every scene change.

Is there a way of removing these distracting frames with ffmpeg? It would take ages to edit them all out manually.

Thanks,
RainbowThief is offline   Reply With Quote
Old 27th June 2022, 18:06   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I've no idea how to do what you want in ffmpeg, nor whether is possible.

Maybe instead of "removing these distracting frames",
"replace these distracting frames with the frame prior to them {ie a dupe}".
No change in frame count, no blips in audio where frame and audio chopped out {otherwise audio de-sync}.

Automatic edit detection with FFmpeg and import into Premiere via EDL
Offsite link:- http://danielbachler.de/2013/02/23/a...e-via-edl.html
Linked by on-site post here:- https://forum.doom9.org/showthread.p...44#post1690644
Dont know if can be used as your post requires. [maybe someone else can comment].

If Avisynth and re-encode is OK, then could maybe use something like this to create a EOS frames list [End-Of-Scene].
Then replace those EOS frames with a dupe of the frame prior to them.
https://forum.doom9.org/showthread.php?t=182392
Quote:
Function SCSelect_HBD(clip dClip,clip Start,clip End,clip Motion, float "dfactor",Float "MinDif",bool "show",String "S_Frames",String "E_Frames")
E_Frames = FileName of EOS frame numbers.


With a frames list, can (using FrameSel) pull out ONLY EOS frames for perusal (see if detects all look good, ie "destracting frame").

and also easily replace those EOS frames with the ones prior to them [Using FrameSel::FrameRep].

If Avisynth is an option for you, please say and I will assist further if needed.

FrameSel:- https://forum.doom9.org/showthread.php?t=167971
FrameSel Docs:- https://forum.doom9.org/showthread.p...43#post1839843

Quote:
FrameSel(Clip, int F1, ... , int Fn, string 'scmd',string 'cmd', bool 'show', bool 'ver',bool "reject",bool "ordered",
\ bool "debug", int "Extract"=1)
Quote:
Extract Int, Default 1, MUST be ODD, 1 to 11. Error if not default 1 AND neither Ordered nor Reject == True.
Let us call the UNIQUE resultant frames after Ordered and/or Reject Processing 'Target' frames.
The number of frames pulled out on either side of Target frame is Extract / 2 (integer divide), so when Extract=3, it will
extract 1 frame before target, the Target frame, and 1 frame after target, for each and every Target frame.
This arg allows you to select eg 3 frames for each Target frame, the previous frame, Target frame and next frame.
May be of use to extract bad frames together with eg 1 frame either side for saving as bitmaps and editing
in some kind of RotoScope editor to repair bad frames using image from adjacent frames. The edited frames could
then be re-loaded, middle one selected via SelectEvery(3,1), and then put back into original source clip via FrameRep().
Another simple use could be when you have a clip where each frame before a scene change is bad, with Ordered=True
and Extract=3, you pull out 3 frames, a SelectEvery(3,0) would select the frames previous to the bad frames and
then use Framerep() to replace the bad frames with those previous to them.
A SelectEvery(3,2) would select the frames
after Target frames.
The total number of frames pulled out of the source clip will be (Extract * number of Target frames).
Reject is less likely to be of use with Extract, unless frame select commands specify good frames rather than bad,
where Reject in FrameRep should also be true (same as in FrameSel, as always).
See FrameRep() for example uses of Extract.
From Docs, using SCMD (framenos in string rather than CMD file)
Quote:
Example use when NOT selecting/replacing in exact same position:
Lets say you have a clip with a bad frame before each scene change and you want to replace these bad frames with the frame immediately
before it.
Code:
    C=Colorbars().Trim(0,-50).ShowFrameNumber()                    # 50 frames (0 -> 49)
    BADFRAMES = "10;20;30;40"                                      # 4 bad frames in source clip
    PREBAD    = " 9;19;29;39"                                      # 4 frames immediately before bad frames
    REPAIR=FrameSel(C,scmd=PREBAD)                                 # Get the 4 frames we will duplicate
    Return FrameRep(C,REPAIR,scmd=BADFRAMES)                       # fix bad frames with REPAIR clip from PREBAD frames
Will produce a duplicate at frames 10, 20, 30, and 40 in source clip.

When used as above you must ensure that eg BADFRAMES and PREBAD have the same number of unique frames and sequential or results
may not be as expected (ie use Ordered).

# ----------------

Same Example again using Extract arg:-

Code:
    
    C=Colorbars().Trim(0,-50).ShowFrameNumber()                     # 50 frames (0 -> 49)
    BADFRAMES = "10;20;30;40"                                       # 4 bad frames in source clip
    EXTRACT=FrameSel(C,scmd=BADFRAMES,ordered=True,extract=3)       # Extract Previous, Target and Next frames for each Target frame
    REPAIR=EXTRACT.SelectEvery(3,0)                                 # Select each frame previous to Target bad frames, 1st of each triplet
    #REPAIR=REPAIR.Invert()                                         # So we can easily see repaired frames
    Return FrameRep(C,REPAIR,scmd=BADFRAMES)                        # Fix bad frames with REPAIR clip using exact same BADFRAMES spec.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 27th June 2022 at 18:44.
StainlessS is offline   Reply With Quote
Reply

Tags
ffmpeg

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.