fieldmatch "marked as interlaced" -- doesn't work

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

fieldmatch "marked as interlaced" -- doesn't work

Mark Filipak (ffmpeg)
I hoped that "marked as interlaced" [1] meant that

'select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST))' [2]

would work. However, the 'select' doesn't work. I'm counting on the 'select' working -- not working
is a complete show stopper.

Is there some other species of "marked as interlaced" that will make the 'select' work?

Thanks,
Mark.

[1] From https://ffmpeg.org/ffmpeg-filters.html#fieldmatch
"The separation of the field matching and the decimation is notably
motivated by the possibility of inserting a de-interlacing filter
fallback between the two. If the source has mixed telecined and real
interlaced content, fieldmatch will not be able to match fields for
the interlaced parts. But these remaining combed frames will be
*marked as interlaced*, and thus can be de-interlaced by a later
filter such as yadif before decimation."

[2] From https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect
"interlace_type (video only)
"    The frame interlace type. It can assume one of the following values:
"    PROGRESSIVE
"        The frame is progressive (not interlaced).
"    TOPFIRST
"        The frame is top-field-first.
"    BOTTOMFIRST
"        The frame is bottom-field-first."

--
In 5 years, robots will have made bitcoin worthless. Why? Bitcoin miners
don't produce anything. They only consume, and consumption has no value.
Now visualize millions of solar powered, self-replicating bitcoin miners.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

Mark Filipak (ffmpeg)
On 2021-03-14 10:47, Mark Filipak (ffmpeg) wrote:
> I hoped that "marked as interlaced" [1] meant that
>
> 'select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST))' [2]

Have I made myself understood? Do you see the problem?

...progressive.&.scan-int.here... 'select' ...only.progressive.here...

But scan-interlace frames are getting through the 'select'.

Either,
1, 'select' is broken, or
2, 'fieldmatch' is broken, or
3, 'fieldmatch' is setting a different flag (not 'interlace_type').

How do I proceed?

> would work. However, the 'select' doesn't work. I'm counting on the 'select' working -- not working
> is a complete show stopper.
>
> Is there some other species of "marked as interlaced" that will make the 'select' work?
>
> Thanks,
> Mark.
>
> [1] From https://ffmpeg.org/ffmpeg-filters.html#fieldmatch
> "The separation of the field matching and the decimation is notably
> motivated by the possibility of inserting a de-interlacing filter
> fallback between the two. If the source has mixed telecined and real
> interlaced content, fieldmatch will not be able to match fields for
> the interlaced parts. But these remaining combed frames will be
> *marked as interlaced*, and thus can be de-interlaced by a later
> filter such as yadif before decimation."
>
> [2] From https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect
> "interlace_type (video only)
> "    The frame interlace type. It can assume one of the following values:
> "    PROGRESSIVE
> "        The frame is progressive (not interlaced).
> "    TOPFIRST
> "        The frame is top-field-first.
> "    BOTTOMFIRST
> "        The frame is bottom-field-first."

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

Paul B Mahol
On Sun, Mar 14, 2021 at 11:18 PM Mark Filipak (ffmpeg) <[hidden email]>
wrote:

> On 2021-03-14 10:47, Mark Filipak (ffmpeg) wrote:
> > I hoped that "marked as interlaced" [1] meant that
> >
> >
> 'select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST))'
> [2]
>
> Have I made myself understood? Do you see the problem?
>
> ...progressive.&.scan-int.here... 'select' ...only.progressive.here...
>
> But scan-interlace frames are getting through the 'select'.
>
> Either,
> 1, 'select' is broken, or
> 2, 'fieldmatch' is broken, or
> 3, 'fieldmatch' is setting a different flag (not 'interlace_type').
>
4, Missing more than half of information to give actual correct conclusion.

