Announcement

Collapse
No announcement yet.

capture X11 to video

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    capture X11 to video

    so I was playing around with ffmpeg last night and reading the man page when I saw that it had a section on X11 grabbing.

    and after 2 attempts WOW I can make a vidio of my desktop 8)

    the first attempt with
    Code:
    ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/out.mpg
    only grabbed a 352x288 section of the upper left corner of the screen but some more reading got me to " -s xga " for 1024x768 (see man ffmpeg ) witch is what my display is and got the hole screen

    I then made my mother a nice little video showing some of the cool window switching effects and 3D desktop that I had been trying to describe to her ...........she was amased.

    VINNY

    i7 4core HT 8MB L3 2.9GHz
    16GB RAM
    Nvidia GTX 860M 4GB RAM 1152 cuda cores

    #2
    Re: capture X11 to video

    Next step. Add sound to make instructional videos.

    Comment


      #3
      Re: capture X11 to video

      Aaaa yes you can merge an audio with a video but I dont have a Mic to test that out with

      but that would be grate for the graygeek and all the people he supports

      VINNY
      i7 4core HT 8MB L3 2.9GHz
      16GB RAM
      Nvidia GTX 860M 4GB RAM 1152 cuda cores

      Comment


        #4
        Re: capture X11 to video

        Hey Vinnie -- thanks for this! I'm a ffmpeg noob -- I only know how to rip the audio out of downloaded youtube videos. But this is very helpful for anyone who want to show a desktop maneuver -- thank you!

        Comment


          #5
          Re: capture X11 to video

          Originally posted by dibl
          Hey Vinnie -- thanks for this! I'm a ffmpeg noob -- I only know how to rip the audio out of downloaded youtube videos. But this is very helpful for anyone who want to show a desktop maneuver -- thank you!
          Cool.....I use winff to do what your doing not the CLI and ffmpeg directly (me ffmpeg n00b as well)..... but the ffmpeg man page gives some good examples to build on for lots of cool things.

          and though a vary long man page mencoder gives some good ones to.

          VINNY

          i7 4core HT 8MB L3 2.9GHz
          16GB RAM
          Nvidia GTX 860M 4GB RAM 1152 cuda cores

          Comment


            #6
            Re: capture X11 to video

            More than anything else (on my notebook) the size of the desired video controls how many FPS I can record without distortion or sound problems. The repository app, recorditnow, has worked well for me in the past.

            Here's some of the commands I've played with, but I didn't originate any of them.

            Code:
            record_with_webcam.sh
            #!/bin/bash
            mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0:forceaudio:adevice=/dev/dsp -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o webcam.avi
            which is a script I have in my home account for recording from my webcam.

            Here are others...
            Code:
            mplayer -fps 15 tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 
            
            mencoder tv:// -tv driver=v4l2:width=60:height=40:fps=60:device=/dev/video0 -[b]nosound[/b] -ovc lavc -lavcopts vcodec=mjpeg -o test.avi
            And, I no longer remember when or from where I obtained this discussion on using ffmpeg to
            record videos in Linux, but ffmpeg seems to work well for me.

            Code:
            Capture video of a linux desktop using ffmpeg
            
            Xdpyinfo is a utility for displaying information about an X server. It is used to examine the capabilities
            of a server, the predefined values for various parameters used in communicating between clients and the server, and the different types of screens and visuals that are available. (see man xdpyinfo).
            
            We use it as follows to determine the screen resolution:
            
            xdpyinfo | grep 'dimensions:'|awk '{print $2}'
            
            FFmpeg can grab the X11 display
            
            ffmpeg -f x11grab -i :0.0 /tmp/out.mpg
            
            0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.
            
            -r will be used to set the output file to 25 fps.
            
            Now you know how to capture video of a linux desktop using ffmpeg:
            
            ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq /tmp/out.mpg
            
            ========================
            i am always having to look this up. now at least i'll have it here:
            
            ffmpeg -f x11grab -vc theora -s vga -r 24 -b 1200 -g 300 -i :0.0 ~/Videos/screenCapture1.ogv
            
            
            
            option by option:
            
            -f x11grab = take video from X...ffmpeg must have been compiled with enable-x11grab included; 
            your distro or version may or may not have this enabled!
            
            -vc = Video Codec...usually you will have ogg theora, xvid, [ff]mpeg (the default), and x264 available
            
            -s = size. see the ffmpeg man page for details; vga is something like 800x600 and there are many 
            other sizes available. know that it starts from the top left corner counts pixels from there.
            
            -r = frame rate. lower frame rate gives smaller file size but looks a little less smooth
            
            -b = bitrate. higher bitrate looks better but makes for a larger file size
            
            -g = GOP size...300 provides a pretty nice looking image without increasing file size too much; 
            it's got one intra frame every...i dunno....300/24 = 12.5 seconds or so.
            
            -i = input...in this case it's :0.0 meaning your main screen. or display. or whatever it's called.
            
            
            As you can imagine, there are a LOT more options available to you via man ffmpeg. Probably 
            the most notable would be the offset, so if you wanted the capture area to not start at the 
            very top left, you could tell it to, say, go down 10 pixels and over 10 pixels and THEN capture 
            vga-size images, or xga-size images, or whatever.
            
            ======================
            ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
            ===================
            Creating screencasts using ffmpeg
            
            While experimenting with creating demo videos for QBoard, i had to tinker quite a lot to get 
            the video capture working how i wanted it. For anyone doing screencasts (whether of QBoard 
            or not), here's a simple shell script which can simplify the process:
            
            #!/bin/bash
            # Generates an ffmpeg command line for capturing a given X11 window.
            # Usage: $0 [optional output file name]
            # It will prompt you to click on the window you want to capture.
            # Output is simply echoed, for use in copy/pasting (adjusting/adding
            # parameters as needed).
            # Tip: the command uses screen coordinates, so do not resize or move
            # the target window once capturing as begun.
            echo "Click the window to capture..."
            
            tmpfile=/tmp/screengrab.tmp.$$
            trap 'touch $tmpfile; rm -f $tmpfile' 0
            
            xwininfo > $tmpfile 2>/dev/null
            left=$(grep 'Absolute upper-left X:' $tmpfile | awk '{print $4}');
            top=$(grep 'Absolute upper-left Y:' $tmpfile | awk '{print $4}');
            width=$(grep 'Width:' $tmpfile | awk '{print $2}');
            height=$(grep 'Height:' $tmpfile | awk '{print $2}');
            geom="-geometry ${width}x${height}+${left}+${top}"
            echo "Geometry: ${geom}"
            size="${width}x${height}"
            pos="${left},${top}"
            echo "pos=$pos size=$size"
            
            out=${1-screengrab.avi}
            #test -f $out && rm $out
            
            framerate=4
            echo "# ffmpeg command"
            echo -n "sleep 2; " # give caller time to switch to captured window
            echo ffmpeg -f x11grab \
              -r ${framerate} \
              -s ${size} \
              -i ${DISPLAY-0:0}+${pos} \
              -sameq \
              $out
            
            It's used like this:
            
            stephan@jareth:/space/stephan$ ./screencap.sh
            Click the window to capture...
            Geometry:  -geometry 598x686+764+0
            pos=764,0 size=598x686
            # ffmpeg command
            sleep 2; ffmpeg -f x11grab -r 4 -s 598x686 -i :0.0+764,0 -sameq screengrab.avi
            
            The output is intended to be copy/pasted to your shell (or script, or whatever), adding 
            or adjusting parameters as necessary. The sleep call is helpful when running the command 
            from a shell, as it gives the caller time to click on the target window before ffmpeg starts 
            capturing. 
            ===================================
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Re: capture X11 to video

              A Qt gui

              > Qt-Apps.org >> qx11grab:
              Description:
              qt4 applet for recording x11 windows with ffmpeg
              Developers home > About qx11grab
              is a systray program that uses FFmpeg for recording X11 desktop windows. this program grab window dimensions with xevent and prepare the command line for ffmpeg with configuration options. it sends the generated parameter list to a new FFmpeg process. qx11grab is not the recording software it prepare all commands for FFmpeg....
              There are both the sources and the binaries available.

              apt-cache show qx11grab:
              Package: qx11grab
              Version: 0.2.1-1
              Architecture: i386
              Maintainer: Juergen Heinemann
              ...
              Homepage: http://qx11grab.hjcms.de
              Description: a systray program that uses FFmpeg for recording X11 desktop windows
              this program grab window dimensions with xevent and prepare the
              command line for ffmpeg with configuration options.
              it sends the generated parameter list to a new FFmpeg process.
              .
              qx11grab is not the recording software it prepare all commands for FFmpeg.
              [img width=388 height=400]http://img530.imageshack.us/img530/1710/grab.jpg[/img]
              Before you edit, BACKUP !

              Why there are dead links ?
              1. Thread: Please explain how to access old kubuntu forum posts
              2. Thread: Lost Information

              Comment


                #8
                Re: capture X11 to video

                Thanks Rog!


                It wasn't in the Ubuntu repository but I found it from the link you supplied. However .... it is only for the 32bit OS. Gdbi does not install it.

                EDIT:
                I dl'd the source and ran cmake. It failed because it could not find the alsa-lib library, which isn't on my system. My system has the directories
                /usr/lib/alsa-lib
                /usr/lib32/alsa-lib
                but they do not meet the cmakelist.txt "FIND_PACKAGE (ALSA REQUIRED)" requirements and I am not going to mess up my sound installing the necessary alsa requirements.



                "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                – John F. Kennedy, February 26, 1962.

                Comment


                  #9
                  Re: capture X11 to video

                  It's not in the Debian repos either -- at least not in 64-bit arch.

                  But that's good to know -- thanks Rog and GG. I did do a practice run on my 1600x1200 desktop with:

                  Code:
                  ~$ ffmpeg -f x11grab -s uxga -r 30 -i :0.0 /tmp/out.mpg
                  Worked perfectly!

                  Comment


                    #10
                    Re: capture X11 to video

                    64


                    > Personal Package Archives for Ubuntu >> PPA for Rog131 >>> Package name contains: qx11grab


                    Older:

                    qx11grab (0.1.8~karmic~ppa2) karmic

                    - qx11grab_0.1.8~karmic~ppa2_amd64.deb
                    - qx11grab_0.1.8~karmic~ppa2_i386.deb
                    - qx11grab_0.1.8~karmic~ppa2_lpia.deb


                    Latest:

                    qx11grab (0.2.3~rc1~maverick~ppa2) maverick

                    - qx11grab_0.2.3~rc1~maverick~ppa2_amd64.deb (273.9 KiB)
                    - qx11grab_0.2.3~rc1~maverick~ppa2_i386.deb (274.5 KiB)



                    More links:

                    > FAQ: Repositories
                    > Using the PPA repositories
                    Before you edit, BACKUP !

                    Why there are dead links ?
                    1. Thread: Please explain how to access old kubuntu forum posts
                    2. Thread: Lost Information

                    Comment


                      #11
                      Re: capture X11 to video

                      Originally posted by Rog131

                      ~maverick~ppa2_
                      Aha!

                      Thank you Rog!

                      Comment


                        #12
                        Re: capture X11 to video

                        Too bad, so sad ... none of those offerings work in a 64bit LL
                        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                        – John F. Kennedy, February 26, 1962.

                        Comment


                          #13
                          Re: capture X11 to video

                          Yep, it installed correctly from the Rog repo -- 64-bit -- looks good. Now I must think of a screen maneuver worth recording!

                          Comment


                            #14
                            Re: capture X11 to video

                            Hey, maybe you can use CDE to package up a copy of your gx11grabber and email it to me?
                            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                            – John F. Kennedy, February 26, 1962.

                            Comment


                              #15
                              Re: capture X11 to video

                              Lucid packages

                              The standard Lucid packages are a bit older:
                              -- checking for modules 'libavformat>=52.38.0;libavcodec>=52.35.0'
                              -- package 'libavformat>=52.38.0' not found
                              -- package 'libavcodec>=52.35.0' not found
                              CMake Error at modules/FindPkgConfig.cmake:259 (message):
                              A required package was not found
                              Adding a patch to reduce the needed libavformat version to 52.31.0 and libavcodec version to 52.20.1.

                              =>

                              -- checking for modules 'libavformat>=52.31.0;libavcodec>=52.20.1'
                              -- found libavformat, version 52.31.0
                              -- found libavcodec, version 52.20.1
                              =>

                              qx11grab_0.2.3~rc1~lucid~ppa1_amd64.deb
                              qx11grab_0.2.3~rc1~lucid~ppa1_i386.deb


                              The qx11grab (i386) seems to work without problems.
                              Before you edit, BACKUP !

                              Why there are dead links ?
                              1. Thread: Please explain how to access old kubuntu forum posts
                              2. Thread: Lost Information

                              Comment

                              Working...
                              X