一、 Jellyfin硬件加速的问题
首先,Jellyfin是支持使用FFMpeg进行视频编码/解码的硬件加速(HWA)的。FFMpeg和Jellyfin可以通过视频加速API支持多种硬件加速实现,例如:
- VA-API是一个视频加速API,它使用libva与本地驱动程序接口用以提供HWA的支持
- QSV使用VA-API的修改(分支)版本,并将其与libmfx及其专有驱动程序连接
以下是官网提供的操作系统与推荐配置的接口
操作系统 | 推荐的硬件加速 |
---|---|
Linux | QSV、NVENC、AMF、VA-API |
Windows | QSV、NVENC、AMF |
MacOS | VideoToolbox |
Android | MediaCodec、OMX |
树莓派 | OMX |
使用HWA的显卡比较
显卡 | 支持的硬件加速 |
---|---|
nVidia | NVENC、VA-API |
AMD | AMF、VA-API |
Intel | QSV、VA-API |
Apple | VideoToolbox |
Other | OMX、MediaCodec |
核显在你的Linux系统是否正确的加载?
我的核显型号为:Intel UHD630,Intel在2017年就启动了Media SDK+相关的Linux图形堆栈/驱动程序开源项目。
组件 Repo 库名 libVA API Libva,libva-utils Libva*.so VAAPI Intel Driver Media-driver,GMMLib iHD_drv_video.so,igfxcmrt64.so Media SDK Library MediaSDK libmfxhw64.so and files under /opt/intel/mediasdk 下面以Ubuntun为例,做构建说明
1.1. 安装系统依赖
1
2
3# sudo apt-get -y install git libssl-dev dh-autoreconf cmake libgl1-mesa-dev libpciaccess-dev libelf-dev
# mkdir <path-to-working-directory>
# export WORKING_DIR=<path-to-working-directory>1.2. 固件的检查与更新
1.3. 重新编译libra和libdrm
基于prefix的不同配置,你可能需要更新LD_LIBRARY_PATH以便安装后可以找到库文件, 另外,记得首先移除其他的libdrm和libva版本。
1
2find /usr -name "libdrm*" | xargs rm -rf
find /usr -name "libva*" | xargs rm -rf重建和安装libdrm:
1
2
3
4
5
6cp /opt/intel/mediasdk/opensource/libdrm/*/libdrm-2.4.54.tar.bz2 .
tar xf libdrm-2.4.54.tar.bz2
cd libdrm-2.4.54
./configure --prefix=/usr/local
make
make install重建和安装libva:
1
2
3
4
5
6
7
8
9
10
11cd $WORKING_DIR
git clone https://github.com/intel/libva.git
git clone https://github.com/intel/libva-utils.git
cd $WORKING_DIR/libva
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
make -j4
sudo make install
cd $WORKING_DIR/libva-utils
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
make -j4
sudo make install注意: 请首先编译libdrm,因为libva依赖于libdrm
编译安装VAAPI Intel Driver
1
2
3
4
5
6
7
8
9
10
11
12
13
14cd $WORKING_DIR
git clone https://github.com/intel/media-driver.git
git clone https://github.com/intel/gmmlib.git
cd $WORKING_DIR/gmmlib
cd $WORKING_DIR/media-driver
cd $WORKING_DIR
mkdir -p build
cd $WORKING_DIR/build
cmake ../media-driver
make -j8
sudo make install
export LIBVA_DRIVER_NAME=iHD
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
vainfo编译安装MediaSDK
1
2
3
4
5
6
7cd $WORKING_DIR
git clone https://github.com/Intel-Media-SDK/MediaSDK.git
cd MediaSDK
mkdir build && cd build
cmake ..
make -j8
sudo make install设置必要的环境变量
1
2
3
4
5
6cd $WORKING_DIR
cd MediaSDK/build/__bin/release
export MFX_HOME=/opt/intel/mediasdk
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
export LIBVA_DRIVER_NAME=iHD
./sample_multi_transcode -i::h264 input.264 -o::h264 out.264怎么验证做了正确的转码设置?
要验证使用了正确的库,可以在控制台–>日志,或者终端下查看
/var/log/jellyfin
1
grep -A2 'Stream mapping:' /var/log/jellyfin/ffmpeg-transcode-85a68972-7129-474c-9c5d-2d9949021b44.txt
这返回了以下结果:
1
2
3Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))Stream #0:0
用软件解码HEVC(VAAPI Decode也可以说是native),用HWA编码1
2
3Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_mmal) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (flac (native) -> mp3 (libmp3lame))Stream #0:0
两者都使用HWA。h264_mmal解码,H264_omx编码
二、Jellyfin字幕方框字的问题
Jellyfin本地客户端解码导中文字幕显示方块解决方法
编辑mpv.conf,放到
/Users/用户名/Library/Application Support/Jellyfin Media Player/
目录中1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166# vim: syntax=config
###########
# General #
###########
save-position-on-quit
no-border # no window title bar
msg-module # prepend module name to log messages
msg-color # color log messages on terminal
term-osd-bar # display a progress bar on the terminal
use-filedir-conf # look for additional config files in the directory of the opened file
#pause # no autoplay
keep-open # keep the player open when a file's end is reached
autofit-larger=100%x95% # resize window in case it's larger than W%xH% of the screen
deinterlace=yes # 'auto' does not imply interlacing-detection
cursor-autohide-fs-only # don't autohide the cursor in window mode, only fullscreen
input-media-keys=no # enable/disable OSX media keys
cursor-autohide=1000 # autohide the curser after 1s
screenshot-format=png
screenshot-png-compression=8
screenshot-template='~/Desktop/%F (%P) %n'
hls-bitrate=max # use max quality for HLS streams
ytdl-raw-options=format="[protocol!=http_dash_segments][protocol!=rtmp]"
#########
# Cache #
#########
cache=yes
cache-default=81960 # size in KB BTW: before is 8000000 it is too big
cache-backbuffer=25000 # size in KB
cache-initial=0 # start playback when your cache is filled up with x kB
cache-secs=10 # how many seconds of audio/video to prefetch if the cache is active
#############
# OSD / OSC #
#############
osd-level=1 # enable osd and display --osd-status-msg on interaction
osd-duration=2500 # hide the osd after x ms
osd-status-msg='${time-pos} / ${duration}${?percent-pos: (${percent-pos}%)}${?vo-drop-frame-count:${!vo-drop-frame-count==0: Dropped: ${vo-drop-frame-count}}}\n${?chapter:Chapter: ${chapter}}'
osd-font='Source Sans Pro'
osd-font-size=32
osd-color='#CCFFFFFF' # ARGB format
osd-border-color='#DD322640' # ARGB format
#osd-shadow-offset=1 # pixel width for osd text and progress bar
osd-bar-align-y=0 # progress bar y alignment (-1 top, 0 centered, 1 bottom)
osd-border-size=2 # size for osd text and progress bar
osd-bar-h=2 # height of osd bar as a fractional percentage of your screen height
osd-bar-w=60 # width of " " "
#############
# Subtitles #
#############
sub-use-margins
sub-ass-force-margins
demuxer-mkv-subtitle-preroll # try to correctly show embedded subs when seeking
sub-auto=fuzzy # external subs don't have to match the file name exactly to autoload
sub-paths=ass:srt:sub:subs:subtitles # search for external subs in the listed subdirectories
embeddedfonts=yes # use embedded fonts for SSA/ASS subs
sub-fix-timing=no # do not try to fix gaps (which might make it worse in some cases)
sub-ass-force-style=Kerning=yes # allows you to override style parameters of ASS scripts
sub-font-size=48 # Font Size UPDATE: 2017-02-20
sub-codepage=utf8:gb18030 # for support Chinese
# the following options only apply to subtitles without own styling (i.e. not ASS but e.g. SRT)
sub-font="Noto Sans CJK SC Medium"
#sub-font-size=36
#sub-color="#FFFFFFFF"
#sub-border-color="#FF262626"
#sub-border-size=3.2
#sub-shadow-offset=1
#sub-shadow-color="#33000000"
#sub-spacing=0.5
#############
# Languages #
#############
#slang=enm,en,eng,de,deu,ger # automatically select these subtitles (decreasing priority)
#alang=en,eng,de,deu,ger # automatically select these audio tracks (decreasing priority)
#########
# Audio #
#########
audio-file-auto=fuzzy # external audio doesn't has to match the file name exactly to autoload
audio-pitch-correction=yes # automatically insert scaletempo when playing with higher speed
volume-max=200 # maximum volume in %, everything above 100 results in amplification
volume=100 # default volume, 100 = unchanged
################
# Video Output #
################
# Active VOs (and some other options) are set conditionally
# See here for more information: https://github.com/wm4/mpv-scripts/blob/master/auto-profiles.lua
# The script was slightly modified, functions from scripts/auto-profiles-functions.lua are imported
# Defaults for all profiles
vo=opengl
tscale=linear
[high-quality]
profile-desc=cond:is_desktop() and get('width', math.huge) < 3840
scale=ewa_lanczossharp
cscale=ewa_lanczossoft
dscale=mitchell
scale-antiring=0.7
cscale-antiring=0.7
dither-depth=auto
correct-downscaling=yes
sigmoid-upscaling=yes
deband=yes
[mid-quality]
profile-desc=cond:(is_laptop() and not on_battery() and get('width', math.huge) < 1920) or (is_desktop() and get('width', math.huge) >= 3840)
scale=spline36
cscale=bilinear
dscale=mitchell
scale-antiring=1.0
cscale-antiring=1.0
dither-depth=auto
correct-downscaling=yes
sigmoid-upscaling=yes
deband=yes
[low-quality]
profile-desc=cond:is_laptop() and (on_battery() or get('width', math.huge) >= 1920)
scale=bilinear
cscale=bilinear
dscale=bilinear
scale-antiring=0.0
cscale-antiring=0.0
dither-depth=no
correct-downscaling=no
sigmoid-upscaling=no
deband=no
[60FPS]
profile-desc=cond:is_laptop() and get('container-fps', 0) >= 59
scale=bilinear
cscale=bilinear
[4K]
profile-desc=cond:get('width', -math.huge) >= 3840
vd-lavc-threads=32
[4K-inverted]
profile-desc=cond:get('width', -math.huge) < 3840
vd-lavc-threads=0
[default]
###################################
# Protocol Specific Configuration #
###################################
[protocol.https]
#cache=yes
#cache-default=500000 # size in KB
#cache-backbuffer=250000 # size in KB
cache-secs=100 # how many seconds of audio/video to prefetch
user-agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0'
[protocol.http]
#cache=yes
#cache-default=500000 # size in KB
#cache-backbuffer=250000 # size in KB
cache-secs=100 # how many seconds of audio/video to prefetch
user-agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0'
[extension.gif]
cache=no
no-pause
loop-file=yes
[extension.webm]
#cache=no
#no-pause
#loop-file=yes需要安装字体:NotoSansCJKsc-Medium.otf.zip