diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2024-11-21 10:04:34 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2024-11-21 10:05:04 +0100 |
| commit | 59297cbd2a6a5c78f131e3b1a8c60710198f5213 (patch) | |
| tree | 55af1f12903d58bb11556a9f18f46428b5d055d8 /local/bin/video-to-h264 | |
| parent | 01f55c6e0a6005bbb051246cd08af49e09fd137c (diff) | |
| download | dotfiles-59297cbd2a6a5c78f131e3b1a8c60710198f5213.tar.gz dotfiles-59297cbd2a6a5c78f131e3b1a8c60710198f5213.tar.bz2 dotfiles-59297cbd2a6a5c78f131e3b1a8c60710198f5213.zip | |
Fixing shellcheck errors
Diffstat (limited to 'local/bin/video-to-h264')
| -rwxr-xr-x | local/bin/video-to-h264 | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/local/bin/video-to-h264 b/local/bin/video-to-h264 new file mode 100755 index 0000000..8b4d21b --- /dev/null +++ b/local/bin/video-to-h264 @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +file_path="$1" + +# from: https://stackoverflow.com/questions/2869281/how-to-determine-video-codec-of-a-file-with-ffmpeg +current_codec="$( + ffprobe -v error -select_streams v:0 \ + -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 \ + "$file_path" +)" +[ "$current_codec" = 'h264' ] && { echo 'Video is already in h264'; exit 1; } + +# CUDA options: -hwaccel cuda -hwaccel_output_format cuda -c:v h264_nvenc +# seems slower on gpu tho +# There is also -c:v hvec_nvenc +# +# Options to reduce size: -b:v 5M -crf 28 + +ffmpeg -i "$file_path" \ + -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy \ + "${file_path%%.*}-h264.${file_path##*.}" |
