[FFmpeg-devel] [PATCH] lavd/x11grab: add an option to disable MIT-SHM.

Nicolas George george at nsup.org
Tue Jul 15 11:40:16 CEST 2014


With remote displays supporting the MIT-SHM extension,
the extension is detected and used, but attaching fails
asynchronously.

Signed-off-by: Nicolas George <george at nsup.org>
---
 doc/indevs.texi       | 4 ++++
 libavdevice/x11grab.c | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)


It would probably be better to catch the XShmAttach() error, but that
requires more work. Maybe later.


diff --git a/doc/indevs.texi b/doc/indevs.texi
index 4205808..4ca12ff 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -895,6 +895,10 @@ ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 25 -video_siz
 
 @item video_size
 Set the video frame size. Default value is @code{vga}.
+
+ at item use_shm
+Use the MIT-SHM extension for shared memory. Default value is @code{1}.
+It may be necessary to disable it for remote displays.
 @end table
 
 @c man end INPUT DEVICES
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index d38c55d..eb67799 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -166,7 +166,7 @@ x11grab_read_header(AVFormatContext *s1)
     int x_off = 0;
     int y_off = 0;
     int screen;
-    int use_shm;
+    int use_shm = 0;
     char *dpyname, *offset;
     int ret = 0;
     Colormap color_map;
@@ -223,8 +223,10 @@ x11grab_read_header(AVFormatContext *s1)
         av_log(s1, AV_LOG_INFO, "followmouse is enabled, resetting grabbing region to x: %d y: %d\n", x_off, y_off);
     }
 
+    if (x11grab->use_shm) {
     use_shm = XShmQueryExtension(dpy);
     av_log(s1, AV_LOG_INFO, "shared memory extension%s found\n", use_shm ? "" : " not");
+    }
 
     if(use_shm) {
         int scr = XDefaultScreen(dpy);
@@ -625,6 +627,7 @@ static const AVOption options[] = {
     { "framerate",  "set video frame rate",      OFFSET(framerate),   AV_OPT_TYPE_VIDEO_RATE, {.str = "ntsc"}, 0, 0, DEC },
     { "show_region", "show the grabbing region", OFFSET(show_region), AV_OPT_TYPE_INT,        {.i64 = 0}, 0, 1, DEC },
     { "video_size",  "set video frame size",     OFFSET(width),       AV_OPT_TYPE_IMAGE_SIZE, {.str = "vga"}, 0, 0, DEC },
+    { "use_shm",     "use MIT-SHM extension",    OFFSET(use_shm),     AV_OPT_TYPE_INT,        {.i64 = 1}, 0, 1, DEC },
     { NULL },
 };
 
-- 
2.0.1



More information about the ffmpeg-devel mailing list