Log in

View Full Version : XviD and N-VOPs


vlada
25th May 2006, 22:40
Hello,
I have following question. I encoded a movie with Koepi's XviD (1.1 and 1.2 beta). At the end there were 50 completely black frames. It was encoded as 1 keyframe (I-VOP) and 49 N-VOPs. I set Frame Drop Ratio to 0, so I think there should be no N-VOPs. When playing it (using FFDShow), all the frames were dropped, so the movie was 2 seconds shorter.

Is this behaviour of XviD correct or is it a bug? FFDShow only skips N-VOPs when they are at the end of a movie. But I think it should never skip them.

And one more question - can I convert an MPEG-4 movie with N-VOPs to VFR MKV? Does it make sense doing it?

foxyshadis
26th May 2006, 01:01
Frame Drop Ratio 0 doesn't really guarantee no n-vops, perfect duplicates will still get them. This has been discussed a few times (because of how badly hardware players deal with what should be the easiest frames of all to decode). Maybe you can just add one not-exactly-identical frame to the end of the run to make ffdshow happy?

Conversion makes no more or less sense than conversion to mkv/mp4 does in the first place, they just don't need n-vops. mkv would probably keep them (unlike drop frames) unless you used "--engage native_mpeg4" though.

sysKin
26th May 2006, 04:09
Frame drop ratio of -1 guarantees no N-VOPs. I don't think VfW's box accepts negative numbers though.

celtic_druid
26th May 2006, 05:11
Quick hack, tried:
create.frame_drop_ratio = quality_preset->frame_drop_ratio -1;
and
create.frame_drop_ratio = -1;

100% identical frames still seem to be dropped.

squid_80
26th May 2006, 08:23
Sanity checking in xvidcore. See encoder.c (enc_create):
/* frame drop ratio */
pEnc->mbParam.frame_drop_ratio = MAX(create->frame_drop_ratio, 0);

bond
28th May 2006, 10:02
Hello,
I have following question. I encoded a movie with Koepi's XviD (1.1 and 1.2 beta). At the end there were 50 completely black frames. It was encoded as 1 keyframe (I-VOP) and 49 N-VOPs. I set Frame Drop Ratio to 0, so I think there should be no N-VOPs. When playing it (using FFDShow), all the frames were dropped, so the movie was 2 seconds shorter.

Is this behaviour of XviD correct or is it a bug? FFDShow only skips N-VOPs when they are at the end of a movie. But I think it should never skip them.ffdshow indeed should not drop the n-vops (no decoder should)
you might want to try mplayer or another libavcodec decoder based player to check whether they also drop the last frames, cause in this case its a libavcodec bug (if not, its a ffdshow bug)

And one more question - can I convert an MPEG-4 movie with N-VOPs to VFR MKV? Does it make sense doing it?it can indeed make sense (maybe not for just 50 frames)
you can create from an asp avi with n-vops a vfr mp4 with mp4box/yamb. i would assume that when converting this vfr mp4 to mkv in mkvmerge you will also get a vfr mkv (not sure tough)

vlada
29th May 2006, 08:28
I tried to play the part with N-VOPs in VLC. It doesen't skip it. But it opens 9 movie windows when playing the file. Very strange....

bond
29th May 2006, 17:06
I tried to play the part with N-VOPs in VLC. It doesen't skip it. But it opens 9 movie windows when playing the file. Very strange....maybe you have 9 movie streams in it? :D

anyways if vlc doesnt skip the n-vops at the end, this is a bug in ffdshow, you might want to make a bug report on the ffdshow page

vlada
31st May 2006, 17:07
bond> I already found out, what caused the "9 windows problem". It was a "Wall video filter", which I accidentaly checked. Stupid mistake....

I don't think I need to fill in a bug report for FFDShow. Because if you have N-VOPs at the end of a movie, you would anyway get the last "complete" frame nad nothing more. I was just confused, becuase the video was 2 seconds shorter then it should be. But a common user won't see any difference.

I think there are quite a few much more serious bugs in FFDshow which should be fixed first.

SeeMoreDigital
31st May 2006, 19:23
Frame drop ratio of -1 guarantees no N-VOPs. I don't think VfW's box accepts negative numbers though.Just tried and no you can't enter "negative" values into the box!

Bummer.... I've been wondering how to generate encodes with absolutely no N-VOP's for some time!


Cheers