>
> How do I proceed?
>
> > would work. However, the 'select' doesn't work. I'm counting on the
> 'select' working -- not working
> > is a complete show stopper.
> >
> > Is there some other species of "marked as interlaced" that will make the
> 'select' work?
> >
> > Thanks,
> > Mark.
> >
> > [1] From https://ffmpeg.org/ffmpeg-filters.html#fieldmatch
> > "The separation of the field matching and the decimation is notably
> > motivated by the possibility of inserting a de-interlacing filter
> > fallback between the two. If the source has mixed telecined and real
> > interlaced content, fieldmatch will not be able to match fields for
> > the interlaced parts. But these remaining combed frames will be
> > *marked as interlaced*, and thus can be de-interlaced by a later
> > filter such as yadif before decimation."
> >
> > [2] From https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect
> > "interlace_type (video only)
> > "    The frame interlace type. It can assume one of the following values:
> > "    PROGRESSIVE
> > "        The frame is progressive (not interlaced).
> > "    TOPFIRST
> > "        The frame is top-field-first.
> > "    BOTTOMFIRST
> > "        The frame is bottom-field-first."
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

Mark Filipak (ffmpeg)
On 2021-03-15 06:43, Paul B Mahol wrote:

> On Sun, Mar 14, 2021 at 11:18 PM Mark Filipak (ffmpeg) wrote:
>> On 2021-03-14 10:47, Mark Filipak (ffmpeg) wrote:
>>> I hoped that "marked as interlaced" [1] meant that
>>>
>> 'select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST))'
>> [2]
>>
>> Have I made myself understood? Do you see the problem?
>>
>> ...progressive.&.scan-int.here... 'select' ...only.progressive.here...
>>
>> But scan-interlace frames are getting through the 'select'.
>>
>> Either,
>> 1, 'select' is broken, or
>> 2, 'fieldmatch' is broken, or
>> 3, 'fieldmatch' is setting a different flag (not 'interlace_type').
>
> 4, Missing more than half of information to give actual correct conclusion.


I don't know what you mean, Paul, but unless there's features I don't know about,
'fieldmatch,yadif,decimate' is, by design, kind to telecined segments of video but unkind to
scan-interlaced segments.

Here are the facts as I know the facts.

'fieldmatch' pulls up 5-frame telecined segments while leaving frame 4 as a duplicate of frame 3.

Since 'decimate=cycle=5' discards frame 4 in formerly telecined segments, 'FRAME_RATE' is reduced
(to 23.976fps).

Reducing 'FRAME_RATE' in formerly telecined segments also reduces 'FRAME_RATE' in scan-interlaced
segments unless either,
1, internal streams support VFR, or
2, scan-interlaced frames are 'split' out to a secondary stream prior to 'decimate'.

Apparently, internal streams don't support VFR [1], therefore, 'FRAME_RATE' in scan-interlaced
segments is reduced unless scan-interlaced frames are 'split' out.

Scan-interlaced frames can't be 'split' out [2], therefore, the 'FRAME_RATE' in scan-interlaced
segments are reduced.

Since 'FRAME_RATE' reduction in scan-interlaced segments can't be avoided, 1 out of 5
scan-interlaced frames are dropped [3] and video in those segments are be degraded.

[1] If serial ffmpeg streams supported VFR, then detelecined segments v. scan-interlaced segments
could be differentiated via 'FRAME_RATE'

[2] Though 'fieldmatch' flags scan-interlaced frames as 'interlaced', the flag is not 'select'able:
'select=expr=eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST)' always fails.

[3] Though follow-on deinterlacers (e.g. 'yadif') can be inserted between 'fieldmatch' & 'decimate',
doing so does not prevent 1-in-5 frame drops.

I understand what was intended, but what is happening is not what was intended -- the
scan-interlaced sections lose 1 frame in every 5 frames and thereby suffer some judder. The easiest
fix would probably be to make the 'interlaced' flag in note [2] visible to the 'select' filter.

Your comments are welcome.

Regards,
Mark.


>> How do I proceed?
>>
>>> would work. However, the 'select' doesn't work. I'm counting on the
>> 'select' working -- not working
>>> is a complete show stopper.
>>>
>>> Is there some other species of "marked as interlaced" that will make the
>> 'select' work?
>>>
>>> Thanks,
>>> Mark.
>>>
>>> [1] From https://ffmpeg.org/ffmpeg-filters.html#fieldmatch
>>> "The separation of the field matching and the decimation is notably
>>> motivated by the possibility of inserting a de-interlacing filter
>>> fallback between the two. If the source has mixed telecined and real
>>> interlaced content, fieldmatch will not be able to match fields for
>>> the interlaced parts. But these remaining combed frames will be
>>> *marked as interlaced*, and thus can be de-interlaced by a later
>>> filter such as yadif before decimation."
>>>
>>> [2] From https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect
>>> "interlace_type (video only)
>>> "    The frame interlace type. It can assume one of the following values:
>>> "    PROGRESSIVE
>>> "        The frame is progressive (not interlaced).
>>> "    TOPFIRST
>>> "        The frame is top-field-first.
>>> "    BOTTOMFIRST
>>> "        The frame is bottom-field-first."
>>
>> _______________________________________________
>> ffmpeg-user mailing list
>> [hidden email]
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> [hidden email] with subject "unsubscribe".
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
>


