Discussion:
[FFmpeg-user] Interlaced x264
Anatol
2016-04-05 06:51:46 UTC
Permalink
Hi,
I am looking for a way to create interlaced x264 TFF file.
The media info result that I get is

Scan type : MBAFF

The scan order is not mentioned.
The '-vf idet' check of the resultant file is considerably different
compared to an interlaced PAFF file.

Command line:

ffmpeg -threads 1 -i
/web//content/r71v1/entry/data/551/98/1_jpzy9xr0_1_t3mdjl8h_11.mp4 -c:v
libx264 -subq 7 -qcomp 0.6 -qmin 10 -qmax 50 -qdiff 4 -bf 16 -coder 1
-refs 6 -x264opts
b-pyramid:weightb:mixed-refs:8x8dct:no-fast-pskip=0:interlaced=1:tff=1:weightp=0
-vprofile high -force_key_frames expr:'gte(t,n_forced*2)' -pix_fmt yuv420p
-b:v 4000k -s 720x480 -r 29.97 -g 60 -aspect 720:480 -c:a libfdk_aac -b:a
128k -ar 48000 -ac 2 -f mpegts -flags +loop+mv4 -cmp 256 -partitions
+parti4x4+partp8x8+partb8x8 -trellis 1 -refs 3 -me_range 16 -keyint_min 20
-sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 4000k -bufsize 8000k
-rc_eq 'blurCplx^(1-qComp)' -aspect 4:3 -top 1 -flags +ilme+ildct -vsync 1
-threads 4 -y BBB_30sec_interlaced.ts

Uncut console output - in the attached file.

Thanks in advance,
Anatol
Carl Eugen Hoyos
2016-04-05 09:29:07 UTC
Permalink
Post by Anatol
The '-vf idet' check of the resultant file is considerably
different compared to an interlaced PAFF file.
x264 does not support PAFF, this is not related to FFmpeg.

What does idet show for your input video? What exactly do
you want? I would have expected that your usecase is not
"I want Mediainfo to show interlaced for my output file".

Carl Eugen
Anatol
2016-04-05 09:51:34 UTC
Permalink
Following are idet results of my file:

[Parsed_idet_0 @ 0x1dee2c0] Repeated Fields: Neither: 903 Top: 0
Bottom: 1
[Parsed_idet_0 @ 0x1dee2c0] Single frame detection: TFF: 0 BFF: 0
Progressive: 220 Undetermined: 684
[Parsed_idet_0 @ 0x1dee2c0] Multi frame detection: TFF: 0 BFF: 0
Progressive: 902 Undetermined: 2

While those are idet of a sample file that was generated from the same
source and with similar encoding params (more or less), but with PAFF/TFF:

[Parsed_idet_0 @ 0x19e7540] Repeated Fields: Neither: 884 Top: 11
Bottom: 5
[Parsed_idet_0 @ 0x19e7540] Single frame detection: TFF: 572 BFF: 0
Progressive: 2 Undetermined: 326
[Parsed_idet_0 @ 0x19e7540] Multi frame detection: TFF: 900 BFF: 0
Progressive: 0 Undetermined: 0

Well, it would be nice if the Mediainfo would say it that it is
'interlaced' with 'Top Field First' scan order,
but my main concern that those files have different structure, therefore
the file that I generated won't comply with the sample file that I got.

Anatol
Carl Eugen Hoyos
2016-04-05 10:26:27 UTC
Permalink
Which file? The input or output file? Of which operation?
Sorry if my question was unlear.
[Parsed_idet_0] Repeated Fields: Neither: 903 Top: 0
Bottom: 1
[Parsed_idet_0] Single frame detection: TFF: 0 BFF: 0
Progressive: 220 Undetermined: 684
[Parsed_idet_0] Multi frame detection: TFF: 0 BFF: 0
Progressive: 902 Undetermined: 2
While those are idet of a sample file that was generated from
the same source and with similar encoding params (more or less),
Which FFmpeg command created the file that idet detects as TFF?

