Log in

View Full Version : I wrote a stats reader... need beta testing :D


Movie Maniac®
4th April 2003, 22:48
Hi guys
to all of you!

This is my first public post in this forum (and Nitrogen now this!!!), and I hope I haven't choosen the wrong place to do it.

I wrote a little .stats viewer (and many thanks go to Nitrogen who gave me some precious informations), and I need a little bug testing now.

The app is very simple and essential, but consider that I don't need any more. It's part of a bigger project (my main app wich is called MMAAT), and for some functions I want to implement, I needed to parse stats file and eventually write in it.

So, in the attachement you'll find my tool. Please feel free to report any bug or suggestion, but keep in mind what I said.

Thanks a lot. ;)

Movie Maniac®
4th April 2003, 22:52
I can't understand why, but I can't see the attachement.
What's wrong?

I browsed my hard disk and then choosen the file, which was a zip archive, not bigger than 21KB. So what's up?

Thanks

oddyseus
4th April 2003, 23:03
wait. It has to be approved first by a moderator. Sometimes it takes time.

Movie Maniac®
4th April 2003, 23:10
Damn

I've deleted it by editing the message.

Ok, it's been a very ugly first time. :(

Can somebody tell me when may I retry to upload it?

Thanx for your patience!
:(

Movie Maniac®
4th April 2003, 23:36
Well
I try again to post my little tool.

Please forget my bad mistakes :D

Hope to have your help ;)

Bye

P.S. I didn't knew that the attachement had to be approved, please forgive me!

EDIT: Removed old attachment see below for new version - DaveEL

NiTroGen
5th April 2003, 17:35
The keyframe's quantizer is shown wrong. You must ignore bit 31 of the nnstats.quant variable. Use something like this: Quantizer = (nnstats.quant And &hff) to get only the first 8 bits of the variable. By the way, in the first pass ALL quantizers are fixed at the value of 2, so you can easily use Quantizer = 2, without anyone noticing it. ;)

Movie Maniac®
6th April 2003, 01:59
Originally posted by NiTroGen
The keyframe's quantizer is shown wrong. You must ignore bit 31 of the nnstats.quant variable. Use something like this: Quantizer = (nnstats.quant And &hff) to get only the first 8 bits of the variable. By the way, in the first pass ALL quantizers are fixed at the value of 2, so you can easily use Quantizer = 2, without anyone noticing it. ;)

Ok
I've corrected this, but now all frames have quantizer=2 so it's impossible to make a distinction between I P and B frames using the quant.

I was using this piece of code when loading the file, and I think it's somewhat correct since it gave correct results:

If newRecord.quant = -2147483646 Then
KFrames = KFrames + 1
ElseIf BFrame And newRecord.dd_v = 1073741824 Then
BFrames = BFrames + 1
Else
PFrames = PFrames + 1
End If

where newrecord is the record (68 bytes), and BFrame is a function that returns wether the frame is B or not (you gave it to me, but seems that all frames are B and P, maybe I missed something).

However now the quant should be displayed correctly, and this ain't made with tricks, ;) hehehe.

So I compiled this new buld, wich is still beta (and remember it's parto of another project, not a real app!!!). I've added a textbox where I display all the details of each record, and I let the quant as displayed in the old version to let understand how frame distinction is made.

but Now I'e tried (and now means Now, at 2.54 am local time - Italy - ) another piece of code, and seems I was inspired since I finally got it working:


If (newRecord.quant And &H80000000) = &H80000000 Then
KFrames = KFrames + 1
ElseIf (newRecord.quant And &H40000000) = 0 And Not (newRecord.dd_v And &H40000000) = &H40000000 Then
PFrames = PFrames + 1
ElseIf (newRecord.quant And &H40000000) = 0 And (newRecord.dd_v And &H40000000) = &H40000000 Then
BFrames = BFrames + 1
End If


Is it correct?
I can't understand why this one works, while the functions you suggested to me don't work whit my way of reading the file (I don't load it to the memory).

In the attachement you can find my file.

Any beta tester is wellcom!!

Sorry for the longest post ever!!! :D

Movie Maniac®
8th April 2003, 00:04
So?

Any opinion?

I've deleted the old version since I've found some little bigs.

I'll be soon back with a new release. Please let me know your opinions. I mean, did you find any problems using it?

Thanks

Movie Maniac®
8th April 2003, 10:31
Ok

Here's a new version, wich is closer to the initial idea I had when I started writing my tool. Now infos are more detailed, and a little graph is shown. I've added the "autoload" function, and I'm planning to add a function to see all Xvid settings as used during last compression.

PLease test it and let me know ;)

P.S.
I'm still looking for help on credits frames.

Movie Maniac®
12th April 2003, 12:47
Ok, no more help on credits frames is needed (thanx Nitrogen).

But I still need to know betatesting results, if anyone have done some test :D

Thanks

P.S. I'm thinking to improve the "insert keyframe function", giving the possibiity to choose wether the size should be:
1) the same as the original frame's
2) the same as the maximum I-frame
3) the same as the average I-Frame
4) a custom size