--
In 5 years, robots will have made bitcoin worthless. Why? Bitcoin miners
don't produce anything. They only consume, and consumption has no value.
Now visualize millions of solar powered, self-replicating bitcoin miners.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

pdr0
In reply to this post by Mark Filipak (ffmpeg)
Mark Filipak (ffmpeg) wrote

> I hoped that "marked as interlaced" [1] meant that
>
> 'select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST))'
> [2]
>
> would work. However, the 'select' doesn't work. I'm counting on the
> 'select' working -- not working
> is a complete show stopper.
>
> Is there some other species of "marked as interlaced" that will make the
> 'select' work?
>
> Thanks,
> Mark.
>
> [1] From https://ffmpeg.org/ffmpeg-filters.html#fieldmatch
> "The separation of the field matching and the decimation is notably
> motivated by the possibility of inserting a de-interlacing filter
> fallback between the two. If the source has mixed telecined and real
> interlaced content, fieldmatch will not be able to match fields for
> the interlaced parts. But these remaining combed frames will be
> *marked as interlaced*, and thus can be de-interlaced by a later
> filter such as yadif before decimation."
>
> [2] From https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect
> "interlace_type (video only)
> "    The frame interlace type. It can assume one of the following values:
> "    PROGRESSIVE
> "        The frame is progressive (not interlaced).
> "    TOPFIRST
> "        The frame is top-field-first.
> "    BOTTOMFIRST
> "        The frame is bottom-field-first."



Try using combmatch=full for fieldmatch

In this zip file is a sample test video "cadence.mp4". It has 23.976p
content, 29.97i (59.94 fields/sec interlaced) content, and 29.97p content,
all in a 29.97i stream. (There are many others cadences, but those are the 3
most common)
https://www.mediafire.com/file/m46kc4p1uvt7ae3/cadence_tests.zip/file

In this example for -vf select after fieldmatch, the 2 branches are
"progressive" and "not progressive". You can experiment with split and
various processing with interleave in the filter chain

progressive frames after fieldmatch
ffmpeg -i cadence.mp4 -filter_complex "fieldmatch=combmatch=full,
select='eq(interlace_type\,PROGRESSIVE)'" -c:v libx264 -crf 18 -an
fieldmatch_combmatchfull_prog.mkv

not progressive frames after fieldmatch
ffmpeg -i cadence.mp4 -filter_complex "fieldmatch=combmatch=full,
select='not(eq(interlace_type\,PROGRESSIVE))'" -c:v libx264 -crf 18 -an
fieldmatch_combmatchfull_notprog.mkv -y









--
Sent from: http://ffmpeg-users.933282.n4.nabble.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

Mark Filipak (ffmpeg)
On 2021-03-18 01:55, pdr0 wrote:

> Mark Filipak (ffmpeg) wrote
>> I hoped that "marked as interlaced" [1] meant that
>>
>> 'select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST))'
>> [2]
>>
>> would work. However, the 'select' doesn't work. I'm counting on the
>> 'select' working -- not working
>> is a complete show stopper.
>>
>> Is there some other species of "marked as interlaced" that will make the
>> 'select' work?
>>
>> Thanks,
>> Mark.
>>
>> [1] From https://ffmpeg.org/ffmpeg-filters.html#fieldmatch
>> "The separation of the field matching and the decimation is notably
>> motivated by the possibility of inserting a de-interlacing filter
>> fallback between the two. If the source has mixed telecined and real
>> interlaced content, fieldmatch will not be able to match fields for
>> the interlaced parts. But these remaining combed frames will be
>> *marked as interlaced*, and thus can be de-interlaced by a later
>> filter such as yadif before decimation."
>>
>> [2] From https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect
>> "interlace_type (video only)
>> "    The frame interlace type. It can assume one of the following values:
>> "    PROGRESSIVE
>> "        The frame is progressive (not interlaced).
>> "    TOPFIRST
>> "        The frame is top-field-first.
>> "    BOTTOMFIRST
>> "        The frame is bottom-field-first."
>
> Try using combmatch=full for fieldmatch

