Skip to content

Instantly share code, notes, and snippets.

@timo
Forked from jpenalbae/peek.sh
Created October 9, 2024 19:45

Revisions

  1. @jpenalbae jpenalbae revised this gist Jun 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion peek.sh
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ echo "Recording started. Press 'q' to stop recording."

    # run the ffmpeg command
    ffmpeg -f x11grab -loglevel quiet -s ${width}x${height} -i ${DISPLAY}+$x,$y \
    -f alsa -i pulse -c:v libx264 -preset ultrafast -crf QUALITY \
    -f alsa -i pulse -c:v libx264 -preset ultrafast -crf ${QUALITY} \
    -tune zerolatency -pix_fmt yuv420p -f mp4 $filename

    # display message to user
  2. @jpenalbae jpenalbae revised this gist Jun 13, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions peek.sh
    Original file line number Diff line number Diff line change
    @@ -41,8 +41,8 @@ echo "Recording started. Press 'q' to stop recording."

    # run the ffmpeg command
    ffmpeg -f x11grab -loglevel quiet -s ${width}x${height} -i ${DISPLAY}+$x,$y \
    -f alsa -i pulse -c:v libx264 -preset ultrafast -crf 28 -tune zerolatency \
    -pix_fmt yuv420p -f mp4 $filename
    -f alsa -i pulse -c:v libx264 -preset ultrafast -crf QUALITY \
    -tune zerolatency -pix_fmt yuv420p -f mp4 $filename

    # display message to user
    echo "Recording stopped."
  3. @jpenalbae jpenalbae created this gist Jun 12, 2023.
    48 changes: 48 additions & 0 deletions peek.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #!/bin/bash

    # Video Quality
    # The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default,
    # and 51 is worst quality possible. A lower value generally leads to higher
    # quality, and a subjectively sane range is 17–28
    QUALITY=28

    # check if slop command exists
    if ! command -v slop &> /dev/null
    then
    echo "slop command not found. Please install slop."
    exit 1
    fi

    # check if an output filename was provided
    if [ -z "$1" ]; then
    echo "Usage: $0 <output.mp4>"
    exit 1
    fi

    # set the output file name
    filename="$1"

    # get the selection coordinates using slop
    echo "Select the desktop area to record."
    coords=$(slop -f "%x %y %w %h")

    # extract the x, y, width, and height values from the coordinates
    x=$(echo $coords | awk '{print $1}')
    y=$(echo $coords | awk '{print $2}')
    width=$(echo $coords | awk '{print $3}')
    height=$(echo $coords | awk '{print $4}')

    # ensure that the height and width are divisible by 2
    width=$((width / 2 * 2))
    height=$((height / 2 * 2))

    # display message to user
    echo "Recording started. Press 'q' to stop recording."

    # run the ffmpeg command
    ffmpeg -f x11grab -loglevel quiet -s ${width}x${height} -i ${DISPLAY}+$x,$y \
    -f alsa -i pulse -c:v libx264 -preset ultrafast -crf 28 -tune zerolatency \
    -pix_fmt yuv420p -f mp4 $filename

    # display message to user
    echo "Recording stopped."