View Single Post
Old 30th June 2016, 01:58   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Too big for post, continued from post #4.
Code:
Func InterpNum($N)
    if $N>=1 and $N<=9 Then
        Local $Frm = GetFrameNo()
        if $Frm <> "" Then
            $Frm=Int($Frm)
            if $Frm = 0 Then
                ToolTip("Cannot Interpolate Frame 0")
                $ShowCnt = $ShowCntLimit * 2
                Beep(500,50)
            Else
                ControlSend($EdTitle, "", $EditControl, "I" & $N & "  " & $Frm & "  # " & $Frm & "," & $Frm+$N-1, 1) ; Send Ix StartFrameNo # s,e       RAW
                ControlSend($EdTitle, "", $EditControl, "{ENTER}", 0)    ; Send ENTER key, 1 line down.                                                 COOKED
            Endif
        EndIf
    EndIf
EndFunc

Func Fn_InterpRange()
    Local $Rng=GetRange()
    if $Rng <> "" Then
        Local $ICnt= 0
        Local $S=""
        While($Rng <> "" and StringIsDigit(StringMid($Rng,1,1)))
            $S = $S & StringMid($Rng,1,1)
            $Rng = StringMid($Rng,2)
        Wend
        if $S <> "" Then
            Local $IS=Number($S)
            Local $IE=$IS
            if StringMid($Rng,1,1) = "," then
                $Rng = StringMid($Rng,2)
                Local $E=""
                While($Rng <> "" and StringIsDigit(StringMid($Rng,1,1)))
                    $E = $E & StringMid($Rng,1,1)
                    $Rng = StringMid($Rng,2)
                Wend
                if $E <> "" then
                    $IE=Number($E)
                Endif
            Endif
            $ICnt=$IE-$IS+1                 ; Interpolation Frame Range
            If $ICnt > 9 Then
                ToolTip("Interpolate Range 1 to 9 frames ONLY")
                $ShowCnt = $ShowCntLimit * 2
            Elseif $IS = 0 Then
                ToolTip("Cannot Interpolate Frame 0")
                $ShowCnt = $ShowCntLimit * 2
                $ICnt=0
            Elseif $ICnt >= 1 Then
                ControlSend($EdTitle, "", $EditControl, "I" & $ICnt & "  " & $IS & "  # " & $IS & "," & $IE, 1) ; Send Ix StartFrameNo      RAW
                ControlSend($EdTitle, "", $EditControl, "{ENTER}", 0)                ; Send ENTER key, 1 line down.                         COOKED
            Endif
        Endif
        if $ICnt < 1 or $ICnt > 9 Then
            Beep(500,50)
        EndIf
    Endif
Endfunc



Func Fn_NotepadSave()
    ; MsgBox($MB_SYSTEMMODAL, "", "NotePad Save")
    ControlSend($EdTitle, "", $EditControl, "^{s}" , 0) ; Send CTRL/S to NotePad, ie Save (FileSelector pop-up if not named)                COOKED
    If NOT WinExists($ScriptTitle) Then
        ToolTip("Sending NotePad Save ONLY")
    Else
        Local $state = WinGetState($ScriptTitle)
        If BitAND($state, 16) Then
            WinSetState($ScriptTitle,"", @SW_RESTORE)                           ; " Restoring Window from Minimized State"
            WinActivate($ScriptTitle,"")
            Sleep(50)
        EndIf
        ControlSend($ScriptTitle, "", $ScriptControl, "{F5}" , 0)   ; Send F5, save File and  Refresh to VirtualDub2 Script Editor  COOKED
        If BitAND($state, 16) Then
            Sleep(50)
            WinActivate($APPTitle,"")
        EndIf
        ToolTip("Sent ScriptEditor Save & Refresh")
    EndIf
    $ShowCnt = $ShowCntLimit * 4
Endfunc

;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;

Func GetFrameNo()                   ; Return VirtualDub Frame Number as string, else "" on Error
    Local $Frm = ""
    Local $E = ControlGetText($APPTitle,"", $VdFrameNo)
    ; MsgBox($MB_SYSTEMMODAL, "", "The text in Edit1 is: " & $E)
    if StringLeft($E,6) = "Frame " Then             ; Case Insignificant
        $E= StringMid($E,7)                         ; Strip 'Frame '
        While $E <> "" and StringIsDigit(StringMid($E,1,1))
            $Frm = $Frm & StringMid($E,1,1)
            $E=StringMid($E,2)
        Wend
    EndIf
    if $Frm=="" then
        Beep(500,50)
    EndIf
    Return $Frm
