View Single Post
Old 03-24-2019, 01:43 PM   #28
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 1,893
Default

I'd like to mention another method to easily create screen videos. This method makes use ot ffmpeg's command line capabilities. I've been using plenty of screen capturing software (BandiCam, OBS, CamStudio, Easy Screencast Recorder, VirtualDub, etc.). Unfortunetely, all of them had their quirks (payed, adds/watermarks, time limit, a/v sync issues, hassle to set up, etc.). I finaly settled on using either OBS (several audio tracks recorded simultaneously with the video, like Reaper output plus my voice on a separate audio stream to be able to mix them as desired later) or VirtualDub and video quality is fine. Both don't have a time limit.

I then read about ffmpeg and its command line capabilities. Generally, I don't like using command line apps. I prefer to have a gui. However, I found some example command lines suitable for screen capturing and I managed to hack together a few batch files that allow me to capture my entire screen or parts of it by simply double-clicking shortcuts to those batch files. I'm sharing the batch files here. The advantages I'm seeing are:
  • no cost
  • very quick launch of screen recording for a few different video resolutions, video image/audio stream qualities and capturing areas - everything is pre-configured in the batch files
  • no ads/watermarks
  • no time limit
  • full control over every parameter
  • fairly easy to tweak
  • probably lower cpu impact while capturing compared to using full-fletched apps
  • nothing to install besides h264 codec which you can use to also render h264 videos in Reaper

Here's how to set it up on Windows:
  • download x264 video codec from here: https://www.videohelp.com/software/x264-VFW and install it
  • download ffmpeg for your system here: https://www.ffmpeg.org/download.html. Simply extract the zip's content to a location of your choice
  • copy and paste the following command line into a plain text editor and save it as a batch file (i.e. with the extension ".bat") to a desired location.
    Here's the command line to record the entire screen in decent quality in FullHD incl. mouse pointer and with aac stereo audio @ 320 kbps captured from an RME Babyface ADAT 1+2:

    Code:
    "D:\Programme\ffmpeg x64\bin\ffmpeg.exe" -n -rtbufsize 2000M -f gdigrab -r 25 -video_size 1920x1080 -draw_mouse 1 -i desktop -f dshow -i audio="SPDIF/ADAT (1+2) (RME Babyface)" -c:v libx264 -r 25 -preset faster -x264-params keyint=25 -crf 12 -pix_fmt yuv420p -c:a aac -ar 48K -ac 2 -b:a 320k "G:\Screen-Videos\Screenvideo_.mkv"
    You have to edit this command line to account for ffmpeg's actual location on your system and the path/file name of the recorded video!

  • create a shortcut to the batch file on your desktop or your quick launch bar
  • double-click the shortcut to immediately start a screen capture recording with the properties defined in the batch file

The following command line captures a user-defined area (834x466 pixels starting at screen location 420,293):

"D:\Programme\ffmpeg x64\bin\ffmpeg.exe" -n -rtbufsize 2000M -f gdigrab -r 25 -show_region 1 -offset_x 420 -offset_y 293 -video_size 834x466 -draw_mouse 0 -i desktop -f dshow -i audio="SPDIF/ADAT (1+2) (RME Babyface)" -c:v libx264 -r 25 -preset faster -crf 24 -pix_fmt yuv420p -c:a aac -ar 48K -ac 1 -b:a 128k "G:\Screen-Videos\abcdefg.mkv"


Explanation of the most common command line parameters:
  • -n (prevents overwriting an existing file with same name in the output directory; use -y to allow overwriting)
  • -f gdigrab (use video grabber provided by Windows)
  • -r 25 (video frame rate)
  • -offset_x 434 -offset_y 292 (grab part of screen with upper left corner of video being at 434,292; x=0 and y=0 -> no offset)
  • -video_size 1920x1080 (dimensions of output video, only use even numbers)
  • -draw_mouse 1 (include mouse pointer in video, change to 0 to not include)
  • -i desktop (capture entire screen)
  • -f dshow (use DirectShow filter)
  • -i audio="SPDIF/ADAT (1+2) (RME Babyface)" (change this to your audio device as described in next paragraph)
  • -c:v libx264 (use x264 to compress the video)
  • -preset faster (encoder speed)
  • -x264-params keyint=25 (force key-/I-frame every 25 frames, thus, once per second with r=25)
  • -crf 12 (video image quality, the lower, the better but also the bigger the file; 1-15 HiQ, 16-25 decent, 26-35 LoQ, >36 pixel mud)
  • -c:a aac (audio codec; alternatively use libopus or libmp3lame instead of "aac")
  • -ar 48K (sampling frequency of your audio device)
  • -ac 2 (no. of audio channels, 1=mono, 2=stereo)
  • -b:a 320k (bit rate of audio stream)

To determin which video capturing device and what audio devices can be used on your system and what their exact system name is, run the following batch command after adapting the path to ffmpeg.exe to the one on your system:

Code:
"D:\Programme\ffmpeg x64\bin\ffmpeg.exe" -list_devices true -f dshow -i dummy
You may then replace the audio device's name in my example command line (Babyface ADAT 1+2) to match your audio device's name.

Only minor drawback of the batch file method is the inability to easily define a custom capture region. You have to edit the batch file for this. To at least facilitate this process, I'm using the free Fast Stone Capture utility to find out the coordinates of a particular screen area by triggering a screen area capture and then copy the values shown into the offset command of the batch file.

Have fun!

EDIT (2019-04-02): Meanwhile I've found the command line to capture 2 stereo sources simultaneously into the same video file:

Code:
"D:\Programme\ffmpeg x64\bin\ffmpeg.exe" -n -rtbufsize 2000M -f gdigrab -r 25 -video_size 1920x1080 -draw_mouse 1 -i desktop -f dshow -i audio="SPDIF/ADAT (1+2) (RME Babyface)" -f dshow -i audio="ADAT (5+6) (RME Babyface)" -map 0:v -map 1:a -map 2:a -c:v libx264 -r 25 -preset faster -x264-params keyint=25 -tune zerolatency -crf 12 -pix_fmt yuv420p -ac 2 -c:a:1 pcm_s16le -c:a:2 pcm_s16le -ar 44.1K "G:\Screen-Videos\Screenvideo_.mkv"
The above example will capture 2 PCM stereo audio streams @ 44.1k along with the video.

.
__________________
[Check out my free VST plugin collection here.]

Last edited by SonicAxiom; 06-21-2019 at 07:36 PM.
SonicAxiom is offline   Reply With Quote