What do you think about this? Please, your opinion is requested :D

Movie Maniac®
17th June 2003, 22:52
Some more troubles.

I've finished (I suppose) my stats viewer editor, and I've realized a function wich should insert a keyframe wherever I may need.

I've done it to solve OGM chapters synch; I mean to insert keyframes where chapters begin.

Now I'm experiencing some troubles, since the Keyframes are inserted correclty, but Xvid doesn't want to consider them :'( Neither if I use the modified .stats file, nor if I do the linear scaling with my stats editor and then do the 2nd pass ext.

I use this piece of code to insert KF (first of all I create a backup copy of the stats file, then I check if the frame is already a KF, if not I insert a KF)


nFrames = (FileLen(FileDialog.sFile) - 4) / 68
If CDbl(ListView1.ListItems.Item(ListView1.ListItems.count).SubItems(2)) < ((FileLen(file) - 4) / 68) Then
If Right(Path, 1) <> "\" Then
Path = Path & "\"
End If
ret = CopyFile(file, Path + "StatsReader_" + Trim(Text5.Text) + ".bak", ByVal 0&)
Open file For Binary Access Read Write As StatsFile
For j = 0 To ListView1.ListItems.count - 1
Set itmX1 = ListView1.ListItems.Item(j + 1)
'setframe=cbdl(itmx1.
Seek StatsFile, 5 + 68 * Abs(itmX1.SubItems(2) - 1)
Get StatsFile, , newRecord
reclen = Len(newRecord)
If newRecord.quant = -2147483646 Then
Else
tblock = newRecord.kblk + newRecord.mblk + newRecord.ublk
newRecord.quant = -2147483646
newRecord.kblk = tblok
newRecord.mblk = 0
newRecord.ublk = 0
newRecord.dd_v = 0
Seek StatsFile, 5 + 68 * Abs(itmX1.SubItems(2) - 1)
Put StatsFile, , newRecord
End If
Next j
Close #StatsFile
MsgBox LoadResString(871 + lingua), vbInformation
Else
MsgBox LoadResString(752 + lingua) & vbCrLf & LoadResString(753 + lingua) & vbCrLf & LoadResString(754 + lingua), vbCritical
End If


To do the linear scaling I use this piece of code:


Public Sub cmdSave_Click()
Dim targSize As Double
Dim compRatio As Double
Dim minSize As Double
Dim Overflow_1 As Double
Dim Overflow_2 As Double
Dim scaleCorr As Long
Dim Skip As Long
Dim redux As Double

targSize = CDbl(Text1(27).Text)
compRatio = targSize / CDbl(Text1(8).Text)
redux = Round(CDbl(Text1(8).Text) / targSize, 3)
minSize = CDbl(Text1(26).Text)

Dim sSave As SelectedFile
Dim filePath As String
Dim filename As String
On Error GoTo Err:
'seleziona ed apre il file per l'output tesatuale
'(se il file esiste le informazioni vengono scritte in append)
newStatsFile = FreeFile

FileDialog.sFilter = "Files di testo (*.stats)" & Chr$(0) & "*.stats" & Chr$(0) ' & "tutti i Files (*.*)" & Chr$(0) & "*.*"
FileDialog.sInitDir = VB.App.Path
FileDialog.sDlgTitle = "Salva"
sSave = ShowSave(Me.hwnd)

If FileDialog.nFilterIndex = 1 Then
FileDialog.sDefFileExt = ".stats"
End If
filePath = Left(FileDialog.sFile, FileDialog.nFileOffset)
filename = Replace(Replace(FileDialog.sFileTitle, " ", "", , , vbTextCompare), vbNullChar, "", , , vbTextCompare)

Open filePath & filename & ".stats" For Binary Access Write As newStatsFile 'APRO IL NUOVO FILE STATS
StatsFile = FreeFile
Open Text1(0).Text For Binary Access Read As StatsFile 'APRO IL FILE STATS


Dim version As Long
Seek StatsFile, 1
Get StatsFile, , version
Put newStatsFile, , version