EndFunc

Func GetRange()           ; Return Selected Range as string, else "" on Error (comma separated range or single frame if only 1 frame ramge)
    Local $Rng = ""
    Local $S = ControlGetText($APPTitle,"", $VdRange)
    if StringMid($S,1,17) = "Selecting frames " Then   ; Case Insignificant
        $S = StringMid($S,18)                          ; Strip 'Selecting Range '
        While $S <> "" and StringIsDigit(StringMid($S,1,1))
            $Rng = $Rng & StringMid($S,1,1)
            $S=StringMid($S,2)
        Wend
        if StringMid($S,1,1) = "-" then
            Local $E=StringMid($S,2)                              ; Strip '-'
            Local $RngE=""
            if StringIsDigit(StringMid($E,1,1)) then
                While $E<> "" and StringIsDigit(StringMid($E,1,1))
                    $RngE = $RngE & StringMid($E,1,1)
                    $E=StringMid($E,2)
                Wend
                Local $IS=Number($Rng)
                Local $IE=Number($RngE)
                if $USER_RangeEndIsExclusive <> 0 then
                    $IE = $IE - 1                                 ; VDub, End of Range is Exclusive
                EndIf
                if $IE < $IS Then
                    $Rng=""
                    ToolTip("Range Is Exclusive (No Frames)")
                    $ShowCnt = $ShowCntLimit * 2
                Elseif $IE > $IS Then
                    $Rng = StringFormat("%d,%d",$IS,$IE)
                EndIf
            EndIf
        Endif
    Else
        ToolTip("No Range")
        $ShowCnt = $ShowCntLimit * 2
    EndIf
    if $Rng=="" then
        Beep(500,50)
    EndIf
    Return $Rng
EndFunc
Below original post #6.

Quote:
Originally Posted by Barabba View Post
it may check the previous and next frame, use one of them when one is ok, if not interpolate with the closest good one..
There lies the rub, how does one tell if one of them is good, we have no way of telling what a frame is supposed to look like or if it is bad (ie how does one define 'ok', and which is the 'closest one', and closest to what).

A decompressor can tell if there is a problem during decode, and 'conceal' the problem by eg duplicating a frame, in avisynth, all frames are already fully decoded and uncompressed, we do not know if there is/was a problem, nor what it is.

If you can come up with a rule, eg a black frame with nearly identical frames either side is a 'bad' frame, then maybe that could be fixed, but without some kind of rule we would have no idea whatsoever what is good or bad.

ffmpeg, is quite a lot better of late than it used to be and can conceal errors (leastwise thats what it says during conversion), perhaps if you have sufficient disk space you could at least try that BEFORE or instead of SawBones/FrameSurgeon (it might auto get rid of a lot of problems or at least conceal them a little).

Perhaps a simple remux would help (but maybe not), might require decode and recode as lossless video, (audio could be copied or decompressed to PCM lossless)

Perhaps have a try with below
Whatever.bat
Code:
REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)

setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory (ie same as dir .bat file)
set INDIR="."

REM Where to place output file, No terminating Backslash. "." would be same as .bat file
set OUTDIR="D:"

REM Below, can add extensionas as eg *.WMV (SPACE separated)
FOR %%A IN (*.mp4 *.vob *.mpg *.TS) DO (

REM ****** Un-REM ONLY one of below lines *******.
    %FFMPEG% -i "%INDIR%\%%A" -vcodec copy    -acodec copy      "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec copy      "%OUTDIR%\%%~nxA.MKV"                
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"     
REM *********************************************.

)

REM ... Above UN-REM'ed lines : 
REM      (1) Remux, copy both video and audio   (output MKV). 
REM      (2) UtVideo lossless video, copy audio (output MKV).
REM      (3) UtVideo lossless video, PCM audio  (output AVI). 

Pause
EDIT: Original Barabba thread:- http://forum.doom9.org/showthread.php?t=173645
__________________
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; 17th April 2018 at 13:05.
StainlessS is offline   Reply With Quote