Please understand that there are two *completely* unrelated
definitions related to your question:
I consider a file "interlaced" if horizontal motion, if
checked visually, leads to ugly combing effects.
Mediainfo cannot detect if a file is "interlaced" (according
to my above definition) because you have to inspect the
frames, usually visually but idet can do this for you.

Another definition of "interlaced" is the used encoding
type: Either the whole frame was encoded "progressively" or
every frame was encoded as two fields (interlaced, PAFF) or
(the following is said to produce better compression) a
more sophisticated method that also leads to "interlaced"
encoding as detected by Mediainfo is used.
This second definition of "interlaced" applies to all SD
DVB streams I know, no matter if they contain live
(really interlaced) content or 24/25fps movie or TV content
that has no combing artefacts, no matter how interlaced it
is supposed to be.

Or to say it differently: You can use interlaced encoding
for progressive input material (as you did in your example)
but the output will still be progressive although Mediainfo
will claim it is interlaced. If you used PAFF, the encoding
efficiency is expected to be (slightly) worse than if you
had used progressive encoding. For MBAFF, this disadvantage
may not exist but the "interlaced" output would still be
progressive because the input was progressive.

If you use progressive encoding for interlaced input you
need a (very) much higher bitrate to get acceptable quality.

You may want to look at the interlace filter but if your
input is <50fps, you won't be happy with the output.

If you absolutely (really) want to get a few ugly arefacts
in your input stream to make somebody happy, try the phase
filter;-)

Carl Eugen
Anatol
2016-04-05 10:42:13 UTC
Permalink
The idet results are of an output file.
The source is progressive.
I don't have the command line of the sample file.

I am aware that those are unrelated issues, but thanks for the clear
expatiation, it helped me to understand it better.
I'll try the 'interlace' filter, but skip the 'phase' filter.

Do u know how can I make it encoded in a way that it will be identified as
TFF?

Anatol
Paul B Mahol
2016-04-05 10:52:08 UTC
Permalink
Post by Anatol
The idet results are of an output file.
The source is progressive.
I don't have the command line of the sample file.
I am aware that those are unrelated issues, but thanks for the clear
expatiation, it helped me to understand it better.
I'll try the 'interlace' filter, but skip the 'phase' filter.
Why you are using interlace filter?

Why are you using phase filter in combination with interlace filter?
Post by Anatol
Do u know how can I make it encoded in a way that it will be identified as
TFF?
Anatol
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Carl Eugen Hoyos
2016-04-05 10:58:52 UTC
Permalink
Post by Anatol
Do u know how can I make it encoded in a way that it will
be identified as TFF?
I try not to think too much about interlaced encoding but I
suspect for MBAFF TFF/BFF have no meaning.

Carl Eugen
Kim Bak
2016-04-05 12:33:27 UTC
Permalink
Post by Anatol
The idet results are of an output file.
The source is progressive.
I don't have the command line of the sample file.
I am aware that those are unrelated issues, but thanks for the clear
expatiation, it helped me to understand it better.
I'll try the 'interlace' filter, but skip the 'phase' filter.
Do u know how can I make it encoded in a way that it will be identified as
TFF?
Try adding -flags +ildct to ffmpeg, this will create an interlaced tff
(top field first) file for you when used with x264

ffmpeg -i input.file -an -c:v libx264 -flags +ildct interlaced.mp4
Post by Anatol
Anatol
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Ivan Cacique
2016-04-05 12:51:26 UTC
Permalink
I'm having serious problems with the latest versions of ffmpeg with constants lockups .

Since ffmpeg-20160310-git-689211d-win64-static

Ivan
Reindl Harald
2016-04-05 12:59:01 UTC
Permalink
Post by Ivan Cacique
I'm having serious problems with the latest versions of ffmpeg with constants lockups
Since ffmpeg-20160310-git-689211d-win64-static
* no subject
* no real problem description
* just wow

