Changes between Version 14 and Version 15 of Capture/Desktop


Ignore:
Timestamp:
Apr 7, 2015, 1:57:32 AM (4 years ago)
Author:
llogan
Comment:

make x11grab examples completely copy and pasteable for trac #4436

Legend:

Unmodified
Added
Removed
Modified
  • Capture/Desktop

    v14 v15  
    11== Linux == 
    22 
    3 Use the '''[http://ffmpeg.org/ffmpeg-devices.html#x11grab x11grab]''' device: 
     3Use the [https://ffmpeg.org/ffmpeg-devices.html#x11grab x11grab] device: 
    44{{{ 
    5 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.flv 
     5ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4 
    66}}} 
    77 
    88This will grab the image from desktop, starting with the upper-left corner at (x=100, y=200) with the width and height of 1024x768. 
    99 
    10 If you need audio too, you can use '''[http://ffmpeg.org/ffmpeg-devices.html#alsa-1 alsa]''' like this: 
     10If you need audio too you can use [https://ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA] (see [[Capture/ALSA]] for more info): 
    1111{{{ 
    12 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i pulse output.flv 
     12ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i hw:0 output.mkv 
    1313}}} 
     14 
     15Or the [https://ffmpeg.org/ffmpeg-devices.html#pulse pulse] input device: 
     16{{{ 
     17ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f pulse -ac 2 -i default output.mkv 
     18}}} 
     19 
    1420 
    1521== OS X == 
    1622 
    17 Use the '''[http://ffmpeg.org/ffmpeg-devices.html#avfoundation avfoundation]''' device: 
     23Use the [https://ffmpeg.org/ffmpeg-devices.html#avfoundation avfoundation] device: 
    1824{{{ 
    1925ffmpeg -f avfoundation -list_devices true -i "" 
     
    2228This will enumerate all the available input devices including screens ready to be captured. 
    2329 
    24 (Did not work for me; only webcam gets enumerated, desktop/audio devices do not.  Any other prerequisites?  -Vultaire) 
    25  
    2630Once you've figured out the device index corresponding to the screen to be captured use: 
    2731{{{ 
    28 ffmpeg -f avfoundation -i "<screen device index>:<audio device index>" out.avi 
     32ffmpeg -f avfoundation -i "<screen device index>:<audio device index>" out.mov 
    2933}}} 
    3034 
    31 This will capture the screen from <screen device index> and audio from <audio device index> into the output file out.avi. 
     35This will capture the screen from `<screen device index>` and audio from `<audio device index>` into the output file `out.mov`. 
    3236 
    3337== Windows == 
    3438 
    35 Use a '''[http://ffmpeg.org/ffmpeg-devices.html#dshow dshow]''' [https://github.com/rdp/screen-capture-recorder-to-video-windows-free device]: 
     39Use a [http://ffmpeg.org/ffmpeg-devices.html#dshow dshow] [https://github.com/rdp/screen-capture-recorder-to-video-windows-free device]: 
    3640{{{ 
    3741ffmpeg -f dshow -i video="screen-capture-recorder" output.flv 
    3842}}} 
    3943 
    40 This will grab the image from entire desktop.  [http://betterlogic.com/roger/2010/07/list-of-available-directshow-screen-capture-filters/ Here] is a list of alternative devices to use as well:  
     44This will grab the image from entire desktop. You can refer to a [http://betterlogic.com/roger/2010/07/list-of-available-directshow-screen-capture-filters/ list of alternative devices]. 
    4145 
    42 If you need audio too, you can use this: 
     46If you need audio too: 
    4347{{{ 
    4448ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone" output.flv 
    4549}}} 
    46 If you want to capture the audio that is playing from your speakers, 
    47 you may also need to configure so-called "Stereo Mix" device. 
     50If you want to capture the audio that is playing from your speakers you may also need to configure so-called "Stereo Mix" device. 
    4851 
    4952or 
     
    5861}}} 
    5962 
    60 There is also a "gdigrab" you can use to grab from the screen in windows (video) 
     63There is also the [https://ffmpeg.org/ffmpeg-devices.html#gdigrab gdigrab] input device you can use to grab video from the screen in Windows. 
    6164 
    62 === Example recipe: live screen capture to webm === 
    63  
    64 Here's a recipe used by one user for doing a live full-screen 1920x1080 screen capture to WebM format (VP8/vorbis).  Note that you may need to tweak the -cpu-used or -b:v parameters depending on how fast your system is. 
    65  
    66 {{{ 
    67 SET "audio_device=<audio_device>" 
    68 SET "video_device=<video_device>" 
    69 SET "threads=<physical cores minus 1>" 
    70 ffmpeg -f dshow -i audio="%audio_device%":video="%video_device%" -c:v libvpx -b:v 2M -deadline realtime -cpu-used -5 -threads %threads% -c:a libvorbis -y output.webm 
    71 }}} 
    72  
    73 It seems that the audio and video might not be perfectly in sync, but this should be a good starting point and may be "good enough" for some. 
    74  
    75 References: 
    76 * wiki:Encode/VP8 
    77 * http://stackoverflow.com/a/20673805 (the above is based on this SO) 
    78  
    79 == General note == 
     65== General notes == 
    8066 
    8167If you have a slow computer, it will not be smart to grab and encode your video at the same time, because slow CPU will not be able to do this. In that case, first grab all you need and save it as uncompressed video/audio and when you finish the grabbing process then start converting it to whatever you need: 
     
    8369Linux: 
    8470{{{ 
    85 ffmpeg -framerate 25 -video_size 1024x768 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.flv 
    86 ffmpeg -i output.flv -acodec ... -vcodec ... final.flv 
     71ffmpeg -framerate 25 -video_size 1024x768 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv 
     72ffmpeg -i output.mkv -acodec ... -vcodec ... final.mkv 
    8773}}} 
    8874 
    8975Windows: 
    9076{{{ 
    91 ffmpeg -f dshow -i video="screen-capture-recorder":audio="Microphone" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.flv 
    92 ffmpeg -i output.flv -acodec ... -vcodec ... final.flv 
     77ffmpeg -f dshow -i video="screen-capture-recorder":audio="Microphone" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv 
     78ffmpeg -i output.flv -acodec ... -vcodec ... final.mkv 
    9379}}} 
    9480 
     
    9884 
    9985{{{ 
    100 ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast -profile:v high444 capture.mkv 
     86ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast capture.mkv 
    10187}}} 
    10288 
    103 The high444 profile is used to ensure a lossless RGB to YUV transformation. Otherwise, the capture will not be lossless, and text will look blurry. {{{-qp 0}}} tells x264 to encode in lossless mode, {{{-preset ultrafast}}} advises it to do so fast. 
     89{{{-qp 0}}} tells x264 to encode in lossless mode, {{{-preset ultrafast}}} advises it to do so fast. 
    10490 
    10591The encoder should be fast enough on most modern hardware to record without any framedrop, and even leave enough CPU headroom for other applications. 
    106  
    107 If most of your screen will be static, it may be useful to use the {{{-tune stillimage}}} parameter, i.e.: 
    108  
    109 {{{ 
    110 ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -tune stillimage -preset ultrafast -profile:v high444 capture.mkv 
    111 }}} 
    11292 
    11393If you're going to archive the recording or are concerned about file size, re-encode it losslessly again but with a slower preset. Note that since the initial recording was lossless, and the re-encode is lossless too, no quality loss is introduced in this process in any way. 
    11494 
    11595{{{ 
    116 ffmpeg -i capture.mkv -c:v libx264 -qp 0 -tune stillimage -preset veryslow -profile:v high444 capture_smaller.mkv 
     96ffmpeg -i capture.mkv -c:v libx264 -qp 0 -preset veryslow capture_smaller.mkv 
    11797}}} 
     98 
     99See [[Encode/H.264]] for more info and examples.