Compare commits
No commits in common. "14c5c7d0fde91755d2d6ff96c32a0df54e076d32" and "3e8045223553b1f1546cc4ae76bdf3b370c15a19" have entirely different histories.
14c5c7d0fd
...
3e80452235
@ -31,5 +31,6 @@
|
|||||||
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
# networking.interfaces.wlp58s0.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;
|
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,6 @@
|
|||||||
system = "x86_64-linux";
|
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 = [
|
nixpkgs.overlays = [
|
||||||
(
|
(
|
||||||
final: prev:
|
final: prev:
|
||||||
|
@ -113,7 +113,7 @@ in
|
|||||||
"doc"
|
"doc"
|
||||||
"info"
|
"info"
|
||||||
];
|
];
|
||||||
nativeBuildInputs = [ final.makeWrapper ];
|
buildInputs = [ final.makeWrapper ];
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
wrapProgram $out/bin/emacs --prefix PATH : ${
|
wrapProgram $out/bin/emacs --prefix PATH : ${
|
||||||
lib.makeBinPath [
|
lib.makeBinPath [
|
||||||
|
@ -33,7 +33,7 @@ let
|
|||||||
.overrideAttrs
|
.overrideAttrs
|
||||||
(old: {
|
(old: {
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
wrapProgram $out/bin/decrypt_k8s_secret --prefix PATH : ${
|
wrapProgram $out/bin/decrypt_k8s_secret --prefix PATH : ${
|
||||||
lib.makeBinPath [
|
lib.makeBinPath [
|
||||||
|
@ -6,7 +6,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
|
|
||||||
: ${VIDEO_BITRATE:="1M"} # Only for encoding modes targeting bitrate
|
: ${VIDEO_BITRATE:="1M"} # Only for encoding modes targeting bitrate
|
||||||
: ${AUDIO_BITRATE:="192k"}
|
: ${AUDIO_BITRATE:="192k"}
|
||||||
: ${SPEED:="1"}
|
|
||||||
|
|
||||||
############## Setup #########################
|
############## Setup #########################
|
||||||
|
|
||||||
@ -63,8 +62,6 @@ function copy {
|
|||||||
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
|
"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 {
|
function convert {
|
||||||
local args=()
|
local args=()
|
||||||
local acceleration_type="$1" # "software" or "hardware"
|
local acceleration_type="$1" # "software" or "hardware"
|
||||||
@ -102,23 +99,11 @@ function convert {
|
|||||||
if [ "$acceleration_type" == "software" ]; then
|
if [ "$acceleration_type" == "software" ]; then
|
||||||
true
|
true
|
||||||
elif [ "$acceleration_type" == "hardware" ]; then
|
elif [ "$acceleration_type" == "hardware" ]; then
|
||||||
if [ "$codec" == "h264" ]; then
|
args+=(-vaapi_device /dev/dri/renderD128)
|
||||||
args+=(-init_hw_device vulkan)
|
|
||||||
elif [ "$codec" == "av1" ]; then
|
|
||||||
args+=(-vaapi_device /dev/dri/renderD128)
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
args+=(-i "$file_to_cast")
|
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 [ "$codec" == "h264" ]; then
|
||||||
if [ "$acceleration_type" == "software" ]; then
|
if [ "$acceleration_type" == "software" ]; then
|
||||||
args+=(-c:v h264)
|
args+=(-c:v h264)
|
||||||
@ -126,7 +111,7 @@ function convert {
|
|||||||
args+=(-b:v "$VIDEO_BITRATE")
|
args+=(-b:v "$VIDEO_BITRATE")
|
||||||
elif [ "$acceleration_type" == "hardware" ]; then
|
elif [ "$acceleration_type" == "hardware" ]; then
|
||||||
args+=(-vf 'format=nv12|vaapi,hwupload')
|
args+=(-vf 'format=nv12|vaapi,hwupload')
|
||||||
args+=(-c:v h264_vulkan)
|
args+=(-c:v h264_vaapi)
|
||||||
args+=(-profile:v high)
|
args+=(-profile:v high)
|
||||||
args+=(-b:v "$VIDEO_BITRATE")
|
args+=(-b:v "$VIDEO_BITRATE")
|
||||||
fi
|
fi
|
||||||
@ -134,14 +119,12 @@ function convert {
|
|||||||
if [ "$acceleration_type" == "software" ]; then
|
if [ "$acceleration_type" == "software" ]; then
|
||||||
args+=(-c:v libsvtav1)
|
args+=(-c:v libsvtav1)
|
||||||
args+=(-preset 4) # [0-13] default 10, lower = higher quality / slower encode
|
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
|
# Parameters: https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Parameters.md
|
||||||
# fast-decode [0-2] default 0 (off), higher = faster decode
|
# 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]
|
# 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
|
# film-grain-denoise, setting to 0 uses the original frames instead of denoising the film grain
|
||||||
# rc 1 = vbr 2 = cbr
|
args+=(-svtav1-params "fast-decode=1:film-grain-denoise=0")
|
||||||
# tbr = average bitrate
|
|
||||||
args+=(-svtav1-params "fast-decode=1:film-grain-denoise=0:tbr=${VIDEO_BITRATE}:rc=1:passes=2")
|
|
||||||
elif [ "$acceleration_type" == "hardware" ]; then
|
elif [ "$acceleration_type" == "hardware" ]; then
|
||||||
# -c:v av1_amf -quality quality
|
# -c:v av1_amf -quality quality
|
||||||
args+=(-vf 'format=nv12|vaapi,hwupload')
|
args+=(-vf 'format=nv12|vaapi,hwupload')
|
||||||
@ -223,4 +206,32 @@ function encode_webcam {
|
|||||||
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
|
"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 "${@}"
|
main "${@}"
|
||||||
|
@ -131,7 +131,7 @@ in
|
|||||||
++ [
|
++ [
|
||||||
prev.rustup
|
prev.rustup
|
||||||
];
|
];
|
||||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
(lib.mkIf config.me.graphical {
|
(lib.mkIf config.me.graphical {
|
||||||
allowedUnfree = [
|
allowedUnfree = [
|
||||||
"vscode"
|
"vscode"
|
||||||
"vscode-x86_64-unknown-linux-gnu-with-extensions"
|
|
||||||
"vscode-with-extensions"
|
"vscode-with-extensions"
|
||||||
"vscode-extension-ms-vscode-remote-remote-ssh"
|
"vscode-extension-ms-vscode-remote-remote-ssh"
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user