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
Hi,> 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...So what you probably want to reduce here is the delay introduced by ogg paging. Ogg collects multiple video frames' worth of data into an Ogg page, typically flushing out when the page becomes 4KB.> I'm not sure why but this makes the playback not very smooth.The reason is, because as you can see from the timing, long blocks of data for multiple video frames are collected together.> 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?I'd have to look again at what we did (it wasn't necessarily all a conscious decision, I sure didn't look at the resulting stream the way you did, thanks for that info), but IIRC we added a property to our ogg muxer that allows it to flush out a page more frequently. You should be able to do the same thing by flushing using ogg_page_flush IIRC. In your case (if you really want the frame to be sent out as quickly as possible) you could even ogg_page_flush after every video frame you submit to the theora encoder. Take into account that you are adding extra overhead to the stream in that case, but it seems warranted from what little I'm guessing about your application. Hope that helps, Thomas Dave/Dina : future TV today ! - http://www.davedina.org/ <-*- thomas (dot) apestaart (dot) org -*-> When somebody knows you well well there's no comfort like that And when somebody loves you well well there's no drug like that <-*- thomas (at) apestaart (dot) org -*-> URGent, best radio on the net - 24/7 ! - http://urgent.fm/