Really? ...I didn't think of that. The default is 'combmatch=sc'. I assumed that added scene change
logic to 'full'.

> In this zip file is a sample test video "cadence.mp4". It has 23.976p
> content, 29.97i (59.94 fields/sec interlaced) content, and 29.97p content,
> all in a 29.97i stream. (There are many others cadences, but those are the 3
> most common)
> https://www.mediafire.com/file/m46kc4p1uvt7ae3/cadence_tests.zip/file

Thanks! That was very kind of you! I'll give it a look.

My current test video is very mixed (and mixed-up) content:
29.970fps(24pps)        ...telecined (movie clips)
+ 29.970fps(59.940sps)   ...scan-interlaced (interviews)
+ 29.970fps(29.970pps)   ...progressive (interviews)
+ 29.970fps(mutt)       ...[1] (location shots)
[1] A mess of nearly random combed, progressive, and repeated frames (amazingly, it looks quite good
on-screen).
The video is from an actual Blu-ray -- would you believe it?

Here is my current filter complex (awaiting methods to 'split' the stream into secondary streams):

settb=expr=1/720000,setpts=N*24024,fps=30000/1001,
fieldmatch,split=3[1][2][3],
[1]select=expr=eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST),yadif,telecine=pattern=8[4],
[2]select=?????,telecine=pattern=8[5],
[3]select=expr=not(eq(interlace_type\,TOPFIRST)+eq(interlace_type\,BOTTOMFIRST)),decimate,telecine=pattern=2,telecine=pattern=55[6],
[4][5][6]interleave=nb_inputs=3

> In this example for -vf select after fieldmatch, the 2 branches are
> "progressive" and "not progressive". You can experiment with split and
> various processing with interleave in the filter chain

Really?! I tried 'eq(interlace_type\,PROGRESSIVE)' in my first attempt and, when that didn't work,
went with functions of 'TOPFIRST' & 'BOTTOMFIRST'. Hmmm... I guess it's time to download the latest
ffmpeg git and try again.

BTW, Tonight I submitted Subject: "'streampatterns' -- a proposed stream structure filter". I think
it would make for an excellent, general purpose solution. I'm eager to read what the folks think of
it. I could do all the algorithm coding but I don't write 'C' (only 'C' syntax), so have never
compiled 'C' and don't know how to use structs. I'd need help with the integration.

Thanks Again,
Mark.

--
Robotics will make bitcoin worthless. Why? Visualize millions of solar powered, self-replicating
bitcoin miners. How much would they be worth? Bitcoin maintains marginal value solely via built-in
inflation. That essentially makes bitcoin a Ponzi scheme, and it will be shut down by governments.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

Mark Filipak (ffmpeg)
In reply to this post by pdr0
On 2021-03-18 01:55, pdr0 wrote:

> https://www.mediafire.com/file/m46kc4p1uvt7ae3/cadence_tests.zip/file

Thanks again. I haven't tested my filters on cadence.mp4 yet to see if they work as expected.

How did you make cadence.mp4? Did you use ffmpeg to make it? Or did you use something else?

If you somehow used ffmpeg, would you share the command line?

Regards,
Mark.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: fieldmatch "marked as interlaced" -- doesn't work

pdr0
Mark Filipak (ffmpeg) wrote

> On 2021-03-18 01:55, pdr0 wrote:
>
>> https://www.mediafire.com/file/m46kc4p1uvt7ae3/cadence_tests.zip/file
>
> Thanks again. I haven't tested my filters on cadence.mp4 yet to see if
> they work as expected.
>
> How did you make cadence.mp4? Did you use ffmpeg to make it? Or did you
> use something else?
>
> If you somehow used ffmpeg, would you share the command line?


The original animation (I'm sure you've seen variations this video before
for testing) was done in after effects. (It is very simple and could
produced in any number of free, open source programs such as natron,
blender, shotcut etc...)

The re-organization into fields, and cadence patterns was done in avisynth

ffmpeg libx264 was used for the encoding






--
Sent from: http://ffmpeg-users.933282.n4.nabble.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".