Changes between Version 20 and Version 21 of Capture/Desktop


Ignore:
Timestamp:
Dec 1, 2017, 2:35:19 PM (2 weeks ago)
Author:
slhck
Comment:

restructure headings and minor changes

Legend:

Unmodified
Added
Removed
Modified
  • Capture/Desktop

    v20 v21  
    1 == Linux == 
     1{{{ 
     2#!html 
     3<h1 style="font-size: 22px;"> 
     4Capturing your Desktop / Screen Recording 
     5</h1> 
     6}}} 
     7 
     8[[PageOutline(1, Contents)]] 
     9 
     10Here are a few solutions for capturing your desktop and recording a video of your screen with ffmpeg. (A Chinese version of this page is [[Capture/Desktop中文版本|also available]].) 
     11 
     12For the sake of brevity, these commands do not specify any additional encoder settings. For more info about H.264 encoding, see [[Encode/H.264|the H.264 encoding guide]]. 
     13 
     14By default, these commands will use the x264 encoder, which should be reasonably fast on modern machines. See [#lossless-recording Lossless Recording] if you need to improve performance. 
     15 
     16= Linux = 
    217 
    318Use the [https://ffmpeg.org/ffmpeg-devices.html#x11grab x11grab] device: 
     
    621}}} 
    722 
    8 This will grab the image from desktop, starting with the upper-left corner at (x=100, y=200) with the width and height of 1024x768. 
     23This will grab the image from desktop, starting with the upper-left corner at x=100, y=200 with a width and height of 1024⨉768. 
    924 
    10 If you need audio too you can use [https://ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA] (see [[Capture/ALSA]] for more info): 
     25If you need audio too, you can use [https://ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA] (see [[Capture/ALSA]] for more info): 
    1126{{{ 
    1227ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i hw:0 output.mkv 
     
    1833}}} 
    1934 
    20  
    21 == OS X == 
     35= macOS = 
    2236 
    2337Use the [https://ffmpeg.org/ffmpeg-devices.html#avfoundation avfoundation] device: 
     
    2842This will enumerate all the available input devices including screens ready to be captured. 
    2943 
    30 Once you've figured out the device index corresponding to the screen to be captured use: 
     44Once you've figured out the device index corresponding to the screen to be captured, use: 
    3145{{{ 
    32 ffmpeg -f avfoundation -i "<screen device index>:<audio device index>" out.mov 
     46ffmpeg -f avfoundation -i "<screen device index>:<audio device index>" output.mkv 
    3347}}} 
    3448 
    35 This will capture the screen from `<screen device index>` and audio from `<audio device index>` into the output file `out.mov`. 
     49This will capture the screen from `<screen device index>` and audio from `<audio device index>` into the output file `output.mkv`. 
    3650 
    37 == Windows == 
     51= Windows = 
    3852 
    39 === Use DirectShow === 
     53== Use DirectShow == 
    4054 
    4155Use a [[DirectShow]] [https://github.com/rdp/screen-capture-recorder-to-video-windows-free device]: 
    4256{{{ 
    43 ffmpeg -f dshow -i video="screen-capture-recorder" output.flv 
     57ffmpeg -f dshow -i video="screen-capture-recorder" output.mkv 
    4458}}} 
    4559 
     
    4862If you need audio too: 
    4963{{{ 
    50 ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone" output.flv 
     64ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone" output.mkv 
    5165}}} 
    5266If you want to capture the audio that is playing from your speakers you may also need to configure so-called "Stereo Mix" device. 
     
    5468or 
    5569{{{ 
    56 ffmpeg -f dshow -i video="UScreenCapture" -f dshow -i audio="Microphone" output.flv 
     70ffmpeg -f dshow -i video="UScreenCapture" -f dshow -i audio="Microphone" output.mkv 
    5771}}} 
    5872 
     
    6377}}} 
    6478 
    65 === Use built-in GDI screengrabber === 
     79== Use built-in GDI screengrabber == 
     80 
    6681You can also use [https://ffmpeg.org/ffmpeg-devices.html#gdigrab gdigrab] as input device to grab video from the Windows screen. 
    6782 
    68 To capture ALL your displays as one big contiguous display: 
     83To capture all your displays as one big contiguous display: 
    6984{{{ 
    70 ffmpeg -f gdigrab -framerate 30 -i desktop capture.mkv 
     85ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv 
    7186}}} 
    7287 
    7388If you want to limit to a region, and show the area being grabbed: 
    7489{{{ 
    75 ffmpeg -f gdigrab -framerate 30 -offset_x 10 -offset_y 20 -video_size 640x480 -show_region 1 -i desktop capture.mkv 
     90ffmpeg -f gdigrab -framerate 30 -offset_x 10 -offset_y 20 -video_size 640x480 -show_region 1 -i desktop output.mkv 
    7691}}} 
    7792 
     
    7994To grab the contents of the window named "Calculator": 
    8095{{{ 
    81 ffmpeg -f gdigrab -framerate 30 -i title=Calculator capture.mkv 
     96ffmpeg -f gdigrab -framerate 30 -i title=Calculator output.mkv 
    8297}}} 
    8398 
    84 Lossless and Fullscreen record: 
     99= Hardware Encoding = 
     100 
     101You can use [[HWAccelIntro|hardware acceleartion]] to speed up encoding and reduce the load on your CPU. For example, with NVIDIA hardware encoding: 
     102 
    85103{{{ 
    86 ffmpeg -f gdigrab -framerate 30 -i desktop -c:v libx264 -qp 0 -preset ultrafast capture.mkv 
     104ffmpeg -f gdigrab -framerate 30 -i desktop -c:v h264_nvenc -qp 0 output.mkv 
    87105}}} 
    88106 
     107= Lossless Recording = 
    89108 
    90 Lossless and Fullscreen record with nvidia hardware encoding: 
     109If your CPU is not fast enough, the encoding process might take too long. To speed up the encoding process, you can use lossless encoding and disable advanced encoder options, e.g.: 
     110 
    91111{{{ 
    92 ffmpeg -f gdigrab -framerate 30 -i desktop -c:v h264_nvenc -qp 0 capture.mkv 
     112ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -crf 0 -preset ultrafast output.mkv 
    93113}}} 
    94114 
    95 == General notes == 
    96  
    97 If 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: 
    98  
    99 Linux: 
    100 {{{ 
    101 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.mkv 
    102 ffmpeg -i output.mkv -acodec ... -vcodec ... final.mkv 
    103 }}} 
    104  
    105 Windows: 
    106 {{{ 
    107 ffmpeg -f dshow -i video="screen-capture-recorder":audio="Microphone" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv 
    108 ffmpeg -i output.flv -acodec ... -vcodec ... final.mkv 
    109 }}} 
    110  
    111 == Lossless recording == 
    112  
    113 If you want a perfect recording of your desktop, x264 can help. Use lossless encoding, e.g.: 
    114  
    115 {{{ 
    116 ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast capture.mkv 
    117 }}} 
    118  
    119 {{{-qp 0}}} tells x264 to encode in lossless mode, {{{-preset ultrafast}}} advises it to do so fast. 
     115{{{-crf 0}}} tells x264 to encode in lossless mode; {{{-preset ultrafast}}} advises it to do so fast. 
    120116 
    121117The encoder should be fast enough on most modern hardware to record without any framedrop, and even leave enough CPU headroom for other applications. 
    122118 
    123 If 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. 
     119If 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. 
    124120 
    125121{{{ 
    126 ffmpeg -i capture.mkv -c:v libx264 -qp 0 -preset veryslow capture_smaller.mkv 
     122ffmpeg -i output.mkv -c:v libx264 -crf 0 -preset veryslow output-smaller.mkv 
    127123}}} 
    128  
    129 See [[Encode/H.264]] for more info and examples. 
    130 [[Capture/Desktop中文版本]]