[Ffmpeg-devel] [RFC] X11 device demuxer

Luca Abeni lucabe72
Thu Nov 16 15:36:55 CET 2006


Hi Edouard,

On Tue, 2006-11-14 at 20:43 +0000, Edouard Gomez wrote:
[...]
> diff -r 246a0ffe5bef -r 1ef5eaa16613 libavformat/x11grab.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/libavformat/x11grab.c	Tue Nov 14 21:38:29 2006 +0100
> @@ -0,0 +1,527 @@
> +/*
> + * X11 video grab interface
> + * Copyright (C) 2006 Clemens Fruhwirth
> + *
> + * A quick note on licensing. This file is a mixture of LGPL code
> + * (ffmpeg) and GPL code (xvidcap). The result is a file that must
> + * abid both licenses. As they are compatible and GPL is more
> + * strict, this code has an "effective" GPL license.
[...]
Can you ask the xvidcap authors for the permission to reuse this part of
their code under the LGPL license (of course, if you are ok with LGPL)?
Maybe they will agree...
 
[...]
> +	st = av_new_stream(s1, 0);
> +	if (!st) {
> +		return -ENOMEM;
> +	}
> +	av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */
I think this should be 64, not 48. grab.c used to generate 48bit
timestamps, but we changed it to 64bit some time ago.
If you use 48, I think you will not be able to synchronize this video
with audio captured from OSS...

[...]
> +static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
> +{
> +	X11Grab *s = s1->priv_data;
> +	Display *dpy = s->dpy;
> +	XImage *image = s->image;
> +	int x_off = s->x_off;
> +	int y_off = s->y_off;
> +
> +	int64_t curtime, delay;
> +	struct timespec ts;
> +  
> +	/* Calculate the time of the next frame */
> +	s->time_frame += int64_t_C(1000000);
> +  
> +	/* wait based on the frame rate */
> +	for(;;) {
> +		curtime = av_gettime();
> +		delay = s->time_frame  * s->frame_rate_base / s->frame_rate - curtime;
> +		if (delay <= 0) {
> +			if (delay < int64_t_C(-1000000) * s->frame_rate_base / s->frame_rate) {
> +				s->time_frame += int64_t_C(1000000);
> +			}
> +			break;
> +		}    
> +		ts.tv_sec = delay / 1000000;
> +		ts.tv_nsec = (delay % 1000000) * 1000;
> +		nanosleep(&ts, NULL);
> +	}
My experience with this code in grab.c is that it is very fragile... It
risks to end up with a lot of skipped frames. Is it working ok for
capturing from x11?
Of course, if you are capturing video without synchronizing it with any
audio you will not see problems...


			Thanks,
				Luca
-- 
_____________________________________________________________________________
Copy this in your signature, if you think it is important:
                               N O    W A R ! ! !





More information about the ffmpeg-devel mailing list