Author Topic: Bit rate investigation  (Read 77771 times)

Chucho

  • Developer
  • Freshman
  • *****
  • Posts: 86
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #150 on: August 30, 2012, 08:37:18 PM »
Is there a way to load in a RAW file off SDCARD into RAM, pass this through the encoder at various compression settings, then measure the resulting difference between these clips with the MSU tool? This would give a repeatable starting point.
If you look at the deleted files in your SD card you will notice a MVIxxxx.DAT file for every MVIxxxx.MOV file. The camera first writes this .DAT file before it adds the headers, tags and atoms, it then renames it to .MOV and delete the .DAT file. This code is somewhere at the end of the main firmware look for the .DAT and .MOV strings. This is the only time I've seen that the camera loads a file of the SD card for a movie fuction. I've never been able to recover the .DAT file from the SD card but it's always the same size as the .MOV file so it's after compression. I have been able to produce a MVIxxxx.DAT file by changing the values of a register C0F1xxxx something I can't remember the exact address. I'm  not sure if it's the same .DAT file as the compress .DAT. It was one of the Initialize H264 encode registers.

deleted.account.0

  • New to the forum
  • *
  • Posts: 9
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #151 on: August 30, 2012, 11:54:19 PM »
My logic is, as we can now do "low frame rate" h.264 movies, (like 1 FPS), then we don't need to work in Real Time.
So yes, we have say 25-30 YUV images on the SDCARD, then have a script to load them into VRAM, one by one.

I would imagine writing this 1 sec test .MOV may take a number of minutes to complete.

The test YUV files needn't be actual real life footage, it could be 1 sec of rendered 3D animation, with lots of detail to test the encoder performance.

Food for thought...

Chucho

  • Developer
  • Freshman
  • *****
  • Posts: 86
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #152 on: August 31, 2012, 12:25:15 AM »
I don't think you can feed YUV footage to the Canon encoder, as I understand it it goes like this,
JPEG path -> H264 encoder (NAL units, ect) MVIxxxx.DAT -> MOV wrapper (headers, tags, atoms) MVIxxxx.MOV.
You have to rewrite a lot of tasks just for a simple test.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #153 on: August 31, 2012, 12:41:14 AM »
I dunno... looking at all this, do you think the bottleneck is at the encoder or the jpeg data being fed to it? We can record ridiculously high BR and yet visible quality is only a little different.

deleted.account.0

  • New to the forum
  • *
  • Posts: 9
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #154 on: August 31, 2012, 01:43:57 AM »
Perhaps the JPEG compressor needs to be adjusted before we'll see improved quality further down the chain...?

How about bypassing the middle man altogether & writing MJPEG .MOV files direct to SD Card? (like the older Canon Powershots used to do).
At low compression ratios, 3:1, the JPEG encoder still gives very good results, supports 4:2:2 colour space and is easier to edit - not to mention bypassing the double compression.

Uncompressed 8-bit YUV 1920x1080@25 FPS is around 103 MB/sec, MJPEG at 7:1 would give about 15MB/sec or 120 mbit/sec.

Leon

  • Freshman
  • **
  • Posts: 73
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #155 on: August 31, 2012, 01:59:25 AM »
4:2:2 video would certainly be nice!

What about getting silent picture video to work properly?  Those .422 files would presumably make a good video?  The main problem when I tried it months ago was that the .422 files often are a mixture of frames (eg top third is one frame, bottom two thirds the next), and there isn't audio.  Perhaps they could somehow be dumped into a .MOV (or any other file), along with audio, even if you had to use a special program on the PC afterwards to convert it into something useable...

I'd also be interested in a 550D-compatible build.  Perhaps with sharpness -1 added in too?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #156 on: August 31, 2012, 02:14:17 AM »
Better still... dump buffer that is fed to the JPeg encoder and bypass all of this. Its major work though, more than I know how to do. Although since we can hijack functions now its technically possible.

Quote
Uncompressed 8-bit YUV 1920x1080@25 FPS is around 103 MB/sec, MJPEG at 7:1 would give about 15MB/sec or 120 mbit/s

2nd one my card could definitely do... but there is no MJPEG codec, it would have to be made from scratch.

Quote
'd also be interested in a 550D-compatible build.

Before that happens need the stubs used for some of the functions in bitrate.c... I only have 600D firmware. I'd also need addresses for where to jump the invalid gop error. 550D also a bit weaker on processing power and no 64bit file size so no files over 4gb. 600D seems like a transition camera to t4i/5dIII.


