Adding QSV and updating readme for it

hwip
Hugh Smalley 2 years ago
parent 1726c07bf1
commit c285782c84

@ -0,0 +1,27 @@
#!/bin/bash
set -o pipefail
IFS=$'\n\t'
for video; do
if [[ ! -f "${video}.json" ]]; then
ffprobe -v quiet -print_format json -show_streams "${video}" > "${video}.json"
fi
d=$(dirname "$video")
filename=$(basename "$video")
filename="${filename%.*}"
video_codec=$(jq -r '.streams[0].codec_name' < "${video}.json")
video_height=$(jq -r '.streams[0].height' < "${video}.json")
echo -e "${video} // ${video_codec} // ${video_height}"
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; then
_filename=$(echo "${filename}" | sed -e 's/h264/x265/g' -e 's/x264/x265/g' -e 's/AVC/x265/g' -e 's/XviD/x265/g').mkv
nice -n 19 ~/Downloads/ffmpeg/ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel qsv -hwaccel_output_format qsv -analyzeduration 20000000 -probesize 20000000 \
-i "${video}" -map 0:v -map 0:a -map 0:s? -map 0:d? -map 0:t? -c:s copy -c:a copy \
-vf 'scale_qsv=w=1920:1080' -c:v hevc_qsv -low_power false -preset 1 -profile:v 1 -scenario 3 -look_ahead 1 -global_quality 20 \
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/$_filename" || exit 1
mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
if [[ -f "${d}/${_filename}" ]]; then
cmp "${d}/${_filename}" "${video}" || rm -vf "${video}" "${video}.json"
ffprobe -v quiet -print_format json -show_streams "${d}/${_filename}" > "${d}/${_filename}.json"
fi
fi
done

@ -12,6 +12,17 @@ the NVIDIA in a few years, so it's kinda stale.
265_system is the one that you should use if you're going to use it.
265_qsv uses Intel Quick Sync to use your igpu.
You'll have to compile ffmpeg with the --enable-libmfx option to enable qsv support. I think jellyfin/emby include qsv with their builds too.
Adjust the -global_quality flag to change the quality. The lower the number the higher the bitrate. 20 seems to be a good balance of quality vs file size.
Here's the options I used to compile it and make qsv work for me:
```text
--enable-gpl --enable-version3 --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libmfx
```
I use it with parallel to do multiple files at once like this:
```shell
@ -23,4 +34,4 @@ end NAS devices.
YMMV // Caveat Emptor // And have an average day :|
-H
-H

Loading…
Cancel
Save