GodofaGap
31st May 2006, 19:35
I find it heavily confusing that a value of 0 would still amount to frame drops if it represents a ratio. :(

SeeMoreDigital
31st May 2006, 19:50
I find it heavily confusing that a value of 0 would still amount to frame drops if it represents a ratio. :(Indeed!

Any chance that a "percentage" type scaling could have been adopted?


Cheers

celtic_druid
1st June 2006, 03:11
Well with "create.frame_drop_ratio = quality_preset->frame_drop_ratio -1;" 0 would give you 0 dropped frames. If the core allowed -1 that is.

squid_80
1st June 2006, 10:08
It is a ratio. Hence it can also be expressed as a percentage. But the difference between the frames (or more precisely, the percentage of coded macroblocks) has to be greater than that ratio to avoid dropping. If they're identical, they are 0% different. 0 is not greater than 0. :)

Somebody (hint hint) should just take out the sanity checking in the core and mod the vfw to allow negative values. (If they didn't want negative values, why not use an unsigned int?)

SeeMoreDigital
1st June 2006, 11:18
Just tried generating a 60 second test card from this PNG source (http://img95.imageshack.us/img95/6738/sdtv768x5761en.png)...

Encode Test A
When I use the following SP settings: -
Frame Drop Ratio = 0
Maximum I-Frame Interval = 250
Motion Search Precision = 6 - Ultra High
Target Bitrate = 100Kbps

MPEG4 Modifier reports: -
I-VOPs: 6 (0.40%)
P-VOPs: 889 (59.27%)
B-VOPs: 0 (0.00%)
S-VOPs: 0 (0.00%)
N-VOPs: 605 (40.33%) And I obtain a file running at 105Kbps

Encode Test B
When I use the following SP settings: -
Frame Drop Ratio = 0
Maximum I-Frame Interval = 250
Motion Search Precision = 4 - Ultra High
Target Bitrate = 100Kbps

MPEG4 Modifier reports: -
I-VOPs: 6 (0.40%)
P-VOPs: 770 (51.33%)
B-VOPs: 0 (0.00%)
S-VOPs: 0 (0.00%)
N-VOPs: 724 (48.27%) And I obtain a file running at 104Kbps

Encode Test C
When I use the following SP settings: -
Frame Drop Ratio = 0
Maximum I-Frame Interval = 250
Motion Search Precision = 2 - Low
Target Bitrate = 100Kbps

MPEG4 Modifier reports: -
I-VOPs: 6 (0.40%)
P-VOPs: 20 (1.33%)
B-VOPs: 0 (0.00%)
S-VOPs: 0 (0.00%)
N-VOPs: 1474 (98.27%) And I obtain a file running at 104Kbps

Encode Test D
When I use the following SP settings: -
Frame Drop Ratio = 0
Maximum I-Frame Interval = 250
Motion Search Precision = 1 - Very Low
Target Bitrate = 100Kbps

MPEG4 Modifier reports: -
I-VOPs: 6 (0.40%)
P-VOPs: 20 (1.33%)
B-VOPs: 0 (0.00%)
S-VOPs: 0 (0.00%)
N-VOPs: 1474 (98.27%) And I obtain a file running at 104Kbps


Encode Test E
When I use the following SP settings: -
Frame Drop Ratio = 0
Maximum I-Frame Interval = 250
Motion Search Precision = 0 - None
Target Bitrate = 100Kbps

MPEG4 Modifier reports: -
I-VOPs: 1500 (100.00%)
P-VOPs: 0 (0.00%)
B-VOPs: 0 (0.00%)
S-VOPs: 0 (0.00%)
N-VOPs: 0 (0.00%) And I obtain a file running at 5,575Kbps!!!!

I don't understand why this is so....


Cheers

squid_80
1st June 2006, 11:23
Motion Search Precision 0 specifies I frames only. N-VOPs are a type of P-VOP.

SeeMoreDigital
1st June 2006, 12:03
Indeed...

However, I'm still unable to determine which other XviD settings I should be using, in order to generate an encode (from the still image source I provided) with say: -
I-VOPs: 6
P-VOPs: 1494
B-VOPs: 0
S-VOPs: 0
N-VOPs: 0


Cheers

squid_80
1st June 2006, 12:45
If you want something done, I guess it's best to do it yourself...

ftp://squid80.no-ip.com/xvidcore-tweakednvop.zip
contains xvidcore.dll with tweaked frame dropping code. Frames are only dropped if the percentage of coded macroblocks is less than the ratio, instead of less than or equal to the ratio. Dump it in windows\system32 or wherever your current xvidcore.dll resides (probably good idea to back it up first).

EDIT: use www.web2ftp.com if the link won't work. Works for me.

bond
1st June 2006, 13:16
i still dont understand what the problems with n-vops should be?

celtic_druid
1st June 2006, 13:21
The problem is I guess crappy SAP's that can't handle them. No problems with them here. Still maybe I can work something in so that they get disabled with the HT profiles.

bond
1st June 2006, 13:25
The problem is I guess crappy SAP's that can't handle them. No problems with them here. Still maybe I can work something in so that they get disabled with the HT profiles.can you point to those reports saying that n-vops dont work on standalones? all i know of is that quicktime doesnt handle n-vops, but who cares about quicktime :D

SeeMoreDigital
1st June 2006, 13:25
Hi Squid...

Unfortunately neither of those links work for me :(

celtic_druid
1st June 2006, 14:08
Well the solution for quicktime would be for apple to fix it rather than screwing with XviD. Same for standalones I guess.

Apparently N-VOP's cause audio desync on DVP642/37's. Other ESS based players to I guess.

Basically I did the same thing. So it should work the same. MSVC6 compile though so it should be slower than my usual builds.
http://celticdruid.no-ip.com/test/xvidcore.n-vop.7z

dukey
1st June 2006, 14:53
n-vops definitely don't work on my yamada player (it is quite old). It just skips over them completely leaving the audio behind the picture.

SeeMoreDigital
1st June 2006, 15:03
n-vops definitely don't work on my yamada player (it is quite old). It just skips over them completely leaving the audio behind the picture.Which model number?

If it's say the Yamada PDiX-770, DVX-6000 or the DVX-6100 they are all fitted ESS chip-sets ;)

SeeMoreDigital
1st June 2006, 15:24
...Basically I did the same thing. So it should work the same. MSVC6 compile though so it should be slower than my usual builds.
http://celticdruid.no-ip.com/test/xvidcore.n-vop.7zThat seems to have nailed it.......

Now when I use the following SP settings: -
Frame Drop Ratio = 0
Maximum I-Frame Interval = 250
Motion Search Precision = 6 - Ultra High
Target Bitrate = 100Kbps

MPEG4 Modifier reports: -
I-VOPs: 6 (0.40%)
P-VOPs: 1494 (99.60%)
B-VOPs: 0 (0.00%)
S-VOPs: 0 (0.00%)
N-VOPs: 0 (0.00%) And I obtain a file that runs at 106Kbps.

Nice one ;)

celtic_druid
1st June 2006, 15:35
Think I will leave it as <= though and instead remove the sanity check and then force -1 for HT profiles. Also I guess modify the VfW GUI so it accepts -1. Hell then you could even produce SP streams for QuickTime.

SeeMoreDigital
1st June 2006, 15:57
Think I will leave it as <= though and instead remove the sanity check and then force -1 for HT profiles. Also I guess modify the VfW GUI so it accepts -1. Hell then you could even produce SP streams for QuickTime.Sounds like a plan ;)

And thanks for taking the time to look into all this you guys :D

dukey
1st June 2006, 16:43
DVX-6100
whatever chipset that uses

SeeMoreDigital
1st June 2006, 17:16
DVX-6100
whatever chipset that usesLike I said above.... It contains an ESS chip-set :rolleyes:

Groucho2004
1st June 2006, 21:38
Basically I did the same thing. So it should work the same. MSVC6 compile though so it should be slower than my usual builds.
http://celticdruid.no-ip.com/test/xvidcore.n-vop.7z

Could you please post the line(s) in the code you changed?

Thanks in advance.

celtic_druid
1st June 2006, 22:25
As per squid_80's instructions, all I did was change "<=" to "<" in from recollection encoder.c.

BigDid
1st June 2006, 23:12
Like I said above.... It contains an ESS chip-set :rolleyes:
ESS chip-set strikes again:devil:

SMD, If you want (and give me a link for) I can try your N-VOP thingie with my MTK 1389 but I guess Celtic's may have tested already :rolleyes:

Did

SeeMoreDigital
2nd June 2006, 09:15
ESS chip-set strikes again:devil:

SMD, If you want (and give me a link for) I can try your N-VOP thingie with my MTK 1389 but I guess Celtic's may have tested already :rolleyes: Thanks for the offer Did.... As it happens though I already have a MTK 1389xx chip-set based player (Pioneer DV-575A) and several Sigma chip-set based players.

Up until recently I also had access to a Philips DVP630 (via one of my neighbours) but the player has since died....


Cheers

squid_80
2nd June 2006, 09:41
Think I will leave it as <= though and instead remove the sanity check and then force -1 for HT profiles. Also I guess modify the VfW GUI so it accepts -1. Hell then you could even produce SP streams for QuickTime.
You know, it's probably not actually necessary to mod the vfw to accept negative values - just remove the sanity check from xvidcore and enter a value >= 2^31 for the frame drop ratio. ;) We could call it the craptime hack. (craptime = quicktime of course)

Also while you've got encoder.c open you might want to add this little bit:

if (current->sStat.kblks + current->sStat.mblks <=
(pParam->frame_drop_ratio * mb_width * mb_height) / 100 &&
( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) &&
(current->coding_type == P_VOP) )

Just to ensure S-VOPs never get dropped, because it doesn't look too good when that happens. Should probably be posted to the dev mailing list but I'm just too darn lazy...