Convert file to AV1 using hw accel. - Printable Version +- Jellyfin Forum (https://forum.jellyfin.org) +-- Forum: Support (https://forum.jellyfin.org/f-support) +--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions) +--- Thread: Convert file to AV1 using hw accel. (/t-convert-file-to-av1-using-hw-accel) Pages:
1
2
|
Convert file to AV1 using hw accel. - goerdi - 2025-01-28 Hi ! I tried to convert a h264 file to AV1 using jellyfin ffmpeg and hw acceleration but its failed... the command was running bu i found no action on hw acceration (intel_gpu_top) and the file (h264 was abot 10 GB) had only 200 MB and conatined only the audio files... what wrong with the command: Code: /usr/lib/jellyfin-ffmpeg/ffmpeg -i ballon.1080p.mkv -init_hw_device vaapi=va:/dev/dri/renderD128 -c:v av1_qsv -preset veryslow -extbrc 1 -look_ahead_depth 40 -b:v 1M -bufsize 2M -rc_init_occupancy 512K -low_power 0 -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 7 -map 0:a? -c:a aac -b:a 64k -map 0:s? -c:s copy -fflags +nobuffer+discardcorrupt+genpts+flush_packets -avoid_negative_ts disabled ballon.av1.mkv Ciao Gerd RE: Convert file to AV1 using hw accel. - TheDreadPirate - 2025-01-28 You did not fully initialize the GPU. Nor did you construct the ffmpeg command properly. Parameter order matters and hardware initialization belong on the "input" side of the command. As in before "-i FILENAME". All parameters to the right of the input file are the "output" parameters. Move -init_hw_device to the left of your file input. Then add these parameters on the input side to fully initialize your GPU. Code: -filter_hw_device qs -hwaccel qsv -hwaccel_output_format qsv hwaccel = hardware DECODING. Without this it would CPU decode. Some codecs that are not supported by an Arc GPU would require you omit this parameter. Like VC1. hwaccel_output_format = hardware encoding. filter_hw_device qs = filters for QSV devices. Helpful if you also have AMD GPUs in the system. Wouldn't need to specify which render device if you only have one of each type. Since you are using "look_ahead_depth" you should also add this to the input side. Code: -extra_hw_frames 40 So the full command would be this. Code: /usr/lib/jellyfin-ffmpeg/ffmpeg -fflags +nobuffer+discardcorrupt+genpts+flush_packets -init_hw_device vaapi=va:/dev/dri/renderD128 -filter_hw_device qs -hwaccel qsv -hwaccel_output_format qsv -extra_hw_frames 40 -i ballon.1080p.mkv -c:v av1_qsv -preset veryslow -extbrc 1 -low_delay_brc 1 -look_ahead_depth 40 -b:v 1M -bufsize 2M -rc_init_occupancy 512K -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 7 -map 0:a? -c:a aac -b:a 64k -map 0:s? -c:s copy -max_muxing_queue_size 2048 -max_interleave_delta 0 -avoid_negative_ts disabled ballon.av1.mkv I also moved fflags to the input side. And "low_power" is not needed for AV1 since only H264 and HEVC have low power modes. I also added "max_muxing_queue_size 2048". This can help prevent some edge cases from causing ffmpeg to fail. "max_interleave_delta 0" also helps ensure that the output file is interleaved "evenly". Some files that are poorly muxed will have huge gaps in between tracks that can cause issues with some video players. The side effect is that some very poorly muxed files will cause ffmpeg to keep reading the file, storing it in memory, until it encounters all the tracks. If ffmpeg fails due to running out of memory you can try omitting max_interleave_delta. If your CPU's GPU is still enabled you may need to use renderD129 instead of 128. RE: Convert file to AV1 using hw accel. - goerdi - 2025-01-28 t Hi ! AFAIR i disabled internal GPU because i only have one render device (renderD12 and AV1 is working perfect w/p cpu load (my cpu is not av1 capable) your commend ends in: Invalid filter device qs. Failed to set value 'qs' for option 'filter_hw_device': Invalid argument Error parsing global options: Invalid argument I saw you also transcode audio... but i dont want to do this.. is it enough to throw -c:a aac -b:a 64k out on the output side ? Ciao Gerd RE: Convert file to AV1 using hw accel. - TheDreadPirate - 2025-01-28 Replace Code: -init_hw_device vaapi=va:/dev/dri/renderD128 with this Code: -init_hw_device qsv=qs@va This should work since your iGPU is disabled. We don't have to worry about ffmpeg selecting the iGPU. The ffmpeg command you provided include the audio transcode, so I figured that's what you wanted to do. Replace Code: -c:a aac -b:a 64k with this Code: -c:a copy If you don't include that it will transcode the audio. I forget what the output would default to if you don't specify anything. Code: /usr/lib/jellyfin-ffmpeg/ffmpeg -fflags +nobuffer+discardcorrupt+genpts+flush_packets -init_hw_device qsv=qs@va -filter_hw_device qs -hwaccel qsv -hwaccel_output_format qsv -extra_hw_frames 40 -i ballon.1080p.mkv -c:v av1_qsv -preset veryslow -extbrc 1 -low_delay_brc 1 -look_ahead_depth 40 -b:v 1M -bufsize 2M -rc_init_occupancy 512K -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 7 -map 0:a? -c:a copy -map 0:s? -c:s copy -max_muxing_queue_size 2048 -max_interleave_delta 0 -avoid_negative_ts disabled ballon.av1.mkv RE: Convert file to AV1 using hw accel. - goerdi - 2025-01-28 Hi ! Another failure Invalid device specification "qsv=qs@va": invalid source device name Failed to set value 'qsv=qs@va' for option 'init_hw_device': Invalid argument Error parsing global options: Invalid argument Ciao Gerd RE: Convert file to AV1 using hw accel. - TheDreadPirate - 2025-01-28 Had to look back at my script to see what I'm forgetting. Forgot to initialize the driver. Code: -init_hw_device vaapi=va:,driver=iHD,kernel_driver=i915 Code: /usr/lib/jellyfin-ffmpeg/ffmpeg -fflags +nobuffer+discardcorrupt+genpts+flush_packets -init_hw_device vaapi=va:,driver=iHD,kernel_driver=i915 -init_hw_device qsv=qs@va -filter_hw_device qs -hwaccel qsv -hwaccel_output_format qsv -extra_hw_frames 40 -i ballon.1080p.mkv -c:v av1_qsv -preset veryslow -extbrc 1 -low_delay_brc 1 -look_ahead_depth 40 -b:v 1M -bufsize 2M -rc_init_occupancy 512K -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 7 -map 0:a? -c:a copy -map 0:s? -c:s copy -max_muxing_queue_size 2048 -max_interleave_delta 0 -avoid_negative_ts disabled ballon.av1.mkv RE: Convert file to AV1 using hw accel. - goerdi - 2025-01-29 Hi ! i'm still confused... it runs through [out#0/matroska @ 0x5c887ae3c840] video:0KiB audio:4666089KiB subtitle:28868KiB other streams:0KiB global headers:0KiB muxing overhead: 0.106630% size= 4699963KiB time=02:05:17.24 bitrate=5121.8kbits/s speed= 565x -rw-r--r-- 1 gerd gerd 12530062186 Mär 9 2019 ballon.1080p.mkv -rw-rw-r-- 1 gerd gerd 4812761941 Jan 29 07:28 ballon.av1.mkv BUT it seems is only a file with audio :-( (also again not activity in intel_gpu_top) Do i need to setup which Codec the Input stream is ? in this case it would be 1080p H264 SDR It seems that codec is not regognized (see picture) Ciao Gerd RE: Convert file to AV1 using hw accel. - TheDreadPirate - 2025-01-29 We forgot to map the video. lol Code: -map 0:v You could also simply do this to map all input streams to the output file. You'd remove all the per stream type mappings and replace it with this. Code: -map 0 If you are specifying a mapping per stream type, you should also add this to ensure you also grab all the attachments, often fonts for text based subtitles. Code: -map 0:t? Code: /usr/lib/jellyfin-ffmpeg/ffmpeg -fflags +nobuffer+discardcorrupt+genpts+flush_packets -init_hw_device vaapi=va:,driver=iHD,kernel_driver=i915 -init_hw_device qsv=qs@va -filter_hw_device qs -hwaccel qsv -hwaccel_output_format qsv -extra_hw_frames 40 -i ballon.1080p.mkv -map 0:v -c:v av1_qsv -preset veryslow -extbrc 1 -low_delay_brc 1 -look_ahead_depth 40 -b:v 1M -bufsize 2M -rc_init_occupancy 512K -adaptive_i 1 -adaptive_b 1 -b_strategy 1 -bf 7 -map 0:a? -c:a copy -map 0:s? -c:s copy -map 0:t? -max_muxing_queue_size 2048 -max_interleave_delta 0 -avoid_negative_ts disabled ballon.av1.mkv RE: Convert file to AV1 using hw accel. - goerdi - 2025-01-29 Hi ! OK works... is this now a lossless conversation (video) ? btw: so you mean with -map 0 i get also rif of these messages ? [aost#0:2/copy @ 0x5615c47f5d80] Non-monotonic DTS; previous: 25563, current: 25556; changing to 25563. This may result in incorrect timestamps in the output file. BTW: additional question.... using pipe:0 as inputfile and pipe:1 as outputfile its then possible to transcode in tvheadend the tv stream on the fly ? Ciao Gerd RE: Convert file to AV1 using hw accel. - TheDreadPirate - 2025-01-29 (2025-01-29, 07:42 PM)goerdi Wrote: OK works... is this now a lossless conversation (video) ? No. I don't think there is a lossless mode for AV1. Least not with QSV. I believe HEVC and H264 software encoders have a lossless mode, but that creates HUGE files. For most videos, the parameters you used should cause little or no loss in perceivable quality. Some videos with a ton of film grain, av1_qsv struggles. (2025-01-29, 07:42 PM)goerdi Wrote: btw: so you mean with -map 0 i get also rif of these messages ? -map 0 tells ffmpeg to take all the input streams and send them to the output file. For the message you are referencing, my understanding is that this message caused by a difference in how the frames in original file was time stamped (DTS = decoding time stamp) vs how the new file is being time stamped. That message is almost always harmless, in my experience. (2025-01-29, 07:42 PM)goerdi Wrote: BTW: additional question.... using pipe:0 as inputfile and pipe:1 as outputfile its then possible to transcode in tvheadend the tv stream on the fly ? I have no idea. Sorry. |