aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPanagiotis Issaris <takis.issaris@uhasselt.be>2006-12-15 13:19:03 +0000
committerPanagiotis Issaris <takis.issaris@uhasselt.be>2006-12-15 13:19:03 +0000
commit0cd4faf977f034c603cb2d5c6bb84e728ed3fab3 (patch)
tree0d676723a197632613feba08cefec29cfa114a08
parent162b98359823e7f508da00f96106da89d642571c (diff)
downloadffmpeg-0cd4faf977f034c603cb2d5c6bb84e728ed3fab3.tar.gz
Allow provision of displaynumber, screennumber, x-offset and y-offset parameters
to the x11grab device. Originally committed as revision 7320 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--doc/ffmpeg-doc.texi7
-rw-r--r--libavformat/x11grab.c27
2 files changed, 27 insertions, 7 deletions
diff --git a/doc/ffmpeg-doc.texi b/doc/ffmpeg-doc.texi
index d9d30ee7f4..470cfe3c10 100644
--- a/doc/ffmpeg-doc.texi
+++ b/doc/ffmpeg-doc.texi
@@ -50,6 +50,13 @@ ffmpeg -f x11grab -vd x11:0.0 /tmp/out.mpg
0.0 is display.screen number of your X11 server, same as
the DISPLAY environment variable.
+@example
+ffmpeg -f x11grab -vd x11:0.0+10,20 /tmp/out.mpg
+@end example
+
+0.0 is display.screen number of your X11 server, same as the DISPLAY environment
+variable. 10 is the x-offset and 20 the y-offset for the grabbing.
+
@section Video and Audio file format conversion
* FFmpeg can use any supported file format and protocol as input:
diff --git a/libavformat/x11grab.c b/libavformat/x11grab.c
index 4b237f6c26..48ef3d7256 100644
--- a/libavformat/x11grab.c
+++ b/libavformat/x11grab.c
@@ -94,20 +94,33 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int x_off = 0;
int y_off = 0;
int use_shm;
+ char *param, *offset;
- dpy = XOpenDisplay(NULL);
- if(!dpy) {
- av_free(st);
+ if (!ap->device) {
+ av_log(s1, AV_LOG_ERROR, "AVParameters don't specify any device. Use -vd.\n");
return AVERROR_IO;
}
- if (!ap->device) {
- av_log(s1, AV_LOG_ERROR, "AVParameters don't specify any device. Use -vd.\n");
+ param = strchr(ap->device, ':');
+ if (!param) {
+ av_free(st);
return AVERROR_IO;
}
- sscanf(ap->device, "x11:%d,%d", &x_off, &y_off);
- av_log(s1, AV_LOG_INFO, "device: %s -> x: %d y: %d width: %d height: %d\n", ap->device, x_off, y_off, ap->width, ap->height);
+ param = av_strdup(param);
+ offset = strchr(param, '+');
+ if (offset) {
+ sscanf(offset, "%d,%d", &x_off, &y_off);
+ *offset= 0;
+ }
+
+ av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", ap->device, param, x_off, y_off, ap->width, ap->height);
+
+ dpy = XOpenDisplay(param);
+ if(!dpy) {
+ av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
+ return AVERROR_IO;
+ }
if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "AVParameters don't have any video size. Use -s.\n");