Av1an
Av1an copied to clipboard
Complex ffmpeg filters fail
When encoding UHD HDR material into FHD SDR material one needs complex ffmpeg filters to do so; those are currently not compatible with av1an, at least not with the (currently) best chunk method available on linux (hybrid
):
Example:
av1an \
-e aom --passes 1 \
-m hybrid \
--split-method av-scenechange-fast \
--verbose \
--ffmpeg " -vf crop=3840:1920:0:120,scale=1920:-1:flags=spline,zscale=transfer=linear,tonemap=reinhard:param=0.38,zscale=transfer=bt709,zscale=primaries=bt709,zscale=matrix=bt709,format=yuv420p10le " \
-v " --good --end-usage=q --cq-level=30 --cpu-used=6 --bit-depth=10 --threads=8 --width=1920 --height=960" \
-a ' -c:a libopus -b:a 480k -mapping_family 1 -af aformat=channel_layouts="7.1|6.1|5.1|stereo|mono" ' \
-i test_uhd.mkv
Scene-detection runs normally. Audio gets encoded.
You are forced to enter the width and height manually, because aomenc demands them. OK, I'm rescaling the video, so that's a fair deal.
Then it will "start" encoding, but nothing happens. Just 1 blank frame (resolution 1920x960) is joined with the audio:
Scene detection
[00:00:32] [#########################################################################################] 100% 2892/2892 (88.08 fps, eta 0s)
Queue: 19 Workers: 8 Passes: 1
Params: --good --end-usage=q --cq-level=30 --cpu-used=6 --bit-depth=10 --threads=8 --width=1920 --height=960
[Worker 01] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 02] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 03] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 04] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 05] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 06] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 07] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[Worker 08] Pass 1/1 frame 0/0 0B 0 us 0.00 fpm [ETA unknown]
[00:00:17] [########################################################################################] 100% 2892/2892 (165.81 fps, eta 0s)
at least not with the (currently) best chunk method available on linux (hybrid):
best chunk method is lsmash
I think your filter is not correct, for example, pixel format should not be supplied by filter as there is explicit flags in av1an to control it,
And --width=1920 --height=960
should not be supplied to the encoder as it gets dimensions from piped source.
If you get width/height errors, it means that piping fails, probably from crahsing fillter
at least not with the (currently) best chunk method available on linux (hybrid):
best chunk method is lsmash
I have tried for hours and could not get lsmash or ffms2 to work on my Arch Linux.
I think your filter is not correct, and
--width=1920 --height=960
should not be supplied to encoder as it get's dimensions from piped source
The filter is correct when used with ffmpeg directly. I encoded >300 hrs material with it (UHD Remux => FHD SDR) using ffmpeg directly.
When you don't specificy the dimensions this happens. When you do, this happens. Leaving away the format=yuv420p10le
from the filter does not change anything.
Try installing this
community/vapoursynth R54-1
community/ffms2
community/vapoursynth-plugin-lsmashsource
After installing this packages vapoursynth should just work on arch
When you don't specify the dimensions this happens. When you do, this happens. Leaving away the format=yuv420p10le from the filter does not change anything
In both cases, the encoder crashes.
The filter is correct
This is how FFmpeg filter works in av1an. selecting frames from source, piping to FFmpeg filter -> applying FFmpeg filter, piping to encoder -> encoding. So it's not equal to encoding with FFmpeg, and have some constrains
@mxsrm if used in simple pipe like
ffmpeg -loglevel error -hide_banner -i test4k.mkv -strict -1 -f yuv4mpegpipe - | ffmpeg -hide_banner -loglevel error -i - -vf crop=3840:1920:0:120,scale=1920:-1:flags=spline,zscale=transfer=linear,tonemap=reinhard:param=0.38,zscale=transfer=bt709,zscale=primaries=bt709,zscale=matrix=bt709,format=yuv420p10le -strict -1 -pixel_format yuv420p10le -f null -
Filter gives error:
code 3074: no path between colorspaces
Error while filtering: Generic error in an external library
Failed to inject frame into filter network: Generic error in an external library
Error while processing the decoded data for stream #0:0
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
@master-of-zen You are absolutely right! I suspect this has to do with yuv4mpegpipe producing material with colorspace YUV.
Using the tonemap filters in the pipe fixes the errors:
ffmpeg -loglevel error -hide_banner -i chn.mkv -vf zscale=t=linear,tonemap=reinhard:param=0.38,zscale=t=bt709:p=bt709:m=bt709,format=yuv420p10le -strict -1 -f yuv4mpegpipe - | ffmpeg -hide_banner -loglevel error -i - -vf crop=3840:1920:0:120,scale=1920:-1:flags=spline -strict -1 -pixel_format yuv420p10le -c:v libx264 -preset veryfast -crf 10 test.mkv
So I guess one would need an additional parameter in av1an to add filters to the pipe?
if you can't make it work with FFmpeg filter that av1na have. 2 ways: use vapoursynth scrip with all filters and give it to av1an as input. transcode with your filters to lossless x264, and after that give it to av1an