An attempt at a merged command.

This commit is contained in:
Tom Alexander 2024-10-10 18:12:39 -04:00
parent 6d0bc958a9
commit 40b0d2c684
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -12,6 +12,8 @@ function main {
shift shift
if [ "$cmd" = "copy" ]; then if [ "$cmd" = "copy" ]; then
copy "${@}" copy "${@}"
elif [ "$cmd" = "av1" ]; then
av1 "${@}"
elif [ "$cmd" = "stream_software_h264" ]; then elif [ "$cmd" = "stream_software_h264" ]; then
stream_software_h264 "${@}" stream_software_h264 "${@}"
elif [ "$cmd" = "stream_hardware_h264" ]; then elif [ "$cmd" = "stream_hardware_h264" ]; then
@ -62,6 +64,70 @@ function copy {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch" "rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
} }
function av1 {
# local additional_flags=()
# additional_flags+=(--profile "$PROFILE")
# (cd "$DIR/../" && cargo build --no-default-features "${additional_flags[@]}")
local destination_type="$1" # "stream" or "preprocess"
local acceleration_type="$2" # "software" or "hardware"
# shift 2
local args=()
if [ "$destination_type" == "stream" ]; then
args+=(-re -stream_loop -1)
elif [ "$destination_type" == "preproces" ]; then
true
else
(>&2 echo "Unknown destination type: $destination_type")
exit 1
fi
if [ "$acceleration_type" == "software" ]; then
true
elif [ "$acceleration_type" == "hardware" ]; then
args+=(-vaapi_device /dev/dri/renderD128)
else
(>&2 echo "Unknown acceleration type: $acceleration_type")
exit 1
fi
args+=(-i "$file_to_cast")
if [ "$acceleration_type" == "software" ]; then
args+=(-c:v h264)
elif [ "$acceleration_type" == "hardware" ]; then
args+=(-vf 'format=nv12|vaapi,hwupload')
args+=(-c:v h264_vaapi)
else
(>&2 echo "Unknown acceleration type: $acceleration_type")
exit 1
fi
args+=(-b:v 2M)
args+=(-profile:v high)
args+=(-bf 0)
args+=(-strict -2)
args+=(-c:a opus)
args+=(-ac 2)
args+=(-b:a 320k)
args+=(-ar 48000)
if [ "$destination_type" == "stream" ]; then
args+=(-f rtsp)
args+=(-rtsp_transport tcp)
args+=("rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch")
elif [ "$destination_type" == "preproces" ]; then
args+=("$file_to_save")
else
(>&2 echo "Unknown destination type: $destination_type")
exit 1
fi
}
function stream_software_h264 { function stream_software_h264 {
local file_to_cast local file_to_cast
file_to_cast="$3" file_to_cast="$3"