nFrames = CDbl(Text1(3))
ProgressBar1.max = nFrames
For i = 0 To nFrames - 1
Seek StatsFile, 5 + 68 * i
Get StatsFile, , newRecord
If newRecord.FrameSize > minSize Then
newRecord.FrameSize = newRecord.FrameSize * compRatio
If newRecord.FrameSize < minSize Then
Overflow_2 = Overflow_2 + (minSize - newRecord.FrameSize)
newRecord.FrameSize = minSize
scaleCorr = scaleCorr + 1
End If
Else
Overflow_1 = Overflow_1 + (minSize - newRecord.FrameSize * compRatio)
Skip = Skip + 1
End If
Put newStatsFile, , newRecord
ProgressBar1.value = i + 1
DoEvents
Next i

Close newStatsFile
Close StatsFile

MsgBox LoadResString(856 + lingua) & Text1(0) & LoadResString(857 + lingua) & Text1(27) & vbCrLf & LoadResString(858 + lingua) & Round((compRatio * 100), 3) & "% (" & redux & ":1)" & vbCrLf & "- " & Skip & LoadResString(859 + lingua) & Round(Overflow_1, 0) & LoadResString(860 + lingua) & vbCrLf & "- " & scaleCorr & LoadResString(861 + lingua) & Round(Overflow_2, 0) & LoadResString(862 + lingua), vbInformation, LoadResString(863 + lingua)
Err:
Exit Sub
End Sub


You can download my stats editor from here http://www.moviemaniac.altervista.org/Xvid.rar (cop and paste this address into IE, otherwise it won't work due to antileech), unfortunately I can't send you my chapter's editor becouse it's included in a larger software. The method I use to insert KF is the same, so you should try with this. If you want to take a look to the chapters editor, you can download my software directly from this link
MMAATools (http://www.moviemaniac.altervista.org/modules.php?op=modload&name=UpDownload&file=index&req=getit&lid=84)

Thanks in advance for your support ;)

Koepi
18th June 2003, 20:51
whua, VB :-/

Just a reminder: keyframe insertation only works with xvid stable (like my last stable build) or if you set "max bframes" to -1 in xvid unstable - else in 2nd pass the dynamic ipb-decision will override any frame-type given by the statsfile. (which is the reason why sometimes the bitrate curve isn't apropiate in xvid.)

I'll help working on that for dev-api-4 as soon as i find the time to switch over.

Another question: i deliver statsreader with my builds which can do extactly this. was it too big? Or why do we need bloated VB? ;) SCNR - evil me.

Regards
Koepi

Movie Maniac®
18th June 2003, 21:29
Originally posted by Koepi
whua, VB :-/

Just a reminder: keyframe insertation only works with xvid stable (like my last stable build) or if you set "max bframes" to -1 in xvid unstable - else in 2nd pass the dynamic ipb-decision will override any frame-type given by the statsfile. (which is the reason why sometimes the bitrate curve isn't apropiate in xvid.)

I use your build, published on 4/10/2002 becouse I think it grants the best quality :D

Originally posted by Koepi I'll help working on that for dev-api-4 as soon as i find the time to switch over.

Another question: i deliver statsreader with my builds which can do extactly this. was it too big? Or why do we need bloated VB? ;) SCNR - evil me.

Regards
Koepi

Let me explain...
When you want to do an OGM with chapters, you must have a KF where the chapter starts. When the movie has 20 or 30 chapters, it's a little bit long to insertt KF one by one. So you can load the chapters list into my app and then insert all KF by simply clicking on "synch" button :D

That's all :D
but the problem remains, why the second pass doesn't take into consideration the stats file for frame type?

Regards

zulu
20th June 2003, 08:35
but the problem remains, why the second pass doesn't take into consideration the stats file for frame type?

As koepi mentioned above, either use the latest stable build or disable bframes (and thus dynamic frame decision).

