Update cast_file incantations.

This commit is contained in:
Tom Alexander 2024-10-09 21:09:11 -04:00
parent e38bee4c0f
commit 6d0bc958a9
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -12,12 +12,14 @@ function main {
shift shift
if [ "$cmd" = "copy" ]; then if [ "$cmd" = "copy" ]; then
copy "${@}" copy "${@}"
elif [ "$cmd" = "h264" ]; then elif [ "$cmd" = "stream_software_h264" ]; then
h264 "${@}" stream_software_h264 "${@}"
elif [ "$cmd" = "stream_hardware_h264" ]; then
stream_hardware_h264 "${@}"
elif [ "$cmd" = "preprocess_software_h264" ]; then
preprocess_software_h264 "${@}"
elif [ "$cmd" = "preprocess_hardware_h264" ]; then elif [ "$cmd" = "preprocess_hardware_h264" ]; then
preprocess_hardware_h264 "${@}" preprocess_hardware_h264 "${@}"
elif [ "$cmd" = "software_h264" ]; then
software_h264 "${@}"
elif [ "$cmd" = "vp9" ]; then elif [ "$cmd" = "vp9" ]; then
vp9 "${@}" vp9 "${@}"
elif [ "$cmd" = "preprocess_hardware_vp9" ]; then elif [ "$cmd" = "preprocess_hardware_vp9" ]; then
@ -60,7 +62,7 @@ function copy {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch" "rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
} }
function h264 { function stream_software_h264 {
local file_to_cast local file_to_cast
file_to_cast="$3" file_to_cast="$3"
@ -74,17 +76,14 @@ function h264 {
</dev/null exec ffmpeg \ </dev/null exec ffmpeg \
-re \ -re \
-stream_loop -1 \ -stream_loop -1 \
-init_hw_device vaapi=foo:/dev/dri/renderD128 \
-hwaccel vaapi \
-hwaccel_output_format vaapi \
-hwaccel_device foo \
-i "$file_to_cast" \ -i "$file_to_cast" \
-filter_hw_device foo \ -c:v h264 \
-vf 'format=nv12|vaapi,hwupload' \ -b:v 2M \
-c:v h264_vaapi \ -profile:v high \
-bf 0 \ -bf 0 \
-strict -2 \ -strict -2 \
-c:a opus \ -c:a opus \
-ac 2 \
-b:a 320k \ -b:a 320k \
-ar 48000 \ -ar 48000 \
-f rtsp \ -f rtsp \
@ -92,7 +91,38 @@ function h264 {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch" "rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
} }
function preprocess_hardware_h264 { function stream_hardware_h264 {
local file_to_cast
file_to_cast="$3"
local USERNAME PASSWORD
USERNAME="$1"
PASSWORD="$2"
set -x
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \
-re \
-stream_loop -1 \
-vaapi_device /dev/dri/renderD128 \
-i "$file_to_cast" \
-vf 'format=nv12|vaapi,hwupload' \
-c:v h264_vaapi \
-b:v 2M \
-profile:v high \
-bf 0 \
-strict -2 \
-c:a opus \
-ac 2 \
-b:a 320k \
-ar 48000 \
-f rtsp \
-rtsp_transport tcp \
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
}
function preprocess_software_h264 {
local file_to_cast file_to_save local file_to_cast file_to_save
file_to_cast="$1" file_to_cast="$1"
file_to_save="$2" file_to_save="$2"
@ -101,14 +131,8 @@ function preprocess_hardware_h264 {
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames. # -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \ </dev/null exec ffmpeg \
-init_hw_device vaapi=foo:/dev/dri/renderD128 \
-hwaccel vaapi \
-hwaccel_output_format vaapi \
-hwaccel_device foo \
-i "$file_to_cast" \ -i "$file_to_cast" \
-filter_hw_device foo \ -c:v h264 \
-vf 'format=nv12|vaapi,hwupload' \
-c:v h264_vaapi \
-b:v 2M \ -b:v 2M \
-profile:v high \ -profile:v high \
-bf 0 \ -bf 0 \
@ -120,32 +144,7 @@ function preprocess_hardware_h264 {
"$file_to_save" "$file_to_save"
} }
function software_h264 { function preprocess_hardware_h264 {
local file_to_cast
file_to_cast="$3"
local USERNAME PASSWORD
USERNAME="$1"
PASSWORD="$2"
set -x
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \
-re \
-stream_loop -1 \
-i "$file_to_cast" \
-c:v h264 \
-bf 0 \
-c:a opus \
-b:a 320k \
-ar 48000 \
-f rtsp \
-rtsp_transport tcp \
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
}
function preprocess_h264 {
local file_to_cast file_to_save local file_to_cast file_to_save
file_to_cast="$1" file_to_cast="$1"
file_to_save="$2" file_to_save="$2"
@ -154,10 +153,16 @@ function preprocess_h264 {
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames. # -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \ </dev/null exec ffmpeg \
-vaapi_device /dev/dri/renderD128 \
-i "$file_to_cast" \ -i "$file_to_cast" \
-c:v h264 \ -vf 'format=nv12,hwupload' \
-c:v h264_vaapi \
-b:v 2M \
-profile:v high \
-bf 0 \ -bf 0 \
-strict -2 \
-c:a opus \ -c:a opus \
-ac 2 \
-b:a 320k \ -b:a 320k \
-ar 48000 \ -ar 48000 \
"$file_to_save" "$file_to_save"