From a3173f90b02526606ec24c0768d2b7597ec5b0d6 Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:02:31 +0300 Subject: [PATCH] write script to quickly re-encode videos from youtube inti H264 MP4 using VAAPI --- _sync.sh | 1 + ffmpeg.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 ffmpeg.sh diff --git a/_sync.sh b/_sync.sh index d368c29..fed666d 100755 --- a/_sync.sh +++ b/_sync.sh @@ -32,6 +32,7 @@ files=( "/usr/local/bin/scap:scap" "$HOME/docker.sh:docker.sh" "/usr/local/etc/X11/xinit/xinitrc.d/10-i3wm-kde-dark:X11/10-i3wm-kde-dark" + "$HOME/Videos/ffmpeg.sh:ffmpeg.sh" ) # create directories diff --git a/ffmpeg.sh b/ffmpeg.sh new file mode 100755 index 0000000..cc9a395 --- /dev/null +++ b/ffmpeg.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +input="$1" +output="$2" + +vaapi_device="/dev/dri/renderD128" +vaapi_codec="h264_vaapi" + +ffmpeg \ + -init_hw_device vaapi=foo:$vaapi_device \ + -hwaccel vaapi \ + -hwaccel_output_format vaapi \ + -hwaccel_device foo \ + -i "$input" \ + -filter_hw_device foo \ + -vf 'format=nv12|vaapi,hwupload' \ + -threads 4 \ + -c:v "$vaapi_codec" \ + -c:a aac \ + "$output"