fellyfin转码
/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -probesize 1G \
-init_hw_device vaapi=va:/dev/dri/renderD128,driver=i965 -hwaccel vaapi \
-hwaccel_output_format vaapi -noautorotate -i file:"视频地址.mp4" \
-noautoscale -map_metadata -1 -map_chapters -1 -threads 4 \
-map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -rc_mode CBR \
-b:v 4878391 -maxrate 4878391 -bufsize 9756782 -profile:v:0 \
constrained_baseline -level 30 -sei -a53_cc -force_key_frames:0 "expr:gte(t,n_forced*3)" \
-vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,\
scale_vaapi=format=nv12:extra_hw_frames=24" -codec:a:0 copy \
-copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 \
-f hls -max_delay 5000000 -hls_time 3 -hls_segment_type fmp4 \
-hls_fmp4_init_filename "11b85c58297c75e7fa2ed9dddf7cdfc5-1.mp4" \
-start_number 0 -hls_segment_filename "/cache/transcodes/11b85c58297c75e7fa2ed9dddf7cdfc5%d.mp4" \
-hls_playlist_type vod -hls_list_size 0 -y "/cache/transcodes/11b85c58297c75e7fa2ed9dddf7cdfc5.m3u8"
这是个转码
jellyfin日志中找的的
然后可以把 -codec:a:0 copy
后面的全删了,因为全是为了生成 hls
流媒体的
-analyzeduration 200M -probesize 1G
可以删除,因为是用来限制系统资源使用量的
-threads 4
可以改成8甚至更高
/usr/lib/jellyfin-ffmpeg/ffmpeg -init_hw_device vaapi=va:/dev/dri/renderD128,driver=i965 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i file:"视频地址.mp4" -noautoscale -map_metadata -1 -map_chapters -1 -threads 8 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -rc_mode CBR -b:v 4878391 -maxrate 4878391 -bufsize 9756782 -profile:v:0 constrained_baseline -level 30 -sei -a53_cc -force_key_frames:0 "expr:gte(t,n_forced*3)" -vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_vaapi=format=nv12:extra_hw_frames=24" -codec:a:0 copy "视频地址-1080p.mp4"
然后可以用 screen -S
加个name运行
执行
docker exec -it jellyfin bash
再运行上上的指令加 &
只有 ssh
断开也可以继续执行了
当然直接 nohup
加上上面全部的指令也行
可以通过 cat nohup.out
查看输出的进度
比如说
nohup docker exec -it jellyfin \
/usr/lib/jellyfin-ffmpeg/ffmpeg \
-init_hw_device vaapi=va:/dev/dri/renderD128,driver=i965 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate \
-i file:"视频地址.mp4" -noautoscale -map_metadata -1 -map_chapters -1 -threads 8 -map 0:0 -map 0:1 -map -0:s \
-codec:v:0 h264_vaapi -rc_mode CBR -b:v 4878391 -maxrate 4878391 -bufsize 9756782 -profile:v:0 constrained_baseline \
-level 30 -sei -a53_cc -force_key_frames:0 "expr:gte(t,n_forced*3)" \
-vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_vaapi=format=nv12:extra_hw_frames=24" \
-codec:a:0 copy "视频地址-1080p.mp4"
cat nohup.out
又比如说
screen -S 001
docker exec -it jellyfin bash
/usr/lib/jellyfin-ffmpeg/ffmpeg \
-init_hw_device vaapi=va:/dev/dri/renderD128,driver=i965 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate \
-i file:"视频地址.mp4" -noautoscale -map_metadata -1 -map_chapters -1 -threads 8 -map 0:0 -map 0:1 -map -0:s \
-codec:v:0 h264_vaapi -rc_mode CBR -b:v 4878391 -maxrate 4878391 -bufsize 9756782 -profile:v:0 constrained_baseline \
-level 30 -sei -a53_cc -force_key_frames:0 "expr:gte(t,n_forced*3)" \
-vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_vaapi=format=nv12:extra_hw_frames=24" \
-codec:a:0 copy "视频地址-1080p.mp4" &
screen -d
screen -ls
screen -r 001
...
呃。。。scale_vaapi=format=nv12会让fellyfin还是会继续转码。。。生成的MP4。。。
/usr/lib/jellyfin-ffmpeg/ffmpeg \
-init_hw_device vaapi=va:/dev/dri/renderD128,driver=i965 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate \
-i file:"视频地址.mp4" \
-vf "scale_vaapi=-1:1080" \
-codec:a:0 copy "视频地址-1080p.mp4"
只需要改下分辨率。。。码率无所谓了,毕竟到1080P基本上都在5mpbs以内了
推荐阅读:
扫描二维码,在手机上阅读