Quote
JPEG path

Nanomad tried using different paths on T3, can the path be switched so compressor is getting larger files than 1920x1080? I know it can resize because of zoom mode, etc. With less frames in the buffer I think it can handle bigger ones. Canon was really stuck on that long gop encoding.

ass5001

  • New to the forum
  • *
  • Posts: 9
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #157 on: August 31, 2012, 03:36:59 AM »
Sandisk Extreme Pro 95MB/s
yes it's the best choice for 2x.

deleted.account.0

  • New to the forum
  • *
  • Posts: 9
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #158 on: August 31, 2012, 05:22:03 AM »
Better still... dump buffer that is fed to the JPeg encoder and bypass all of this. Its major work though, more than I know how to do. Although since we can hijack functions now its technically possible.

2nd one my card could definitely do... but there is no MJPEG codec, it would have to be made from scratch.

How about just a series of Jpeg images written to SDCard? (avoiding the need to create an MJPEG codec from scratch)
Perhaps a new Folder is created for each "Record", it's a simple matter to convert image sequences to .MOV files - plus would also get around the 4GB file size limit of FAT on older camera's.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #159 on: August 31, 2012, 06:37:30 AM »
Or raw stream of what comes out before its converted into H.264. The dat file is just the uncontainerized H264 stream.

Audionut

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3657
  • Blunt and to the point
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #160 on: August 31, 2012, 06:53:39 AM »
Bypassing the jpeg engine and all it's processing would be the way to go.

I don't see how it would be possible to capture the raw data.  You would never be able to record the data fast enough.

Chucho

  • Developer
  • Freshman
  • *****
  • Posts: 86
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #161 on: August 31, 2012, 07:16:47 AM »
In a earlier post I wrote about a register that dumped a MVIxxxx.DAT file. I found the register again it's C0F113C4 it's a Boolean register. Start recording after a couple of seconds, 10 or 20 change the the 1 value and it dumps a MVIxxxx.DAT to the memory card. I opened the .DAT file in a hex editor and searched for SPS 0x0000000167, PPS 0x0000000168, I-frames 0x0000000165 and P-frames 0x0000000161, I didn't find any.

Chucho

  • Developer
  • Freshman
  • *****
  • Posts: 86
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #162 on: August 31, 2012, 08:30:30 AM »
Or maybe it just stop recording before it deletes the DAT file from the card

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3169
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #163 on: August 31, 2012, 09:37:23 AM »
hmm 1%, you uploaded a MVI_2369.MOV, remember?
it has one I every 4 frames, QP is about 10
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: paypal@g3gg0.de
ONLY donate for things we have done, not for things you expect!

deleted.account

  • Member
  • ***
  • Posts: 154
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #164 on: August 31, 2012, 02:32:15 PM »
I'm not a dev but interested in the flow path and state of the data at entry into the h264 encoder.

Is the .422 data (silent pics) considered the state of the feed for the h264 encoder? I've never bothered with them are they really compressed or just subsampled to 4:2:2?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #165 on: August 31, 2012, 05:21:07 PM »
Does QP ever go above ~10? I've been looking and it seems to go lower but not higher.

Quote
I opened the .DAT file in a hex editor and searched for SPS 0x0000000167, PPS 0x0000000168, I-frames 0x0000000165 and P-frames 0x0000000161, I didn't find any.

The one time I got a dat file was when camera crashed while recording and it didn't get deleted. I could still play it in VLC it was just a raw TS file. I think it happened when we first went over the 4GB.

ilguercio

  • Hero Member
  • *****
  • Posts: 845
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #166 on: August 31, 2012, 05:25:45 PM »
Let me get this straight, none of the things tried so far delivered a better image quality?
Canon EOS 6D, 60D, 50D.
Sigma 70-200 EX OS HSM, Sigma 70-200 Apo EX HSM, Samyang 14 2.8, Samyang 35 1.4, Samyang 85 1.4.
Proud supporter of Magic Lantern.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #167 on: August 31, 2012, 05:54:20 PM »
Better than what you'd get without it. But its not enough. You can compress the same input as nicely as possible but you still have the same input.

I cap out at ~250-260Mbps with the static... qp slice is still -10. I'll try to up it, I think its at 0x6ce0 right by deblocking filter. It goes like 0 to 1xx (at -16 qscale). We'll see what happens.

