[FFmpeg-user] unable to capture desktop session using x11grab on debian jessie with ffmpeg 3.1.4

Mark Thompson sw at jkqxz.net
Wed Nov 9 00:32:39 EET 2016


On 08/11/16 21:59, Mark Thompson wrote:
> On 08/11/16 12:17, 肖文良 wrote:
>> Built from the latest git source seems not help.
>>
>> following command runs about 15+ seconds. nothing was captured. If I add -loglevel debug,  this log keep being printed:
>>
>> cur_dts is invalid (this is harmless if it occurs once at the start per stream)
>> [rawvideo @ 0x3234840] PACKET SIZE: 4196352, STRIDE: 5464
>>
>> Here is the whole command line and output:
>>
>> ➜  ffmpeg git:(master) ✗ ./ffmpeg  -s 1366x768 -f x11grab -i :0.0 -c libx264 -crf 28 -preset ultrafast /tmp/output.mp4
>> ffmpeg version N-82294-g6f0a171 Copyright (c) 2000-2016 the FFmpeg developers
>>   built with gcc 4.9.2 (Debian 4.9.2-10)
>>   configuration: --disable-yasm --enable-x11grab --enable-gpl --enable-libx264
>>   libavutil      55. 35.100 / 55. 35.100
>>   libavcodec     57. 66.101 / 57. 66.101
>>   libavformat    57. 57.100 / 57. 57.100
>>   libavdevice    57.  2.100 / 57.  2.100
>>   libavfilter     6. 66.100 /  6. 66.100
>>   libswscale      4.  3.100 /  4.  3.100
>>   libswresample   2.  4.100 /  2.  4.100
>>   libpostproc    54.  2.100 / 54.  2.100
> 
> There is something strange going on here.
> 
> I can reproduce the problem precisely by using the ffmpeg package in debian testing, which is close to a vanilla build of 3.2:
> 
> $ /usr/bin/ffmpeg -y -f x11grab -i :0 out.mp4
> ffmpeg version 3.2-2 Copyright (c) 2000-2016 the FFmpeg developers
>   built with gcc 6.2.0 (Debian 6.2.0-10) 20161027
>   configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-libtesseract --disable-stripping --disable-decoder=libschroedinger --enable-avresample
> --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme
> --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
> --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-opengl --enable-sdl2 --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-openal
> --enable-frei0r --enable-libopencv --enable-libx264 --enable-chromaprint --enable-shared
>   libavutil      55. 34.100 / 55. 34.100
>   libavcodec     57. 64.100 / 57. 64.100
>   libavformat    57. 56.100 / 57. 56.100
>   libavdevice    57.  1.100 / 57.  1.100
>   libavfilter     6. 65.100 /  6. 65.100
>   libavresample   3.  1.  0 /  3.  1.  0
>   libswscale      4.  2.100 /  4.  2.100
>   libswresample   2.  3.100 /  2.  3.100
>   libpostproc    54.  1.100 / 54.  1.100
> 
> But I can't reproduce it at all if I build myself (either git head or the tip of the 3.2 branch).  The 3.2 here really should pretty much identical to the Debian build:
> 
> $ ./ffmpeg -y -f x11grab -i :0 out.mp4
> ffmpeg version n3.2-3-g7568b0f Copyright (c) 2000-2016 the FFmpeg developers
>   built with gcc 6.2.0 (Debian 6.2.0-10) 20161027
>   configuration: --enable-libx264 --enable-gpl --enable-x11grab
>   libavutil      55. 34.100 / 55. 34.100
>   libavcodec     57. 64.100 / 57. 64.100
>   libavformat    57. 56.100 / 57. 56.100
>   libavdevice    57.  1.100 / 57.  1.100
>   libavfilter     6. 65.100 /  6. 65.100
>   libswscale      4.  2.100 /  4.  2.100
>   libswresample   2.  3.100 /  2.  3.100
>   libpostproc    54.  1.100 / 54.  1.100
> 
> The problem with the Debian version is that the timestamps are messed up somehow - I can work around it there by giving both the -framerate and -r options:
> 
> /usr/bin/ffmpeg -y -framerate 30 -r 30 -f x11grab -i :0 out.mp4
> 
> at which point it produces the same result as the 3.2 I built myself.
> 
> So, I downloaded the source for exactly the debian version from https://packages.debian.org/stretch/ffmpeg, applied their patches and built it myself:
> 
> $ ./ffmpeg -y -f x11grab -i :0 out.mp4
> ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
>   built with gcc 6.2.0 (Debian 6.2.0-10) 20161027
>   configuration: --enable-libx264 --enable-gpl --enable-x11grab
>   libavutil      55. 34.100 / 55. 34.100
>   libavcodec     57. 64.100 / 57. 64.100
>   libavformat    57. 56.100 / 57. 56.100
>   libavdevice    57.  1.100 / 57.  1.100
>   libavfilter     6. 65.100 /  6. 65.100
>   libswscale      4.  2.100 /  4.  2.100
>   libswresample   2.  3.100 /  2.  3.100
>   libpostproc    54.  1.100 / 54.  1.100
> 
> This also works perfectly.
> 
> So, I'm left with the Debian binary being somehow broken, while mine built from supposedly the same source (with the same compiler, but not with the same options) is not?
> 
> You say that you can reproduce it with a version built from git - can you offer anything more about your setup which might be relevant to this issue?  While the Debian build does set many options, I don't see how any of them can plausibly be of relevance here.

It is libavdevice in Debian which is broken somehow, not ffmpeg itself.

If I inject the system libavdevice into my working shared version built from the same source it fails:

$ LD_LIBRARY_PATH=$(echo lib* | sed 's/ /:/g') ldd ./ffmpeg
        linux-vdso.so.1 (0x00007ffda47a3000)
        libavdevice.so.57 => libavdevice/libavdevice.so.57 (0x00007fe5b1e13000)
        libavfilter.so.6 => libavfilter/libavfilter.so.6 (0x00007fe5b19e8000)
        libavformat.so.57 => libavformat/libavformat.so.57 (0x00007fe5b15d1000)
        libavcodec.so.57 => libavcodec/libavcodec.so.57 (0x00007fe5b00a1000)
        libpostproc.so.54 => libpostproc/libpostproc.so.54 (0x00007fe5afe83000)
        libswresample.so.2 => libswresample/libswresample.so.2 (0x00007fe5afc67000)
        libswscale.so.4 => libswscale/libswscale.so.4 (0x00007fe5af9df000)
        libavutil.so.55 => libavutil/libavutil.so.55 (0x00007fe5af764000)
...

$ LD_LIBRARY_PATH=$(echo lib* | sed 's/ /:/g') ./ffmpeg -y -f x11grab -i :0 out.mp4

-> works.

$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libavdevice.so.57 LD_LIBRARY_PATH=$(echo lib* | sed 's/ /:/g') ./ffmpeg -y -f x11grab -i :0 out.mp4

-> fails.


And the other way around, if I inject my just-built libavdevice into the system ffmpeg:

$ LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ /usr/bin/ffmpeg -y -f x11grab -i :0 out.mp4

-> fails.

$ LD_PRELOAD=libavdevice/libavdevice.so.57 LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ /usr/bin/ffmpeg -y -f x11grab -i :0 out.mp4

-> works.


Still wondering what can matter in the configuration...

- Mark



More information about the ffmpeg-user mailing list