Compare commits

..

No commits in common. "14c5c7d0fde91755d2d6ff96c32a0df54e076d32" and "3e8045223553b1f1546cc4ae76bdf3b370c15a19" have entirely different histories.

7 changed files with 36 additions and 33 deletions

View File

@ -31,5 +31,6 @@
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -20,14 +20,6 @@
system = "x86_64-linux";
};
# Uncomment on of these to enable cross compiling:
# nixpkgs.buildPlatform = builtins.currentSystem;
# nixpkgs.buildPlatform = {
# gcc.arch = "znver4";
# gcc.tune = "znver4";
# system = "x86_64-linux";
# };
nixpkgs.overlays = [
(
final: prev:

View File

@ -113,7 +113,7 @@ in
"doc"
"info"
];
nativeBuildInputs = [ final.makeWrapper ];
buildInputs = [ final.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/emacs --prefix PATH : ${
lib.makeBinPath [

View File

@ -33,7 +33,7 @@ let
.overrideAttrs
(old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/decrypt_k8s_secret --prefix PATH : ${
lib.makeBinPath [

View File

@ -6,7 +6,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${VIDEO_BITRATE:="1M"} # Only for encoding modes targeting bitrate
: ${AUDIO_BITRATE:="192k"}
: ${SPEED:="1"}
############## Setup #########################
@ -63,8 +62,6 @@ function copy {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
}
# benchmark vulkan decode:
# ffmpeg -init_hw_device "vulkan=vk:0" -hwaccel vulkan -hwaccel_output_format vulkan -i INPUT -f null - -benchmark
function convert {
local args=()
local acceleration_type="$1" # "software" or "hardware"
@ -102,23 +99,11 @@ function convert {
if [ "$acceleration_type" == "software" ]; then
true
elif [ "$acceleration_type" == "hardware" ]; then
if [ "$codec" == "h264" ]; then
args+=(-init_hw_device vulkan)
elif [ "$codec" == "av1" ]; then
args+=(-vaapi_device /dev/dri/renderD128)
fi
args+=(-vaapi_device /dev/dri/renderD128)
fi
args+=(-i "$file_to_cast")
if [ "$SPEED" != "1" ]; then
local audio_speed video_speed
video_speed=$(bc -l <<< "1/${SPEED}")
audio_speed=$(bc -l <<< "${SPEED}/1")
args+=(-filter:v "setpts=${video_speed}*PTS")
args+=(-filter:a "atempo=${audio_speed}")
fi
if [ "$codec" == "h264" ]; then
if [ "$acceleration_type" == "software" ]; then
args+=(-c:v h264)
@ -126,7 +111,7 @@ function convert {
args+=(-b:v "$VIDEO_BITRATE")
elif [ "$acceleration_type" == "hardware" ]; then
args+=(-vf 'format=nv12|vaapi,hwupload')
args+=(-c:v h264_vulkan)
args+=(-c:v h264_vaapi)
args+=(-profile:v high)
args+=(-b:v "$VIDEO_BITRATE")
fi
@ -134,14 +119,12 @@ function convert {
if [ "$acceleration_type" == "software" ]; then
args+=(-c:v libsvtav1)
args+=(-preset 4) # [0-13] default 10, lower = higher quality / slower encode
# args+=(-crf 20) # [0-63] default 35, lower = higher quality / larger file
args+=(-crf 20) # [0-63] default 35, lower = higher quality / larger file
# Parameters: https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Parameters.md
# fast-decode [0-2] default 0 (off), higher = faster decode
# tune [0-2] default 1, Specifies whether to use PSNR or VQ as the tuning metric [0 = VQ, 1 = PSNR, 2 = SSIM]
# film-grain-denoise, setting to 0 uses the original frames instead of denoising the film grain
# rc 1 = vbr 2 = cbr
# tbr = average bitrate
args+=(-svtav1-params "fast-decode=1:film-grain-denoise=0:tbr=${VIDEO_BITRATE}:rc=1:passes=2")
args+=(-svtav1-params "fast-decode=1:film-grain-denoise=0")
elif [ "$acceleration_type" == "hardware" ]; then
# -c:v av1_amf -quality quality
args+=(-vf 'format=nv12|vaapi,hwupload')
@ -223,4 +206,32 @@ function encode_webcam {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
}
function speed_up_preprocess_vp8 {
local file_to_cast file_to_save
file_to_cast="$1"
file_to_save="$2"
set -x
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
# -strict -2 :: Enable support for experimental codecs like opus.
# -b:v 2M :: Target 2 megabit/s
# -crf 10 :: Target a quality level and adjust bitrate accordingly. This should be preferred, but ideally both should be used.
# Could also use -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]"
</dev/null exec ffmpeg \
-i "$file_to_cast" \
-filter:v "setpts=0.66666666*PTS" \
-filter:a "atempo=1.5" \
-c:v vp8 \
-b:v 2M \
-crf 10 \
-bf 0 \
-c:a opus \
-b:a 320k \
-ar 48000 \
-strict -2 \
"$file_to_save"
}
main "${@}"

View File

@ -131,7 +131,7 @@ in
++ [
prev.rustup
];
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [ pkgs.makeWrapper ];
};
})
];

View File

@ -22,7 +22,6 @@
(lib.mkIf config.me.graphical {
allowedUnfree = [
"vscode"
"vscode-x86_64-unknown-linux-gnu-with-extensions"
"vscode-with-extensions"
"vscode-extension-ms-vscode-remote-remote-ssh"
];