http://www.catb.org/esr/faqs/smart-questions.html#beprecise
Anatol
2016-04-05 13:00:32 UTC
Permalink
Kim,
I used that flag ("-flags +ilme+ildct"),
but got the results that u can see above
Andy Furniss
2016-04-06 18:23:08 UTC
Permalink
Post by Anatol
The idet results are of an output file.
The source is progressive.
I don't have the command line of the sample file.
I am aware that those are unrelated issues, but thanks for the clear
expatiation, it helped me to understand it better.
I'll try the 'interlace' filter, but skip the 'phase' filter.
Do u know how can I make it encoded in a way that it will be identified as
TFF?
-vf setfield=tff
Anatol
2016-04-06 19:40:44 UTC
Permalink
Thanks And,
But no, it did not help
Post by Andy Furniss
Post by Anatol
The idet results are of an output file.
The source is progressive.
I don't have the command line of the sample file.
I am aware that those are unrelated issues, but thanks for the clear
expatiation, it helped me to understand it better.
I'll try the 'interlace' filter, but skip the 'phase' filter.
Do u know how can I make it encoded in a way that it will be identified as
TFF?
-vf setfield=tff
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Andy Furniss
2016-04-06 21:02:40 UTC
Permalink
Post by Anatol
Thanks And,
But no, it did not help
Please avoid top posting.

Yea, I missed that your rather long command line already had -top 1
in addition to -flags +ilme+ildct.

Earlier in the thread mediainfo got a mention and given progressive
input for libx264 either

-vf setfield=tff -x264opts tff=1 or

-top 1 -flags +ilme+ildct

will produce correct output in the sense that ffprobe/mediainfo will
show tff and mbaff will be used by libx264.

Using idet as has been said will just show what it really is.

If your source is 50 or 60(/1.001) fps progressive than you could try
to make real interlaced from it with tinterlace.

Your input bbb test file is 30 fps, your ffmpeg is not current, and I
guess libx264 is old, or maybe doesn't get/parse your "monster" command
line :-)

I mean if I using a simple line, ask for interlaced -x264opts tff=1 then
I see it works by output from libx264 like -

...
[libx264 @ 0x30125a0] interlace + weightp is not implemented
...

I don't see that in your output (it's informational, not an error).
Post by Anatol
Post by Andy Furniss
Post by Anatol
The idet results are of an output file.
The source is progressive.
I don't have the command line of the sample file.
I am aware that those are unrelated issues, but thanks for the clear
expatiation, it helped me to understand it better.
I'll try the 'interlace' filter, but skip the 'phase' filter.
Do u know how can I make it encoded in a way that it will be identified as
TFF?
-vf setfield=tff
Anatol
2016-04-07 09:27:18 UTC
Permalink
Andy,
U don't see 'weightp' warning, because I have 'weightp=0' at the end of the
'x264opts' list in my "monster" command line (its sometimes a fun to be a
monster ...).
The results with ffmpeg3 are the same (for monster and simple cmd-lines).
In all cases the x264 gets the correct interlaced params - media info shows
"interlaced=tff" in the 'Encoding settings', but the 'idet' test remains
the same.

But, it look like 'tinterlace' produces something more meaningful -

[Parsed_idet_0 @ 0x1fdb060] Repeated Fields: Neither: 118 Top: 0
Bottom: 2
[Parsed_idet_0 @ 0x1fdb060] Single frame detection: TFF: 105 BFF: 2
Progressive: 1 Undetermined: 12
[Parsed_idet_0 @ 0x1fdb060] Multi frame detection: TFF: 120 BFF: 0
Progressive: 0 Undetermined: 0

But only with 'simple' cmd line:

ffmpeg -threads 1 -i BBB_30sec.mp4 -c:v libx264 -vf
"tinterlace,fieldorder=tff" -flags +ilme+ildct -threads 4 -y
BBB_30sec_interlaced.ts


Do u know whether there are any quality or other issues with 'tinterlace'
filter?

Thanks,
Anatol
Carl Eugen Hoyos
2016-04-07 09:47:54 UTC
Permalink
Post by Anatol
Do u know whether there are any quality or other
issues with 'tinterlace' filter?
It permanently damages your video, just inspect visually.