Chucho

  • Developer
  • Freshman
  • *****
  • Posts: 86
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #168 on: August 31, 2012, 06:08:16 PM »
Does QP ever go above ~10? I've been looking and it seems to go lower but not higher.

The one time I got a dat file was when camera crashed while recording and it didn't get deleted. I could still play it in VLC it was just a raw TS file. I think it happened when we first went over the 4GB.

TS like in MPEG2 file? I'm going to try to run a DAT file in a MPEG-2 analyser to see if I can get any information.

ilguercio

  • Hero Member
  • *****
  • Posts: 845
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #169 on: August 31, 2012, 06:20:35 PM »
I'm sticking with CBR 1.0x as mov files are already huge and i don't want to burden my old laptop with excess weight of my files.
It looks like the solution isn't so easy and it's a shame given the fact that we could have so much better footage from our cameras.
Thanks for the effort, by the way :)
Canon EOS 6D, 60D, 50D.
Sigma 70-200 EX OS HSM, Sigma 70-200 Apo EX HSM, Samyang 14 2.8, Samyang 35 1.4, Samyang 85 1.4.
Proud supporter of Magic Lantern.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #170 on: August 31, 2012, 07:20:15 PM »
Quote
TS like in MPEG2 file? I'm going to try to run a DAT file in a MPEG-2 analyser to see if I can get any information.

No like transport stream... mpeg2 ts is different, h.264 ts (or is it es?) is different. It is raw h.264 without the . mov container.

Quote
I'm sticking with CBR 1.0x

CBR 1.0x is actually compressing your footage. There is a difference between 40 and ~90 MBps. You give up too soon, as we're starting to figure out the encoder. That CBR just modifies the data rate parameters, you're actually getting Q+ (which i seen as high as Q+24) values to maintain. Watch what it does.

I recorded static @ 5000 iso and it fails right away at q-16... requests BR over 250. Need to find a way to keep quantizer but hard cap bit rate so it doesn't overrun hw buffer in encoder. We also haven't even started to try to increase frame size.

I recorded a few videos with QP parameter modified... there is crashing and all that but I got a few that overran the buffer right away and hopefully have increased qp slice values.

*Update...

I was having trouble so I set qscale to -17 and slice QP goes down to expected values and MVR records. I had to disable all assertions but I'm sure I can find the place where its checked and just NOP it.

ilguercio

  • Hero Member
  • *****
  • Posts: 845
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #171 on: August 31, 2012, 08:44:15 PM »
So what should i do then, use 2.7x (it's my maximum setting with my 50D) for some reason?
Canon EOS 6D, 60D, 50D.
Sigma 70-200 EX OS HSM, Sigma 70-200 Apo EX HSM, Samyang 14 2.8, Samyang 35 1.4, Samyang 85 1.4.
Proud supporter of Magic Lantern.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #172 on: August 31, 2012, 09:10:46 PM »
2x or setting qscale to something - is probably good.

Set slice to fixed value. CBR function can change qscale but it no longer alters the slice (0x6ce0) while recording. Not sure if its showing up in the files yet.

Leon

  • Freshman
  • **
  • Posts: 73
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #173 on: September 01, 2012, 01:08:37 AM »
Are the .422 files uncompressed 4:2:2 YUV (which is 16 bits per pixel, I think)?  It's just that they should be 4.15MB each if that's the case...

Uncompressed 8-bit YUV 1920x1080@25 FPS is around 103 MB/sec, MJPEG at 7:1 would give about 15MB/sec or 120 mbit/sec.

For 4:2:0 chroma subsampling, there are 12 bits per pixel.  That would give a bitrate of 1920*1080*25*12 = 622 Mbps, or 78 MB/s.

JPEG compression ratios are based on size before chroma subsampling, so for 15MB/s you'd need a compression ratio of 10:1, which would be quite feasible, and of course much less compression could be used.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Bit rate investigation - altering ratio between P and I frame sizes
« Reply #174 on: September 01, 2012, 04:36:06 AM »
Need to take a silent pic and check.

Here are today's results:

600D Slice locked to max(qp=10)/min(qp=2)? for CBR

https://bitbucket.org/OtherOnePercent/tragic-lantern/downloads/AE_SliceMin.bin

https://bitbucket.org/OtherOnePercent/tragic-lantern/downloads/AE_SliceMax.bin

*Set slice from menu, VBR fixed, sound with audio off and high bitrate. Deblocking filter works for ALL frames:

https://bitbucket.org/OtherOnePercent/tragic-lantern/downloads/autoexec.bin.600D.Fixes