Make NO_AUDIO only in ffmpeg, stop saving options between clips

Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2023-05-16 20:53:36 -04:00
parent 1442043c5b
commit 958710ba7c
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
3 changed files with 33 additions and 35 deletions

View File

@ -5,7 +5,7 @@
.nh .nh
.ad l .ad l
.\" Begin generated content: .\" Begin generated content:
.TH "wf-shadow" "1" "2023-05-16" "wf-shadow" "General Commands Manual" .TH "wf-shadow" "1" "2023-05-17" "wf-shadow" "General Commands Manual"
.P .P
.SH NAME .SH NAME
.P .P
@ -26,8 +26,7 @@ and wofi(1) in order to accomplish the task.\&
.P .P
\fB-A, --acodec\fR \fICODEC\fR \fB-A, --acodec\fR \fICODEC\fR
.RS 4 .RS 4
This option is passed directly to ffmpeg(1)'\&s \fI-acodec\fR.\& Saved between This option is passed directly to ffmpeg(1)'\&s \fI-acodec\fR.\&
clips over the course of a session'\&s lifetime.\&
.P .P
.RE .RE
\fB-a, --audio\fR \fIDEVICE\fR \fB-a, --audio\fR \fIDEVICE\fR
@ -38,8 +37,7 @@ that is recorded by \fBwf-shadow\fR.\&
.RE .RE
\fB-c, --vcodec\fR \fICODEC\fR \fB-c, --vcodec\fR \fICODEC\fR
.RS 4 .RS 4
This option is passed directly to ffmpeg(1)'\&s \fI-vcodec\fR.\& Saved between This option is passed directly to ffmpeg(1)'\&s \fI-vcodec\fR.\&
clips over the course of a session'\&s lifetime.\&
.P .P
.RE .RE
\fB-d, --debug\fR \fB-d, --debug\fR
@ -59,15 +57,13 @@ Shows a simple help menu.\&
.RE .RE
\fB-N, --no-video\fR \fB-N, --no-video\fR
.RS 4 .RS 4
By default, \fBwf-shadow\fR enables video recording.\& Saved between clips By default, \fBwf-shadow\fR enables video recording.\&
over the course of a session'\&s lifetime.\&
.P .P
.RE .RE
\fB-n, --no-audio\fR \fB-n, --no-audio\fR
.RS 4 .RS 4
By default, \fBwf-shadow\fR enables the -a option of wf-recorder(1).\& This By default, \fBwf-shadow\fR enables the -a option of wf-recorder(1).\& This
option disables it.\& Saved between clips over the course of a session'\&s option disables it.\&
lifetime.\&
.P .P
.RE .RE
\fB-r, --record\fR [\fIOUTPUT\fR] \fB-r, --record\fR [\fIOUTPUT\fR]
@ -97,14 +93,12 @@ Show the output of wf-recorder(1), ffmpeg(1), and wofi(1).\&
.RE .RE
\fB-Y, --yes-video\fR \fB-Y, --yes-video\fR
.RS 4 .RS 4
Enable video recording.\& Overrides \fI-N\fR.\& Saved between clips over the Enable video recording.\& Overrides \fI-N\fR.\&
course of a session'\&s lifetime.\&
.P .P
.RE .RE
\fB-y, --yes-audio\fR \fB-y, --yes-audio\fR
.RS 4 .RS 4
Enable audio recording.\& Overrides \fI-n\fR.\& Saved between clips over the Enable audio recording.\& Overrides \fI-n\fR.\&
course of a session'\&s lifetime.\&
.P .P
.RE .RE
.SH ENVIRONMENT .SH ENVIRONMENT

View File