BTW:
Did you ever have a look at this (http://forum.doom9.org/showthread.php?s=&threadid=39687) thread?

Movie Maniac®
20th June 2003, 08:57
Originally posted by zulu
As koepi mentioned above, either use the latest stable build or disable bframes (and thus dynamic frame decision).

BTW:
Did you ever have a look at this (http://forum.doom9.org/showthread.php?s=&threadid=39687) thread?

but koepi's last stable is the one published on 4/10/2002, or is there another stable version that I don't know?
On koepi's site i can see only 04/10/2002, and it doesn't support Bframes. So, just to make things clearer, can you please tell me exactly wich build should I try and where to download it?

Another thing, is it correct my way of inserting KF?
I mean this piece of code:

tblock = newRecord.kblk + newRecord.mblk + newRecord.ublk
newRecord.quant = -2147483646
newRecord.kblk = tblock
newRecord.mblk = 0
newRecord.ublk = 0
newRecord.dd_v = 0

Thanks a lot

P.S. concerning this post, I admit that I've never seen it before :'(
however I would be very happy if someone could help me.

zulu
20th June 2003, 09:23
Yes, the build on koepis site is the latest stable binary and you're right,it doesn't support bframes (and thats the very reason it'll work with forced keyframes). The unstable binarys ignore the statsfile's frametypes and choose frametypes dynamically. You can avoid this behaviour by disabling bframes (-1).

If you want i can give you the relevant code snippet of my kf insertion tool (don't have it on my fingertips right now), unfortunately it's written in C, but maybe it is of help to you.

regards,
zulu

Movie Maniac®
20th June 2003, 09:26
Originally posted by zulu
If you want i can give you the relevant code snippet of my kf insertion tool (don't have it on my fingertips right now), unfortunately it's written in C, but maybe it is of help to you.

regards,
zulu

Thanks for your support, I'd really like to have your piece of code.
But please take a look at mine, am I making any mistakes?
I mean is it correct to put keyblocks equal to the sum of k,m,ublocks and the other block types to zero? and putting to zero dd_v too? In this (http://forum.doom9.org/showthread.php?s=&threadid=34125&highlight=xvid+stats+file) post I found that dd_v is ignored by the codec, so shouldn't matter whether it is zero or not. But looking at other frames info, I see that dd_v is not zero, so may be this? (I hope Koepi is reading me...)

Anyhow
I'll stay tuned for your help ;)

regards

Koepi
20th June 2003, 09:51
The "correct" way to insert a keyframe is this:

#define NNSTATS_KEYFRAME (1<<31)

void CStatsReaderDlg::OnAddkeyframe()
{
// m_stats[m_keyframe].bytes *= 1.5;
m_stats[m_keyframe].drf |= NNSTATS_KEYFRAME;
m_stats[m_keyframe].kblk = m_stats[0].kblk;
m_stats[m_keyframe].mblk = 0;
m_stats[m_keyframe].ublk = 0;
// m_stats[m_keyframe-1].dd_v = 0;
m_stats[m_keyframe].dd_v = 0;
// m_stats[m_keyframe+1].dd_v = 0;
}


Explanation:

The first frame _has_ to be a keyframe, thus it has all blocks coded intra (kblk).

The lines starting with "//" are commented out s they are useless with current unstable builds, but for stable they're correct.

Increasing the bitrate for the "wrong decided" keyframe should help the bitrate distribution routines not to get nuts.
in dd_v the bframe-flag is stored, so this is correct as well: no bframe before or after a keyframe.

I hope this helps.

regards
Koepi

zulu
20th June 2003, 09:57
ok, this is what my code looks like (i believe koepi does it the same way)

#define NNSTATS_KEYFRAME (1<<31)

stats[n].quant |= NNSTATS_KEYFRAME;
stats[n].kblk = stats[0].kblk; /* --- keyblocks are set to keyblocks of stats 1st frame (1st frame is allways intra...) */
stats[n].mblk = 0; /* --- motion blocks */
stats[n].ublk = 0; /* --- unchanged blocks */
stats[n].dd_v = 0;

stats[] is an array containing all stat frames.
The line
stats[n].quant |= NNSTATS_KEYFRAME;
can be reproduced in vb this way:
stats[n].quant = stats[n].quant OR &80000000h

hope this helps,
zulu

EDIT: ups, koepi was a little bit faster :)

Movie Maniac®
20th June 2003, 10:56
Const IFrameBit As Long = &H80000000
tblock = newRecord.kblk + newRecord.mblk + newRecord.ublk
newRecord.quant = (newRecord.quant Or IFrameBit)
newRecord.kblk = tblock
newRecord.mblk = 0
newRecord.ublk = 0
newRecord.dd_v = 0
Seek StatsFile, 5 + 68 * Abs(itmX1.SubItems(2) - 1)
Put StatsFile, , newRecord

newrecord is the current record I'm reading and I must convert to KF.
IFrameBit is the equivalent of NNSTATS_KEYFRAME.
tblock is the total amount of blocks, I will change it so that it takes block amount onli once by reading the first frame in the stats file.
itmX1.SubItems(2) is the coloumn of the listview where chapters are displayed, so I take the frame number and subtract 1 (abs is for the first frame, wich in smartrippers info file is always 0). I seek again the file till currentrecord, then I put everything in the stats file.

Comparing this code with yours, it should work... but nothing to do. KF just get ignored...

I could even send to you or make available for download the stats file modified by me (compressed to rar it's only 807KB) so that you can check if I'm doing right or wrong.

P.S. zulu I've tried your KFenforcer, but it doesn't work like mine. So I'm starting to think that this option couldn't be used with koepi's 10/04/2002 build... is it possible?

Movie Maniac®
20th June 2003, 11:31
Increasing the bitrate for the "wrong decided" keyframe should help the bitrate distribution routines not to get nuts.

So you say it's better to increase the bitrate of the inserted KF? ok I'll manage to do this.


in dd_v the bframe-flag is stored, so this is correct as well: no bframe before or after a keyframe.

I'm noticing that in this stats file no frame has dd_v equal to zero. Even the first frame, which has this stats:
Frame size = 3101
dd_v = 2824
Quant = -2147483646
kblk = 1000

Lets' consider a KF inserted by the codec (during the first pass), the frame number 103. Frame number 102, wich is a P-Frame (remember the build I'm using) has these stats:

Frame size = 27236
dd_v = 1573
Quant = 2
kblk = 0
mblk = 1000
ublk = 0

Frame number 104 (P-Frame) has these:

Frame size = 27677
dd_v = 1978
Quant = 2
kblk = 0
mblk = 1000
ublk = 0

So none of the two has dd_v set to zero, but the codecs consider frame 103 (Frame size = 64241; dd_v = 3556; Quant = -2147483646; kblk = 1000; mblk = 0; ublk = 0) as KF :'(

I'm going slightly mad :D

regards
Koepi [/B]

regards
Movie Maniac®

zulu
20th June 2003, 12:19
Why do you expect dd_v to be zero? dd_v has a b-frame flag stored in bit 30, so if this _bit_ is zero it's not a bframe, not if the whole _value_ is zero.

Looking at your code i don't understand why i you seek after you modified a stats frame.
It should work like this:
1. seek to the frame to be modified
2. read the frame
3. bitwise OR the quant field and alter kblk, mblk, ublk, dd_v
4. write the frame back into the statsfile

Try to load the modified statsfile into koepis statsviewer (ships with xvid) and check if the keyframes were inserted correctly.

Movie Maniac®
20th June 2003, 12:46
Ok
concerning the dd_v there was a misunderstanding. Now I've understood everything.

For what concerns my way of seeking, consider this.
Probably you load the whole file into memory in a unique vector, and then you access every record of the file simply calling vector[position] is it true?

I use a different method.
I seek the file and read the record I need, then I calculate totalblocks, then i prepare the variables (bitwise OR the quant field and alter kblk, mblk, ublk, dd_v
)
then i reseek the file and store the modified record.

I know it's a little bit slow, I'll speed up the code asap.

However did you read about your KFenforcer? It doesn't work on my computer and with Koepi 4 october 2002 release.

regards
Movie Maniac®

zulu
20th June 2003, 12:57
Ah, ok you seek and read before you process the stats frame. This wasn't clear from the peace of code you posted.

My tool doesn't work for you? IMPOSSIBLE! :D

Seriously, how do you know it doesn't work? I mean what do you do to test if it works? Do you check the statsfile in statsreader? Do you observe the encoded video with inserted keyframes in virtualdub?

Movie Maniac®
20th June 2003, 14:11
Well let me explain what I've done:

1) I opened the first pass stats file with your KFenforcer
2) I importet the chapters list from the smartripper INFO file
3) I clicked on the "Start" button
4) Once it finished, I opened my avisynth script with virtualdubmod, 5) I set compression on fast recompress
6) I set Xvid Koepi 10/04/2002 to make the second pass Intra
7) as we discussed above, no B-frame (the codec doen't support them)
8) save as avi

