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

View File

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

View File

@ -97,6 +97,7 @@ OPTIONS:
-N, --no-video Disable video recording. Overrides video options.
-y, --yes-audio Enable audio 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.
-h, --help Show this menu.
@ -125,9 +126,9 @@ start() {
printf '' >> "$i"
printf '%s' "$i" > "$RUNTIME"/"$OUTPUT"_current
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
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
printf "%s" "$!" > "$RUNTIME"/"$OUTPUT".pid
fg || exit
@ -136,7 +137,7 @@ start() {
}
until [ -z "$1" ]; do
re="[0-9]+"
re="^[0-9]+$"
case "$1" in
'-h' | '--help') print_help ;;
'-e' | '--end')
@ -195,6 +196,16 @@ until [ -z "$1" ]; do
'-Y' | '--yes-video')
NO_VIDEO=""
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')
set -x
shift 1 ;;
@ -205,10 +216,6 @@ until [ -z "$1" ]; do
esac
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
printf "Must have either audio or video recording enabled.\n"
@ -224,13 +231,18 @@ if [ "$START" == 1 ]; then
fi
fi
if [ "$RAW_RECORD" == 1 ]; then
kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)"
record "$FILE" "$TIME"
fi
if [ "$RECORD" == 1 ]; 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"
TIME="$(eval "printf '$WOFI_STRING' | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 ${VERBOSE:-2>/dev/null}")"
FILE="$(<"$RUNTIME"/"$OUTPUT"_current)"
kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)"
. "$RUNTIME"/"$OUTPUT".env
case "$TIME" in
'5 seconds') record "$FILE" 5 ;;
'10 seconds') record "$FILE" 10 ;;
@ -240,7 +252,6 @@ if [ "$RECORD" == 1 ]; then
'5 minutes') record "$FILE" 300 ;;
'10 minutes') record "$FILE" 600 ;;
+([0-9])) record "$FILE" "$TIME" ;;
*) ;;
esac
else
printf "No such session on output %d\n" "$OUTPUT"
@ -251,7 +262,6 @@ if [ "$END" == 1 ]; then
if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then
kill "$(<"$RUNTIME"/"$OUTPUT"_host.pid)"
rm -f "$RUNTIME"/"$OUTPUT"_host.pid
rm -f "$RUNTIME"/"$OUTPUT".env
else
printf "No such session on output %d\n" "$OUTPUT"
fi