@ -18,16 +18,14 @@ and wofi(1) in order to accomplish the task.
# OPTIONS # OPTIONS
*-A, --acodec* _CODEC_ *-A, --acodec* _CODEC_
This option is passed directly to ffmpeg(1)'s _-acodec_. Saved between This option is passed directly to ffmpeg(1)'s _-acodec_.
clips over the course of a session's lifetime.
*-a, --audio* _DEVICE_ *-a, --audio* _DEVICE_
This option is used in order to set the pulseaudio/pipewire-pulse device This option is used in order to set the pulseaudio/pipewire-pulse device
that is recorded by *wf-shadow*. that is recorded by *wf-shadow*.
*-c, --vcodec* _CODEC_ *-c, --vcodec* _CODEC_
This option is passed directly to ffmpeg(1)'s _-vcodec_. Saved between This option is passed directly to ffmpeg(1)'s _-vcodec_.
clips over the course of a session's lifetime.
*-d, --debug* *-d, --debug*
Sets the bash(1) _-x_ option. Sets the bash(1) _-x_ option.
@ -39,13 +37,11 @@ and wofi(1) in order to accomplish the task.
Shows a simple help menu. Shows a simple help menu.
*-N, --no-video* *-N, --no-video*
By default, *wf-shadow* enables video recording. Saved between clips By default, *wf-shadow* enables video recording.
over the course of a session's lifetime.
*-n, --no-audio* *-n, --no-audio*
By default, *wf-shadow* enables the -a option of wf-recorder(1). This By default, *wf-shadow* enables the -a option of wf-recorder(1). This
option disables it. Saved between clips over the course of a session's option disables it.
lifetime.
*-r, --record* [_OUTPUT_] *-r, --record* [_OUTPUT_]
Record the last few moments of video using a wofi(1) menu. Any arbitrary Record the last few moments of video using a wofi(1) menu. Any arbitrary
@ -65,12 +61,10 @@ and wofi(1) in order to accomplish the task.
Show the output of wf-recorder(1), ffmpeg(1), and wofi(1). Show the output of wf-recorder(1), ffmpeg(1), and wofi(1).
*-Y, --yes-video* *-Y, --yes-video*
Enable video recording. Overrides _-N_. Saved between clips over the Enable video recording. Overrides _-N_.
course of a session's lifetime.
*-y, --yes-audio* *-y, --yes-audio*
Enable audio recording. Overrides _-n_. Saved between clips over the Enable audio recording. Overrides _-n_.
course of a session's lifetime.
# ENVIRONMENT # ENVIRONMENT

View File