I encoded about 2500 frames, becouse the first inserted keyframe is at 1963 (your enforcer inserted it at 1965, but doesn't matter at all).
Then I opened the file with both VirtualdubMod 1.5.1.1a and Virtualdub 1.5.4, but neither frame 1963 non 1965 are KF. The nearest KF are n°1956 and 2056 wich are KF also in the first pass stats file (and decided by the codec).

So am I wrong? or maybe this release of xvid doen't support KF insertion?

Regards

zulu
20th June 2003, 14:33
hmmm...this is strange.
This xvid version should respect inserted keyframes.
Are you really sure you didn't miss anything (like replacing the original statsfile with the modified one)?
If nothing helps, try an unstable build with bframes set to -1 to narrow down the reason of the problem.

P.S:
My tool inserts keyframes delayed by one frame to circumvent a bug in the ogm dsf. But 2 frames of is too much, please count again (frames start at 0).

Movie Maniac®
20th June 2003, 14:54
Originally posted by zulu
hmmm...this is strange.
This xvid version should respect inserted keyframes.
Are you really sure you didn't miss anything (like replacing the original statsfile with the modified one)?
If nothing helps, try an unstable build with bframes set to -1 to narrow down the reason of the problem.

I'm sure becouse I don't have a backup copy. If you want I can pass you the stats file so you can check it out on your own.

I'll try anothere release asap.

Originally posted by zulu
P.S:
My tool inserts keyframes delayed by one frame to circumvent a bug in the ogm dsf. But 2 frames of is too much, please count again (frames start at 0).

Let me submit another question, that you brought to my mind. Suppose I want to see frame's number 1963 stats, then I should seek the stats file this way
Seek StatsFile, 5 + 68 * (1963 - 1)
Is it correct?
Anyhow I've checked out each frame insertion made by your app and by mine, both with Nitrogen's stats editor and with my stats viewer, and it seems that all your KF where inserted delayed by 2.
While Koepi's stats reader says that mine are inserted a frame before and yours a frame after, but as I once sayd to Koepi in a pm, his stats reader seems to be tuned one frame ahead (I mean it reads frame 999 but it displays it like 1000).
This are my impressions!

Best Regards

zulu
20th June 2003, 15:08
sorry, i've no more time today.
i'll have a look at things tomorrow.

Movie Maniac®
21st June 2003, 00:03
Originally posted by zulu
sorry, i've no more time today.
i'll have a look at things tomorrow.

Ok
thanks for your support :D

zulu
21st June 2003, 13:10
Regarding our frame offset difference: What is your formular to calculate frame positions from timestamps (e.g. 00:34:23.200)?
I believe my frame offsets are correct since i tested them many times, checked them in vdub and compared them against the frame offsets of smartripper files.

Did you try an unstable release?
If you managed to convince xvid to respect inserted frames, please check the offsets of the inserted frame in virtualdub, too. Frames inserted by kfenforcer should be exactly one frame delayed.

Movie Maniac®
21st June 2003, 19:07
Let me explain:

I'm not saying that your app is wrong and mine is right.
If you read carefully, I've sayd that by using my app and nitrogen's, my frames are inserted at the same frame that is listed into the chapter's list, while yours are delayed by two.
If I use koepi's stats reader instead, mine seems to be inserted a frame before, while yours seems delayed by one.
If I look at the result of the compression whith virtualdub, neither mine nor your KF appear :'(
So this lead me to think that the koepi's release I'm using doesn't support this feature.

When I insert KF I don't use any formula, since I use the frame number reported in SmartRipper's Info file. So i don't have timestamps, but only frame numbers... (I hope my english is good enough to make things clear!).

Did you try an unstable release?
If you managed to convince xvid to respect inserted frames, please check the offsets of the inserted frame in virtualdub, too. Frames inserted by kfenforcer should be exactly one frame delayed.

Since our last conversation I haven't rebooted my machine :D so I couldn't installa nother xvid release :(
I will try an official Xvid release, maybe 0.91 since your app supports it, then I'll let you know.

Regards
Movie Maniac®

P.S. where can I find an official Xvid release (0.91) compiled? On the original site I can see only source code...

Koepi
21st June 2003, 19:20
Can you check if it works when you insert a keyframe with statsreader?
It worked for me but you never know.

That may help to track down the issue.

reards
Koepi

zulu
21st June 2003, 19:22
I will try an official Xvid release, maybe 0.91 since your app supports it, then I'll let you know.

Please try the latest unstable one with bframes set to -1.
There is no official build of the 0.9.1 release.
Once you've got it working, please use vdub to check if frames have been inserted correctly.

Movie Maniac®
21st June 2003, 19:25
Ok
I couldn't stand that situation, so I installed this release, taken from Nic's site http://nic.dnsalias.com/XviD_Install.exe
and tryed to compress the movie.
then I looked into it with vdubmod and...
tataaaaaaaaaaaaaaa
my frame is inserted one frame before and your is delayed by one.

So that's the situation:
1) your app works fine with stable builds later then 0.91
2) my app works with stable builds later then 0.91, but frames are inserted one before... so seems I must set up my routines.

