[Theora] encoder settings

Karol Bryd karolbe at gmail.com
Wed Sep 7 07:55:30 PDT 2005


Hi!

Some background: I am trying to create an application that would
encode video taken by USB camera using Theora and then send it
to the client. I have almost succeeded, but I have one problem.

When I grab  video frames from the camera and encode them they
form 4KB  OGG pages, then I send them over TCP/IP to the client
application.  Since I want to achieve as small latency as possible I don't
want to buffer the stream and here is the problem...

Right now the encoder works with following settings:

    bitrate = 80
    video_r = 80;
    videostream->ti.width = video_x;
    videostream->ti.height = video_y;
    videostream->ti.frame_width = frame_x;
    videostream->ti.frame_height = frame_y;
    videostream->ti.offset_x = frame_x_offset;
    videostream->ti.offset_y = frame_y_offset;
    videostream->ti.fps_numerator =   refreshrate * 1000000;
    videostream->ti.fps_denominator = 10 * 100000;
    videostream->ti.aspect_numerator = 0;
    videostream->ti.aspect_denominator = 0;
    videostream->ti.colorspace = OC_CS_UNSPECIFIED;
    videostream->ti.target_bitrate = video_r;
    videostream->ti.quality = 1;

    videostream->ti.dropframes_p = 0;
    videostream->ti.quick_p = 1;
    videostream->ti.keyframe_auto_p = 1;
    videostream->ti.keyframe_frequency = 16;
    videostream->ti.keyframe_frequency_force = 16;
    videostream->ti.keyframe_data_target_bitrate = (unsigned int)
(video_r * 1.5);
    videostream->ti.keyframe_auto_threshold = 80;
    videostream->ti.keyframe_mindistance = 8;
    videostream->ti.noise_sensitivity = 1;

and this, as I wrote above, creates 4KB packets, take a look at the below
timings which show how many seconds it takes to encode one video page
and send over TCP/IP (localhost):

1.452 sec. read 4243 bytes
2.429 sec. read 4151 bytes
3.33 sec. read 4299 bytes
4.476 sec. read 4224 bytes
5.889 sec. read 4362 bytes
6.849 sec. read 4211 bytes
7.858 sec. read 4305 bytes
8.767 sec. read 4337 bytes
10.216 sec. read 4153 bytes
11.488 sec. read 4352 bytes

I'm not sure why but this makes the playback not very smooth. I have one
"reference" Theora stream (http://stream.fluendo.com:8810) and this one
works just fine, the player displays it without any delays etc. Here is the
timing for this stream:

0.0 sec. read 1448 bytes
0.022 sec. read 1448 bytes
0.07 sec. read 1448 bytes
0.183 sec. read 1448 bytes
0.206 sec. read 1448 bytes
0.209 sec. read 1448 bytes
0.222 sec. read 1448 bytes
0.239 sec. read 1448 bytes
0.249 sec. read 1448 bytes
0.328 sec. read 1448 bytes
0.341 sec. read 1448 bytes

The difference is obvious, but how they (Fluendo) did this? Is this related
to the TCP/IP server or to Theora settings?  I think that the latter option is
more probable, so the question is: how do I configure Theora stream to
achieve similiar results?

Thanks in advance
Karol
-- 
Fotografia przyrodnicza i nie tylko
http://www.karolbryd.art.pl

"Jakże często szczęście bywa zaprzepaszczone przez zbyt długie
przygotowania - głupie przygotowania!" - J. Austin


More information about the Theora mailing list