initial commit

This commit is contained in:
2023-12-20 17:08:11 -05:00
commit c93f1c1a05
5 changed files with 121 additions and 0 deletions

10
LICENSE Normal file
View File

@@ -0,0 +1,10 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
README.md Normal file
View File

@@ -0,0 +1 @@
# transcode-video

21
default.nix Normal file
View File

@@ -0,0 +1,21 @@
{ stdenv, pkgs, ... }:
let
transcode-animated-video = with pkgs; writeShellApplication {
name = "transcode-animated-video.sh";
runtimeInputs = [ ffmpeg ];
text = builtins.readFile ./transcode-animated-video.sh;
};
transcode-organic-video = with pkgs; writeShellApplication {
name = "transcode-organic-video.sh";
runtimeInputs = [ ffmpeg ];
text = builtins.readFile ./transcode-organic-video.sh;
};
in {
environment.systemPackages = [
transcode-animated-video
transcode-organic-video
];
}

View File

@@ -0,0 +1,45 @@
# CLI arguments
input_video=$1
output_video=$2
# Get video pixel format
video_pix_fmt=$(ffprobe -v error \
-select_streams v:0 \
-show_entries stream=pix_fmt \
-of flat "$input_video" \
| sed 's/\"//g' \
| awk -F= '{ print $2 }')
# Set transcode profile based on pixel format
case $video_pix_fmt in
yuv420p10le)
video_profile="main444-10"
;;
yuv420p12le)
video_profile="main444-12"
;;
yuvj420p)
video_profile="main444-8"
;;
*)
video_profile="main444-8"
;;
esac
# Transcode video
ffmpeg -v info -hide_banner -i "$input_video" \
-progress - \
-nostats \
-preset slow \
-tune animation \
-c:s copy \
-c:a copy \
-c:v libx265 \
-profile:v $video_profile \
-crf 36 \
"$output_video"

View File

@@ -0,0 +1,44 @@
# CLI arguments
input_video=$1
output_video=$2
# Get video pixel format
video_pix_fmt=$(ffprobe -v error \
-select_streams v:0 \
-show_entries stream=pix_fmt \
-of flat "$input_video" \
| sed 's/\"//g' \
| awk -F= '{ print $2 }')
# Set transcode profile based on pixel format
case $video_pix_fmt in
yuv420p10le)
video_profile="main444-10"
;;
yuv420p12le)
video_profile="main444-12"
;;
yuvj420p)
video_profile="main444-8"
;;
*)
video_profile="main444-8"
;;
esac
# Transcode video
ffmpeg -v info -hide_banner -i "$input_video" \
-progress - \
-nostats \
-preset medium \
-c:s copy \
-c:a copy \
-c:v libx265 \
-profile:v $video_profile \
-crf 27 \
"$output_video"