Carl Eugen
Andy Furniss
2016-04-07 20:04:52 UTC
Permalink
Post by Anatol
Andy,
U don't see 'weightp' warning, because I have 'weightp=0' at the end of the
'x264opts' list in my "monster" command line (its sometimes a fun to be a
monster ...).
Oh OK
Post by Anatol
The results with ffmpeg3 are the same (for monster and simple cmd-lines).
In all cases the x264 gets the correct interlaced params - media info shows
"interlaced=tff" in the 'Encoding settings', but the 'idet' test remains
the same.
But, it look like 'tinterlace' produces something more meaningful -
Bottom: 2
Progressive: 1 Undetermined: 12
Progressive: 0 Undetermined: 0
ffmpeg -threads 1 -i BBB_30sec.mp4 -c:v libx264 -vf
"tinterlace,fieldorder=tff" -flags +ilme+ildct -threads 4 -y
BBB_30sec_interlaced.ts
You need to use tinterlace properly to make interlaced.

https://www.ffmpeg.org/ffmpeg-filters.html#tinterlace

I don't know why you need fieldorder.

https://www.ffmpeg.org/ffmpeg-filters.html#fieldorder
Post by Anatol
Do u know whether there are any quality or other issues with 'tinterlace'
filter?
Carl Eugen is correct - you are basically breaking videos doing this.

Why do you need to make interlaced from progressive?

If you have good reason (and 50/60 fps source) then you also have to
be careful around chroma conversions and any scaling filters for which
may get auto inserted and break chroma (cause it to bleed between fields).

Having never done this myself I can't just give a working command line.
Carl Eugen Hoyos
2016-04-08 10:46:53 UTC
Permalink
Post by Andy Furniss
Post by Anatol
Do u know whether there are any quality or other
issues with 'tinterlace' filter?
Carl Eugen is correct - you are basically breaking
videos doing this.
Why do you need to make interlaced from progressive?
If you have good reason (and 50/60 fps source)
Allow me to repeat: If you want your 25/30 fps input
to look ugly (to make somebody happy) just use the
phase filter: It is difficult to see a difference
between interlaced and "phased" video.

Carl Eugen
PSPunch
2016-04-11 02:22:12 UTC
Permalink
Post by Andy Furniss
Why do you need to make interlaced from progressive?
Excuse me to jump in.
For example, when encoding for BD I need to make the choice between
1080i to retain resolution, or 720p for ease of handling.
(Although I never had to used FFmpeg for this task)
Post by Andy Furniss
If you have good reason (and 50/60 fps source) then you also have to
be careful around chroma conversions and any scaling filters for which
may get auto inserted and break chroma (cause it to bleed between fields).
Is there a technical term for this phenomenon, or any resources I can
read further on this? Hopefully one aimed at video operators rather than
codec designers...

Thanks.
--
David Shimamoto
Andy Furniss
2016-04-14 20:12:56 UTC
Permalink
Post by Andy Furniss
Why do you need to make interlaced from progressive?
Excuse me to jump in. For example, when encoding for BD I need to
make the choice between 1080i to retain resolution, or 720p for ease
of handling. (Although I never had to used FFmpeg for this task)
I guess there are some valid cases.

720p is somewhat higher vertical res than 1080i allowing for two
fields and extra low pass filtering interlaced content undergoes.
Post by Andy Furniss
If you have good reason (and 50/60 fps source) then you also have
to be careful around chroma conversions and any scaling filters for
which may get auto inserted and break chroma (cause it to bleed
between fields).
Is there a technical term for this phenomenon, or any resources I can
read further on this? Hopefully one aimed at video operators rather
than codec designers...
I don't really know the technical term, but mpeg mandates that 420
weaved interlaced and 420 progressive content have different chroma
sub-sampling positions. In the weaved case fields have to be treated
separately.

www.mir.com/DMG/chroma.html

I don't think ffmpeg can handle the positions for top/bottom correctly.

It can treat fields separately when scaling or changing chroma format.

-vf scale=interl=1 should do this, but sometimes depending on other
commands a scaler may be auto inserted which will mess this up.

Carl Eugen Hoyos
2016-04-05 11:00:29 UTC
Permalink
Post by Carl Eugen Hoyos
You may want to look at the interlace filter but if your
input is <50fps, you won't be happy with the output.
The name of the correct filter is "tinterlace", sorry
about my mistake.

Carl Eugen
Continue reading on narkive:
Loading...