diff --git a/ansible/roles/media/files/cast_file_vaapi b/ansible/roles/media/files/cast_file_vaapi index 6786cd2..e972a8d 100644 --- a/ansible/roles/media/files/cast_file_vaapi +++ b/ansible/roles/media/files/cast_file_vaapi @@ -12,6 +12,8 @@ function main { shift if [ "$cmd" = "copy" ]; then copy "${@}" + elif [ "$cmd" = "av1" ]; then + av1 "${@}" elif [ "$cmd" = "stream_software_h264" ]; then stream_software_h264 "${@}" elif [ "$cmd" = "stream_hardware_h264" ]; then @@ -62,6 +64,70 @@ function copy { "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 { local file_to_cast file_to_cast="$3"