====== FFmpeg ======
* examples https://jeremyrouet.medium.com/simple-commands-to-learn-ffmpeg-in-real-use-case-a53f4360efa7
* qsv params [[https://gist.github.com/nico-lab/58ac62e359bd63feed36af64db3e4406|gist]] \\
* install ffmep qsv https://gist.github.com/Brainiarc7/4f831867f8e55d35cbcb527e15f9f116 \\
* video for test http://ultravideo.fi/#testsequences
* ffmpeg QSV params - https://trac.ffmpeg.org/wiki/Hardware/QuickSync
* [[https://forum.videohelp.com/threads/392745-Kaby-Lake-Quick-Sync-quality-test|Example to encode to HEVC]]
* best presets to h264 [[https://streaminglearningcenter.com/wp-content/uploads/2019/05/SME-2019-FFmpeg-Hardware.pdf|h264]]
## FFMPEG
apt install ffmpeg
ffmpeg -decoders|Select-String "qsv"
ffmpeg -encoders|Select-String "qsv"
ffmpeg -hide_banner -h encoder=hevc_qsv
#--------- ASUS N750JK
#asus encode
ffmpeg -i .\akudama.mp4 -i .\akudama_240.mp4 -c:v h264_qsv -preset 1 -rdo 1 -global_quality 23 -bf 4 -refs 4 -g 250 "qsv_h264.mp4"
# asus dvd to mp4 decode
ffmpeg -i "concat:VTS_02_1.VOB|VTS_02_2.VOB|VTS_02_3.VOB" -c:v h264_qsv -preset 1 -rdo 1 -global_quality 20 -bf 4 -refs 4 -g 250 -c:a aac -b:a 192k -loglevel verbose d:\cosmetology.mp4
# decode in all sub directories files *.m2ts and save in one catalogue
for /R d:\recode %f in (*.m2ts) do ffmpeg -i "%f" -vf "yadif=1:-1:0" -c:v h264_qsv -preset 1 -rdo 1 -global_quality 20 -bf 4 -refs 4 -g 250 -c:a aac -b:a 192k -loglevel verbose "c:\tmp\encoded\%~nf.mp4"
# decode in all sub directories files *.mpg and save in one original catalogue
for /R "Y:\EOS\ФОТО\" %f in (*.mpg) do ffmpeg -i "%f" -vf "yadif=1:-1:0,hqdn3d=2:1:2" -c:v h264_qsv -preset 1 -rdo 1 -global_quality 24 -bf 4 -refs 4 -g 250 -c:a aac -b:a 192k -loglevel verbose "%~dpnf.mp4"
-------------------------------
# -------- modern CPU HEVC
# encode string H264 -> HEVC h265
ffmpeg -t:v 400 -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv -i .\emma.mp4 -vf hwupload=extra_hw_frames=64,format=qsv -c:v hevc_qsv -preset 1 -rdo 1 -global_quality 23 -mbbrc 1 -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 4 -refs 4 -g 250 -metadata:s:a language=eng -metadata creation_time=now -loglevel verbose "HEVC ICQ.mp4"
# encode finish string ----------------------------
ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv -i .\islrose.mp4 -vf hwupload=extra_hw_frames=64,format=qsv -c:v hevc_qsv -preset 3 -rdo 1 -global_quality 23 -mbbrc 1 -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 4 -refs 4 -g 250 -metadata:s:a language=eng -metadata creation_time=now -loglevel verbose "islrose_hevc.mp4"
#--------------------------------------------------
# examples https://kimathir.wordpress.com/2018/05/07/intel-qsv-encoding-coffee-lake/
#HEVC (10bit):
ffmpeg -i input.mp4 -load_plugin hevc_hw -c:v hevc_qsv -pix_fmt p010le -global_quality 25 -g 24 -c:a aac -b:a 192k -metadata:s:a language=eng -metadata creation_time=now -loglevel verbose hevc.mp4
#AVC:
ffmpeg -i input.mp4 -c:v h264_qsv -global_quality 25 -g 24 -c:a aac -b:a 192k -metadata:s:a language=eng -metadata creation_time=now -loglevel verbose avc.mp4
===== FFmpeg intel processor quick sync QSV =====
^ Generation ^ Codename (Lake) ^ Release Year ^
| 1st Gen | Nehalem | 2008 |
| 2nd Gen | Sandy Bridge | 2011 |
| 3rd Gen | Ivy Bridge | 2012 |
| 4th Gen | Haswell | 2013 |
| 5th Gen | Broadwell | 2014 |
| 6th Gen | Skylake | 2015 |
| 7th Gen | Kaby Lake | 2016 |
| 8th Gen | Kaby Lake R | 2017 |
| 9th Gen | Coffee Lake | 2018-2019 |
| 10th Gen | Comet Lake | 2019-2020 |
| 11th Gen | Tiger Lake | 2020-2021 |
| 12th Gen | Alder Lake | 2021 |
| 13th Gen | Raptor Lake | 2022 |
| 14th Gen | Meteor Lake | 2023 |
**Intel n100**
Intel N100 processor. The N100 belongs to the Alder Lake-N architecture and was launched in Q1 2023. Here are its key specifications:
Total Cores: 4
Total Threads: 4
Max Turbo Frequency: 3.40 GHz
Cache: 6 MB Intel® Smart Cache
TDP: 6 W
Memory Types: DDR4 3200 MT/s, DDR5 4800 MT/s
==== Ffmpeg support QSV ====
[[https://www.michaelstinkerings.org/gpu-virtualization-with-intel-12th-gen-igpu-uhd-730/| configure qsv 12th gen on proxmox lxc ]] \\
[[https://jellyfin.org/docs/general/administration/hardware-acceleration/intel|jellyfin configure QSV on intel]] [[https://trac.ffmpeg.org/wiki/Hardware/VAAPI|off wiki ffmpeg vaapi]] [[https://trac.ffmpeg.org/wiki/Hardware/QuickSync|off wiki QSV quick sync]] \\
[[https://github.com/intel/media-driver?tab=readme-ov-file#decodingencoding-features| intel decoding/encoding features ]] \\
:!:[[https://www.reddit.com/r/Proxmox/comments/14c8bpj/igpu_passthrough_for_intel_quick_sync/|igpu_passthrough_for_intel_quick_sync]]
=== Proxmox install ===
- on proxmox see in [[linux:proxmox|Linux.proxmox]] install [[https://www.derekseaman.com/2023/11/proxmox-ve-8-1-windows-11-vgpu-vt-d-passthrough-with-intel-alder-lake.html| alderlake ]]
- in lxc container(CT) configure like [[https://www.michaelstinkerings.org/gpu-virtualization-with-intel-12th-gen-igpu-uhd-730/| configure qsv 12th gen on proxmox lxc ]]
- inside CT upgrade and add jellifin repository and install jellyfin ffmpeg
# for N100 cpu use VAAPI not QSV
# get info abot VA
sudo vainfo --display drm --device /dev/dri/renderD128
env -u DRI_PRIME LIBVA_DRIVER_NAME=iHD vainfo --display drm --device /dev/dri/renderD128
cliinfo
intel_gpu_top -d sriov
ffmpeg -hwaccels
ffmpeg -hide_banner -encoders|grep h264
# https://trac.ffmpeg.org/wiki/Hardware/VAAPI
#Check ffmpeg
ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device opencl@va
# debug va
LIBVA_TRACE=/tmp/libva_trace.log DRI_PRIME=0 LIBVA_DRIVER_NAME=iHD ffmpeg -loglevel verbose -init_hw_device vaapi=/dev/dri/renderD128
echo $DRI_PRIME ${VDPAU_DRIVER:=unset} ${LIBVA_DRIVER_NAME:=unset}
#Example vaapi
ffmpeg -init_hw_device vaapi=foo:/dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device foo -i input.mp4 -filter_hw_device foo -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi output.mp4
# frame= 6348 fps=248 q=-0.0 size= 87040kB time=00:04:24.68 bitrate=2693.9kbits/s speed=10.3x
# codecs param
ffmpeg -help encoder=h264_vaapi
#example QSV
LIBVA_TRACE=/tmp/libva_trace.log DRI_PRIME=0 LIBVA_DRIVER_NAME=iHD /usr/lib/jellyfin-ffmpeg/ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -i input.mp4 -vf hwupload=extra_hw_frames=64,format=qsv -c:v h264_qsv -b:v 5M -maxrate 5M output.mp4
#frame= 1285 fps=122 q=19.0 Lsize= 33332kB time=00:00:53.50 bitrate=5103.5kbits/s speed=5.07x
#on host check stat of gpu
oot@pve:/usr/src/i915-sriov-dkms-6.5.13-3# intel_gpu_top -d sriov
intel-gpu-top: Intel Alderlake_n (Gen12) @ /dev/dri/card0 - 749/ 737 MHz; 0% RC6
1.11/12.68 W; 0 irqs/s
ENGINES BUSY MI_SEMA MI_WAIT
Render/3D 42.18% |███████████████████ | 0% 0%
Blitter 0.00% | | 0% 0%
Video 18.49% |████████▍ | 0% 0%
VideoEnhance 12.34% |█████▋ | 0% 0%
[unknown] 0.00% | | 0% 0%