One last question. You sayd that you insert frames dfelayed by one to avoid a bug. May you tell me about this bug? I mean, I don't know about it, so can you explain me what's the matter or post some links where I can read something?

Do you think that anticipating the KF by one is a good idea as yours of delaying it by one?

regards
Movie Maniac®

Movie Maniac®
21st June 2003, 19:27
Originally posted by Koepi
Can you check if it works when you insert a keyframe with statsreader?
It worked for me but you never know.
That may help to track down the issue.


I'll try, but as you can read, Seems everything work with newer releases.
While nothing works with your stable build published on 04 october 2002. :(

Anyhow, I'll try and let you know :)

Bye

Movie Maniac®
21st June 2003, 19:29
Originally posted by zulu
Please try the latest unstable one with bframes set to -1.
There is no official build of the 0.9.1 release.
Once you've got it working, please use vdub to check if frames have been inserted correctly.

I've tryed a stable release as I sayd.
i'll try latest unstables by Koepi, nics and umaniac asap.

Til then thanks for all your support.

My girlfriend is gonna kill me... gotta go, sorry :D
Regards
Movie Maniac®

zulu
21st June 2003, 20:09
First, another issue comes to my mind:
if you don't calculate the framepositions from the corresponding timestamps and don't take the framerate of the encoded movie into account, you'll run into problems if framerate_of_source_movie != frame_rate_of_encoded_movie.

You mux a timestamp list into the ogm file and the corresponding frame offsets are calculated on playback, depending on the framerate.
So the source_movie_framerate_chapter_frame you forced will be at the wrong posistion if the framerate differs from the framerate of the source movie.
(Damn, i wished i could explain this better..)



One last question. You sayd that you insert frames dfelayed by one to avoid a bug. May you tell me about this bug? I mean, I don't know about it, so can you explain me what's the matter or post some links where I can read something?

Do you think that anticipating the KF by one is a good idea as yours of delaying it by one?


Try it yourself: OGGDSF won't find the keyframe if it isn't delayed by one.
EDIT: There are no links that i know of, the only post i know is the one i made in my kfe thread :D

EDIT2: Another note:
the first chapter 00:00:00.000 -> frame 0 does't need to be forced, frame 0 is always intra. Also skip other frames which are already intra.


regards,
zulu

Movie Maniac®
1st July 2003, 17:35
Originally posted by zulu
First, another issue comes to my mind:
if you don't calculate the framepositions from the corresponding timestamps and don't take the framerate of the encoded movie into account, you'll run into problems if framerate_of_source_movie != frame_rate_of_encoded_movie.

Well, I took the chapter list from Smartripper Info file, and I insert KF considering the frame nuber and not the time stamp, so the frame rate doesn't matter. More, in this way, I can check out and circunvent Smartripper's errors during the creation of the chapter list (and this errors are very common).

Try it yourself: OGGDSF won't find the keyframe if it isn't delayed by one.
EDIT: There are no links that i know of, the only post i know is the one i made in my kfe thread :D

Ok, i've modified my code so that it now insert KF delayed by one.

EDIT2: Another note:
the first chapter 00:00:00.000 -> frame 0 does't need to be forced, frame 0 is always intra. Also skip other frames which are already intra.

I already do this. I check whether a frame is a KF or not, and then insert the KF if needed.

Please, would you like to test my app?
If so, you can download it from the link below. It's the full tool collection. In the "edit" menu you can find the chapters editor and the stats viewer. You can use the chapters editor to load SmartRipper info file, and then the synch function to synchronize your stats file whit the chapters list.

Download MMAAT 3.5.67 (http://www.moviemaniac.altervista.org/modules.php?op=modload&name=UpDownload&file=index&req=getit&lid=84)

For Koepi
there's something that I still can't understand about reading stats files. I mean, the number of frames is filelenght-4/68
then i can read the nth frame by seeking the file until position 5+68*n is it right? But, in this way, frames seems to be (filelenght-4/68)+1, since we must consider frame 0. Can you make things clearer?


And if I want to read all frames, is this loop correct?

nFrames = filelenght-4/68

For i = 0 To nFrames
Seek StatsFile, 5 + 68 * i
Get StatsFile, , newRecord
'read all the infos about the frame
Next i


Thanks and regards

Koepi
2nd July 2003, 17:03
C/C++ start counting with 0.

Maybe VB starts with 1?

Sounds like an off-by-one error which is quite usual due to this behaviour.

Regards
Koepi

Movie Maniac®
2nd July 2003, 17:11
Originally posted by Koepi
C/C++ start counting with 0.

Maybe VB starts with 1?

No no
it starts with 0 too. That's why I posted that question about frame number.

Suppose that (filelen-4)/68 = 10

when I do the loop, it starts from 0 aand it ends at 10, so it seems that frames are 11 and not 10. This thing is the main misunderstanding, and it lead me to a great waste of time... ended up this week, thanks to your help and to zulo help too.

And, at the moment, it's the only question still unsolved to me :'(

regards
Movie Maniac®

zulu
3rd July 2003, 09:09
Well, I took the chapter list from Smartripper Info file, and I insert KF considering the frame nuber and not the time stamp, so the frame rate doesn't matter. More, in this way, I can check out and circunvent Smartripper's errors during the creation of the chapter list (and this errors are very common).


Please consider the following:

source movie:
framerate pal 25fps


chapter 00:04:27.040 ->

(int)( ( ( (hours (00) * 3600)
+ (minutes (04) * 60)
+ seconds (27)
+ (milliseconds (040)/1000.0) )
* fps (25) ) + 0.5);

= frame 6676



encoded movie:
framerate changed to (23.976 (e.g. by applying IVTC)


chapter 00:04:27.040 ->

(int)( ( ( (hours (00) * 3600)
+ (minutes (04) * 60)
+ seconds (27)
+ (milliseconds (040)/1000.0) )
* fps (23.976) ) + 0.5);

= frame 6403

So you can't expect chapterframe 6676 from your source video to be at 00:04:27.040 in your encoded video.
If you encode using a different framerate, e.g. 23.967, frame 6403 corresponds to time 00:04:27.040.
I hope i made it clearer this time.

regards,
zulu

Movie Maniac®
3rd July 2003, 09:28
I understand what you say, but when smartrippers writes in its Info file:


****************
* Chapter Info *
****************

Chap#=Frame#
Chapter1=0
Chapter2=5901
Chapter3=8889

it considers just frames. So frame number 5901 would be the same in a 25 fps movie as in a 23.97 fps movie. isn't it?
I was meant to say this in my last post.
I take frame position and not time stamp from smartripper... this should be independent from frame rate... i hope :)
Or does not smartripper take into consideration movie's framerate?

thanks a lot
regards
Movie Maniac®

P.S. can someone send me some smartripper info file taken from a 23,97 fps movie and from some 29.997 fps movie? so that I can check it out by myself... thanks

zulu
3rd July 2003, 12:29
it considers just frames. So frame number 5901 would be the same in a 25 fps movie as in a 23.97 fps movie. isn't it?
I was meant to say this in my last post.


You don't want the same frame of the original movie,
you want the same _chaptertime_ which is printed in the booklet or where ever.
The 25fps version and the 30fps version of a movie would have the same chaptertimes,
but since they have different framerates, these chaptertimes correspond to different frames.

...



Imagine the following situation:
The original movie has a chapter at 00:04:27.040 which means frame# 6676 if the framertate is 25fps.
Now you take this frame# and force it to be a keyframe in your encoded video which has a different framerate.
Fine, now frame 6676 is a keyframe.
Then you mux in your chapterlist, among others timestamp 00:04:27.040.
Finally, you watch your movie and in OggDSF you'd like to seek to 00:04:27.040.
But "suprisingly" OggDSF seeks to frame 6403 and not to the forced I-Frame 6676,
because this target frame is calculated from timestamp 00:04:27.040 and the respective framerate (reminder: the framerate differs from the original movies framerate)!

Bottom line:
If your encoded movie's framerate differs from the original movie's framerate, then muxed chapterlist timestamps (e.g. 00:04:27.040)
correspond to different frames.

Sorry, i'm afraid i couldn't make it any clearer.

regards,
zulu

Movie Maniac®
3rd July 2003, 18:00
mmm...

begin from the beginning...

When smartripper extracts the info from IFO files, it saves chapters INFO in different ways. It saves timestamps and frame number.
It saves frame number independently from any fps. I mean, it read frame number x, if it's the beginning pf a chapter, thenm it saves the value. Isn't it?

So if the movie is 25 fps, the time stamp will be at x/25 sec, if it's 30 fps the time stamp will be at x/30 sec. isn't it?

So the same should be with stats files.
I mean, I'm not inserting a customized chapter's list, but only the smartripper saved one, so I think I can consider only frame position.

Your explanation is valid if I want to insert my own chapters list. In this case I should take into consideration timestamps, though if the user insert directly framenumber (calculted on timestamp basis, taking into consideration the fps) there should be no problems.

Feel like we're sayin' almost the same thing but we're running on parallel's line... maybe this is due to my english sorry.

I can assure I've completely understood what you are saying, and I hope you understand me too...
I'm not going to offer the possibility to create a customized chapter's list as your KFe does...

Regards
Movie Maniac®

Movie Maniac®
5th July 2003, 19:06
I've tested Koepi unstable release XviD-24062003-1.exe with forced key Frames and it works fine.

I've not checked how it works with B-frames yet (and I haven't done it nor with Nic stable).

I'll let you know asap.

Bye