[FFmpeg-user] Decombing via screening - 'tblend' bug (?)

Mark Filipak markfilipak.windows+ffmpeg at gmail.com
Wed Apr 15 13:20:19 EEST 2020


On 04/15/2020 06:16 AM, Paul B Mahol wrote:
> On 4/15/20, Mark Filipak <markfilipak.windows+ffmpeg at gmail.com> wrote:
>> On 04/15/2020 05:38 AM, Paul B Mahol wrote:
>>> On 4/15/20, Mark Filipak <markfilipak.windows+ffmpeg at gmail.com> wrote:
>>>> On 04/15/2020 05:00 AM, Paul B Mahol wrote:
>>>>> On 4/15/20, Mark Filipak <markfilipak.windows+ffmpeg at gmail.com> wrote:
>>>>>> On 04/15/2020 04:25 AM, Paul B Mahol wrote:
>>>>>>> On 4/15/20, Mark Filipak <markfilipak.windows+ffmpeg at gmail.com> wrote:
>>>>>>>> Request for bug confirmation is included.
>>>>>>>>
>>>>>>>> Correction: I had datascope in #2 just 1 time. I don't know how it
>>>>>>>> got
>>>>>>>> into
>>>>>>>> the original post twice.
>>>>>>>> Sorry. - M.
>>>>>>>>
>>>>>>>> On 04/14/2020 10:24 AM, Paul B Mahol wrote:
>>>>>>>>> On 4/14/20, Mark Filipak <markfilipak.windows+ffmpeg at gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>> In the command line below,
>>>>>>>>>>                      I will eventually insert a screen maker --+
>>>>>>>>>>                                                                ¦
>>>>>>>>>> separatefields,scale=height=2*in_h:sws_flags=neighbor,--HERE--,tblend=normal[D]
>>>>>>>>>>
>>>>>>>>>> but first, I need to persuade 'tblend' to accept the 2 frames made
>>>>>>>>>> by
>>>>>>>>>> 'separatefields' (and scaled
>>>>>>>>>> by 'scale').
>>>>>>>>>> But as you can see in the next section (extracted from the log),
>>>>>>>>>> though
>>>>>>>>>> the
>>>>>>>>>> 'height=2*in_h'
>>>>>>>>>> directive works (i.e., the 1920x540 frames from 'separatefields'
>>>>>>>>>> are
>>>>>>>>>> scaled
>>>>>>>>>> to 1920x1080), ffmpeg is
>>>>>>>>>> not happy. Is it because the SARs don't match? How can I overcome
>>>>>>>>>> that?
>>>>>>>>>> Thanks!
>>>>>>>>>
>>>>>>>>> Insert setsar=1 after scale?
>>>>>>>>
>>>>>>>> Thank you, Paul. It works. I apologize for not finding that solution
>>>>>>>> on
>>>>>>>> my
>>>>>>>> own ...how embarrassing.
>>>>>>>>
>>>>>>>> Next problem: 'tblend' appears to be malfunctioning.
>>>>>>>>
>>>>>>>> "The tblend (time blend) filter takes two consecutive frames from one
>>>>>>>> single
>>>>>>>> stream, and outputs the
>>>>>>>> result obtained by blending the new frame on top of the old frame."
>>>>>>>>
>>>>>>>> #1 - This works as expected:
>>>>>>>> ffmpeg -i IN -filter_complex "telecine=pattern=5, split[A][B],
>>>>>>>> [A]select='not(eq(mod(n+1\,5)\,3))'[C],
>>>>>>>> [B]select='eq(mod(n+1\,5)\,3)',
>>>>>>>> datascope=size=1920x1080:x=45:y=340:mode=color2[D], [C][D]interleave"
>>>>>>>> OUT
>>>>>>>>
>>>>>>>> #2 - This malfunctions:
>>>>>>>> ffmpeg -i IN -filter_complex "telecine=pattern=5, split[A][B],
>>>>>>>> [A]select='not(eq(mod(n+1\,5)\,3))'[C],
>>>>>>>> [B]select='eq(mod(n+1\,5)\,3)',
>>>>>>>> separatefields,
>>>>>>>> scale=height=2*in_h:sws_flags=neighbor, setsar=1, tblend,
>>>>>>>> datascope=size=1920x1080:x=45:y=340:mode=color2, [C][D]interleave"
>>>>>>>> OUT
>>>>>>>>
>>>>>>>> #1 brings up datascope in frames (n, zero-based): 2 7 12 17 etc., as
>>>>>>>> expected.
>>>>>>>> #2 brings up datascope in frames (n, zero-based): 4 7 10 13 etc.
>>>>>>>>
>>>>>>>> Another clue is:
>>>>>>>> #1 OUT has 598 frames.
>>>>>>>> #2 OUT has 716 frames.
>>>>>>>>
>>>>>>>> Would someone who has the latest nightly build kindly confirm this. I
>>>>>>>> can
>>>>>>>> supply the test video --
>>>>>>>> contact me off-list.
>>>>>>>
>>>>>>> You still can not read documentation? Why?
>>>>>>>
>>>>>>> interleave filter simply picks frames from several streams.
>>>>>>> This is obviously explained in documentation.
>>>>>>> tblend filter blend successive frames, this is obviously different
>>>>>>> from interlace filter as that will not drop any frame like interlace
>>>>>>> does.
>>>>>>
>>>>>> Look at my command lines again. Here, I'll give you filtergraphs:
>>>>>>
>>>>>> #1
>>>>>> telecine -> split -> select (n+1%5!=3) ---------------------------->
>>>>>> interleave
>>>>>>                       -> select (n+1%5==3) ---------------------------->
>>>>>> 598 frames (correct)
>>>>>>
>>>>>> #2
>>>>>> telecine -> split -> select (n+1%5!=3) ---------------------------->
>>>>>> interleave
>>>>>>                       -> select (n+1%5==3) -> separatefields...tblend ->
>>>>>> 716 frames (malfunction)
>>>>>>
>>>>>> 598*4/5 = 478 frames (upper 'select')
>>>>>> 598*1/5 = 119 frames (lower 'select')
>>>>>> 119*2 = 238 frames (output of 'separatefields')
>>>>>> 238/2 = 119 frames (what output of 'tblend' is supposed to be)
>>>>>> 238 frames (what output of 'tblend' actually is)
>>>>>> 478+238 = 716 frames (output of 'interleave' showing that 'tblend'
>>>>>> malfunctions)
>>>>>>
>>>>>
>>>>> tblend works fine, you obviously do not know what you doing.
>>>>>
>>>>> Given frames: A B C D E F G:
>>>>>
>>>>> tblend gives this output: AB BC CD DE EF FG, so original number of
>>>>> frames in input minus one.
>>>>
>>>> Are you even looking at the command lines?
>>>>
>>>> #2
>>>> telecine -> split -> select (n+1%5!=3) ---------------------------->
>>>> interleave
>>>>                      -> select (n+1%5==3) -> separatefields...tblend ->
>>>>
>>>> 'telecine' input (IN) is      A B C...
>>>> 'telecine' output is          A A AB B B ... (modulo 5) ...frame 2 is
>>>> combed
>>>> upper 'select' output is      A A __ B B (n+1%5!=3)     ...progressive
>>>> frames
>>>> lower 'select' output is      _ _ AB _ _ (n+1%5==3)     ...combed frame
>>>> 'separatefields' output is        AB AB                 ...2 frames (1/2
>>>> height)
>>>> 'scale=height=2*in_h' output is   AB AB                 ...2 frames (full
>>>> height)
>>>> 'tblend' output is supposed to be AB                    ...1 frame
>>>> OUT is supposed to be         A A AB B B                ...598 frames
>>>> OUT is                        A A AB AB B B             ...716 frames
>>>> Conclusion: 'tblend' is outputting 2 frames instead of 1 frame.
>>>
>>> And that is completely correct for filter to do.
>>>
>>> If you not happy with that, write own code instead.
>>
>>   From here: https://ffmpeg.org/ffmpeg-filters.html#blend
>> "The tblend (time blend) filter takes two consecutive frames from one single
>> stream, and outputs the
>> result obtained by blending the new frame on top of the old frame."
>>
>> Seems to me that 'tblend' is supposed to output 1 frame.
> 
> Nope.
> 
> Enjoy living in your own world.

This:

ffmpeg -i IN -filter_complex 
"telecine=pattern=5,split[A][B],[A]select='not(eq(mod(n+1\,5)\,3))'[C],[B]select='eq(mod(n+1\,5)\,3)',split[E][F],[E][F]blend[D],[C][D]interleave" 
OUT

outputs 598 frames. 'blend' outputs as expected.

This:

ffmpeg -i IN -filter_complex 
"telecine=pattern=5,split[A][B],[A]select='not(eq(mod(n+1\,5)\,3))'[C],[B]select='eq(mod(n+1\,5)\,3)',separatefields,scale=height=2*in_h:sws_flags=neighbor,setsar=1,tblend[D],[C][D]interleave" 
OUT

outputs 716 frames. 'tblend' (documented in the same article) outputs extra frames.

Now, does that look consistent to you?

But of course, since I can't read, and I'm always wrong...



More information about the ffmpeg-user mailing list