@ -97,6 +97,7 @@ OPTIONS:
-N, --no-video Disable video recording. Overrides video options. -N, --no-video Disable video recording. Overrides video options.
-y, --yes-audio Enable audio recording. Overrides -n. -y, --yes-audio Enable audio recording. Overrides -n.
-Y, --yes-video Enable video recording. Overrides -N. -Y, --yes-video Enable video recording. Overrides -N.
-R, --raw-record OUTPUT FILE SECONDS Low level record. Passed directly to the \`record\` function.
-v, --verbose Verbose output. -v, --verbose Verbose output.
-h, --help Show this menu. -h, --help Show this menu.
@ -125,9 +126,9 @@ start() {
printf '' >> "$i" printf '' >> "$i"
printf '%s' "$i" > "$RUNTIME"/"$OUTPUT"_current printf '%s' "$i" > "$RUNTIME"/"$OUTPUT"_current
if [ -n "$VERBOSE" ]; then if [ -n "$VERBOSE" ]; then
wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} ${NO_AUDIO:--a} ${AUDIO_DEV:+"${NO_AUDIO:-$AUDIO_DEV}"} -f "$i" <<< y$'\n'$OUTPUT & wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} -a $AUDIO_DEV -f "$i" <<< y$'\n'$OUTPUT &
else else
wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} ${NO_AUDIO:--a} ${AUDIO_DEV:+"${NO_AUDIO:-$AUDIO_DEV}"} -f "$i" <<< y$'\n'$OUTPUT &>/dev/null & wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} -a $AUDIO_DEV -f "$i" <<< y$'\n'$OUTPUT &>/dev/null &
fi fi
printf "%s" "$!" > "$RUNTIME"/"$OUTPUT".pid printf "%s" "$!" > "$RUNTIME"/"$OUTPUT".pid
fg || exit fg || exit
@ -136,7 +137,7 @@ start() {
} }
until [ -z "$1" ]; do until [ -z "$1" ]; do
re="[0-9]+" re="^[0-9]+$"
case "$1" in case "$1" in
'-h' | '--help') print_help ;; '-h' | '--help') print_help ;;
'-e' | '--end') '-e' | '--end')
@ -195,6 +196,16 @@ until [ -z "$1" ]; do
'-Y' | '--yes-video') '-Y' | '--yes-video')
NO_VIDEO="" NO_VIDEO=""
shift 1 ;; shift 1 ;;
'-R' | '--raw-record')
if [ -n "$4" ]; then
OUTPUT="$2"
FILE="$3"
TIME="$4"
RAW_RECORD=1
shift 4
else
print_help
fi ;;
'-d' | '--debug') '-d' | '--debug')
set -x set -x
shift 1 ;; shift 1 ;;
@ -205,10 +216,6 @@ until [ -z "$1" ]; do
esac esac
done done
declare -p AUDIO_CODEC > "$RUNTIME"/"$OUTPUT".env
declare -p NO_AUDIO >> "$RUNTIME"/"$OUTPUT".env
declare -p VIDEO_CODEC >> "$RUNTIME"/"$OUTPUT".env
declare -p NO_VIDEO >> "$RUNTIME"/"$OUTPUT".env
if [ -n "$NO_VIDEO" ] && [ -n "$NO_AUDIO" ]; then if [ -n "$NO_VIDEO" ] && [ -n "$NO_AUDIO" ]; then
printf "Must have either audio or video recording enabled.\n" printf "Must have either audio or video recording enabled.\n"
@ -224,13 +231,18 @@ if [ "$START" == 1 ]; then
fi fi
fi fi
if [ "$RAW_RECORD" == 1 ]; then
kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)"
record "$FILE" "$TIME"
fi
if [ "$RECORD" == 1 ]; then if [ "$RECORD" == 1 ]; then
if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then
WOFI_STRING="5 seconds\n10 seconds\n15 seconds\n30 seconds\n1 minute\n5 minutes\n10 minutes\nCancel\n" WOFI_STRING="5 seconds\n10 seconds\n15 seconds\n30 seconds\n1 minute\n5 minutes\n10 minutes\nCancel\n"
TIME="$(eval "printf '$WOFI_STRING' | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 ${VERBOSE:-2>/dev/null}")" TIME="$(eval "printf '$WOFI_STRING' | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 ${VERBOSE:-2>/dev/null}")"
FILE="$(<"$RUNTIME"/"$OUTPUT"_current)" FILE="$(<"$RUNTIME"/"$OUTPUT"_current)"
kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)" kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)"
. "$RUNTIME"/"$OUTPUT".env
case "$TIME" in case "$TIME" in
'5 seconds') record "$FILE" 5 ;; '5 seconds') record "$FILE" 5 ;;
'10 seconds') record "$FILE" 10 ;; '10 seconds') record "$FILE" 10 ;;
@ -240,7 +252,6 @@ if [ "$RECORD" == 1 ]; then
'5 minutes') record "$FILE" 300 ;; '5 minutes') record "$FILE" 300 ;;
'10 minutes') record "$FILE" 600 ;; '10 minutes') record "$FILE" 600 ;;
+([0-9])) record "$FILE" "$TIME" ;; +([0-9])) record "$FILE" "$TIME" ;;
*) ;;
esac esac
else else
printf "No such session on output %d\n" "$OUTPUT" printf "No such session on output %d\n" "$OUTPUT"
@ -251,7 +262,6 @@ if [ "$END" == 1 ]; then
if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then
kill "$(<"$RUNTIME"/"$OUTPUT"_host.pid)" kill "$(<"$RUNTIME"/"$OUTPUT"_host.pid)"
rm -f "$RUNTIME"/"$OUTPUT"_host.pid rm -f "$RUNTIME"/"$OUTPUT"_host.pid
rm -f "$RUNTIME"/"$OUTPUT".env
else else
printf "No such session on output %d\n" "$OUTPUT" printf "No such session on output %d\n" "$OUTPUT"
fi fi