Skip to content

Instantly share code, notes, and snippets.

@gorango
Last active January 7, 2023 04:28
Show Gist options
  • Select an option

  • Save gorango/3612f03cd3123eee81a3fe6d49fbf1b5 to your computer and use it in GitHub Desktop.

Select an option

Save gorango/3612f03cd3123eee81a3fe6d49fbf1b5 to your computer and use it in GitHub Desktop.
Uses CVLC (command-line VLC) to record a screen session in Linux.

Linux screen capture

Uses CVLC (command-line VLC) to record an ongoing screen session in Linux.

Requires VLC to be installed.

Usage

To save a new video file in the current folder:

$ screencast

To save a new video file in a new/existing folder foo:

$ screencast -d foo # -d or --directory

New files will be named screencast-<year><month><day><hour><minute>.mp4

Important

In order to finish recording and save the video file, enter quit in the original console.

Do not close with ctrl-c as it can corrupt the file!

Notes

  • Doesn't display cursor in output
    • There is a way to provide a custom PNG to overlay cursor movements
      • BUT! Cursor won't change as it does on usual interactive elements (text, buttons, etc)
  • Apparent lag in final output
    • FPS flag doesn't seem to change the output framerate
#!/bin/bash
#
# Usage:
# -------------------------------------------------------
# `screencast`
# saves video file in the current folder
# `screencast -d foo`
# saves video file in the 'foo' folder (creates folder if none exists)
#
# TERMINATE BY ENTERING `quit` INTO THE RUNNING TERMINAL
#
# DO NOT CLOSE WITH `Ctrl-C` -- CAN CAUSE CORRUPTION !!!
#
DATE=$(date +%y%m%d%H%M)
NAME="screencast-$DATE"
FILE="$NAME"
while [[ $# > 1 ]]
do
key="$1"
case $key in
-d|--directory)
DIR="$2"
FILE="$DIR/$NAME"
$(mkdir -p $DIR)
shift;;
*)
esac
shift
done
cvlc screen:// \
-I rc \
--screen-follow-mouse \
--screen-fps 5 \
:sout="#transcode{vcodec=h264,vb=800,fps=5,scale=1,acodec=none}:duplicate{dst=std{access=file,mux=mp4,dst=$FILE}}"
@midnqp
Copy link
Copy Markdown

midnqp commented Jul 16, 2020

  1. Can it record audio? If yes, can it record from both mic and output?
  2. (silly question) Why is fps=5?

@gorango
Copy link
Copy Markdown
Author

gorango commented Jul 25, 2020

I think it does record audio - you'd have to look into the VLC command line util for the vairous options.
Frames per second (FPS) controls the quality.

I no longer use this solution - instead OBS for any screencaps/recordings.

@midnqp
Copy link
Copy Markdown

midnqp commented Jul 25, 2020

@gorango May I know, what specifically bothers you about this solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment