Changes between Version 14 and Version 15 of Capture/Desktop
- Timestamp:
- Apr 6, 2015, 10:57:32 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Capture/Desktop
v14 v15 1 1 == Linux == 2 2 3 Use the '''[http://ffmpeg.org/ffmpeg-devices.html#x11grab x11grab]'''device:3 Use the [https://ffmpeg.org/ffmpeg-devices.html#x11grab x11grab] device: 4 4 {{{ 5 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output. flv5 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4 6 6 }}} 7 7 8 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. 9 9 10 If you need audio too , you can use '''[http://ffmpeg.org/ffmpeg-devices.html#alsa-1 alsa]''' like this:10 If you need audio too you can use [https://ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA] (see [[Capture/ALSA]] for more info): 11 11 {{{ 12 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i pulse output.flv12 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i hw:0 output.mkv 13 13 }}} 14 15 Or the [https://ffmpeg.org/ffmpeg-devices.html#pulse pulse] input device: 16 {{{ 17 ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f pulse -ac 2 -i default output.mkv 18 }}} 19 14 20 15 21 == OS X == 16 22 17 Use the '''[http://ffmpeg.org/ffmpeg-devices.html#avfoundation avfoundation]'''device:23 Use the [https://ffmpeg.org/ffmpeg-devices.html#avfoundation avfoundation] device: 18 24 {{{ 19 25 ffmpeg -f avfoundation -list_devices true -i "" … … 22 28 This will enumerate all the available input devices including screens ready to be captured. 23 29 24 (Did not work for me; only webcam gets enumerated, desktop/audio devices do not. Any other prerequisites? -Vultaire)25 26 30 Once you've figured out the device index corresponding to the screen to be captured use: 27 31 {{{ 28 ffmpeg -f avfoundation -i "<screen device index>:<audio device index>" out. avi32 ffmpeg -f avfoundation -i "<screen device index>:<audio device index>" out.mov 29 33 }}} 30 34 31 This will capture the screen from <screen device index> and audio from <audio device index> into the output file out.avi.35 This will capture the screen from `<screen device index>` and audio from `<audio device index>` into the output file `out.mov`. 32 36 33 37 == Windows == 34 38 35 Use a '''[http://ffmpeg.org/ffmpeg-devices.html#dshow dshow]'''[https://github.com/rdp/screen-capture-recorder-to-video-windows-free device]:39 Use a [http://ffmpeg.org/ffmpeg-devices.html#dshow dshow] [https://github.com/rdp/screen-capture-recorder-to-video-windows-free device]: 36 40 {{{ 37 41 ffmpeg -f dshow -i video="screen-capture-recorder" output.flv 38 42 }}} 39 43 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:44 This 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]. 41 45 42 If you need audio too , you can use this:46 If you need audio too: 43 47 {{{ 44 48 ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone" output.flv 45 49 }}} 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. 50 If you want to capture the audio that is playing from your speakers you may also need to configure so-called "Stereo Mix" device. 48 51 49 52 or … … 58 61 }}} 59 62 60 There is also a "gdigrab" you can use to grab from the screen in windows (video)63 There is also the [https://ffmpeg.org/ffmpeg-devices.html#gdigrab gdigrab] input device you can use to grab video from the screen in Windows. 61 64 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 == 80 66 81 67 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: … … 83 69 Linux: 84 70 {{{ 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. flv86 ffmpeg -i output. flv -acodec ... -vcodec ... final.flv71 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 72 ffmpeg -i output.mkv -acodec ... -vcodec ... final.mkv 87 73 }}} 88 74 89 75 Windows: 90 76 {{{ 91 ffmpeg -f dshow -i video="screen-capture-recorder":audio="Microphone" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output. flv92 ffmpeg -i output.flv -acodec ... -vcodec ... final. flv77 ffmpeg -f dshow -i video="screen-capture-recorder":audio="Microphone" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv 78 ffmpeg -i output.flv -acodec ... -vcodec ... final.mkv 93 79 }}} 94 80 … … 98 84 99 85 {{{ 100 ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast -profile:v high444capture.mkv86 ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast capture.mkv 101 87 }}} 102 88 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. 104 90 105 91 The 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.mkv111 }}}112 92 113 93 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. 114 94 115 95 {{{ 116 ffmpeg -i capture.mkv -c:v libx264 -qp 0 - tune stillimage -preset veryslow -profile:v high444capture_smaller.mkv96 ffmpeg -i capture.mkv -c:v libx264 -qp 0 -preset veryslow capture_smaller.mkv 117 97 }}} 98 99 See [[Encode/H.264]] for more info and examples.
