int streamer_run_done_rq;
+int
+timespec_subtract (struct timespec *result,
+ struct timespec *x,
+ struct timespec *y)
+{
+ /* Perform the carry for the later subtraction by updating Y. */
+ if (x->tv_nsec < y->tv_nsec) {
+ int num_sec = (y->tv_nsec - x->tv_nsec) / 1000000000 + 1;
+ y->tv_nsec -= 1000000000 * num_sec;
+ y->tv_sec += num_sec;
+ }
+ if (x->tv_nsec - y->tv_nsec > 1000000000) {
+ int num_sec = (x->tv_nsec - y->tv_nsec) / 1000000000;
+ y->tv_nsec += 1000000000 * num_sec;
+ y->tv_sec -= num_sec;
+ }
+
+ /* Compute the time remaining to wait.
+ `tv_nsec' is certainly positive. */
+ result->tv_sec = x->tv_sec - y->tv_sec;
+ result->tv_nsec = x->tv_nsec - y->tv_nsec;
+
+ /* Return 1 if result is negative. */
+ return x->tv_sec < y->tv_sec;
+}
+
+
void* streamer_run(void* args)
{
int done;
-
+ int frame = 0;
+ int fps_avg = 0;
+ struct timespec start, end, d;
+ clock_gettime(CLOCK_MONOTONIC, &start);
done = 0;
while (!(done = streamer_run_done_rq)) {
AVPacket *pkt;
opkt = pkt_encode(os, f);
if (opkt) {
pkt_send(os, opkt);
- printf("opkt size: %d\n", opkt->size);
+
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ timespec_subtract(&d, &end, &start);
+ int fps_now = (1000<<8)/(d.tv_sec*1000+d.tv_nsec/1000000);
+ start = end;
+ fps_avg += (fps_now - fps_avg) >> 3;
+
+ printf("%5d: %d fps opkt size: %d\n",
+ frame,
+ fps_avg>>8,
+ opkt->size);
+ frame++;// = (frame + 1) % fps;
}
}
//rt_job_end();
os->streams[0]->codec->width = s->streams[0]->codec->width;
os->streams[0]->codec->height = s->streams[0]->codec->height;
os->streams[0]->codec->time_base = s->streams[0]->codec->time_base;
- os->streams[0]->codec->bit_rate = 300000;
+ os->streams[0]->codec->bit_rate = 1000000;
codec_connect(s->streams[0]->codec, os->streams[0]->codec);
out_codec_open(os);
dump_format(os, 0, os->filename, 1);