Av1an
Av1an copied to clipboard
FPS of the encoded video is wrong
Hi! I encode a bunch of videos which video FPS is 24, but the encoded ones have FPS 24.122. The only way to change it back is by using MKVToolNix GUI, which is very inconvenient.
The command I am using is following:
docker run --privileged -v /REDACTED:/videos --user 1000:1000 -it --rm masterofzen/av1an:latest -i a.mkv -s mats -l logfile -o a30.mkv -e aom -c mkvmerge -a ' -an ' -v ' --cpu-used=4 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --enable-fwd-kf=1 --lag-in-frames=35 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0 --enable-dnl-denoising=0 --denoise-noise-level=8 ' --vmaf --resume
This seems like an issue specific to the source. Possibly it's VFR? You should be able to check if it's constant or variable frame rate with a tool such as MediaInfo.
The source is not VFR. And I have this issue with different sources...
Frame rate mode : Constant
Frame rate : 24.000 FPS
It seems, if I remove -s option and change -c from mkvmerge to ffmpeg the framerate is correct
mkvmerge will be more correct than ffmpeg about true average framerate 99% of the time, but if you only want to show nominal framerate, you can get that with ffmpeg or some other options in mkvmerge. Note that your conclusion that the source is not VFR isn't verifiable, because mediainfo prefers the nominal framerate and only shows a true average framerate if you do a deep scan of the file. (That's obviously a mediainfo statistic.)
You need some kind of log of different framecounts between the mkvmerge and ffmpeg to verify that they are, in fact, actually different in any way other than how mediainfo reports them.
Ok, so did some testing with 10 second long video... The only difference was -c
option. ivf
outputs a video with 30FPS, ffmpeg
crashes, and mkvmerge
outputs a video with variable 24.302 FPS... Neither seems to be correct because audio and subtitles (after encoding an original long video) are out of sync and the final length of the video is different.
Here is the output of all commands. ivf:
Scene detection
[00:00:00] [###########################################################################################################################################] 100% 242/242 (306.70 fps, eta 0s)
Queue: 3 Workers: 3 Passes: 2
Params: --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0
[00:00:28] [#############################################################################################################################################] 100% 242/242 (8.34 fps, eta 0s)
ffmpeg:
docker run --privileged -v "$(pwd):/videos" --user $(id -u):$(id -g) -it --rm masterofzen/av1an:latest -i aa10.mkv -l logfile -o aa10g.mkv -e aom -c ffmpeg -a ' -an ' -v ' --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0 ' --keep
Scene detection
[00:00:01] [###########################################################################################################################################] 100% 242/242 (222.06 fps, eta 0s)
Queue: 3 Workers: 3 Passes: 2
Params: --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0
[00:00:28] [#############################################################################################################################################] 100% 242/242 (8.36 fps, eta 0s)
thread 'main' panicked at 'FFmpeg failed with output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "[matroska,webm @ 0x727a340] Duplicate element\n[matroska,webm @ 0x727a340] 0x00 at pos 110 (0x6e) invalid as first byte of an EBML number\n[matroska,webm @ 0x727a340] Duplicate element\n[matroska,webm @ 0x727a340] 0x00 at pos 204 (0xcc) invalid as first byte of an EBML number\n[matroska,webm @ 0x727a340] Element at 0x67 ending at 0x171ec0100006f exceeds containing master element ending at 0x1413\n/videos/.3d50ffa/audio.mkv: End of file\n" }
Command: "ffmpeg" "-y" "-hide_banner" "-loglevel" "error" "-f" "concat" "-safe" "0" "-i" "/videos/.3d50ffa/concat" "-i" "/videos/.3d50ffa/audio.mkv" "-c" "copy" "-c" "copy" "aa10g.mkv"', av1an-core/src/concat.rs:267:3
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mkv:
docker run --privileged -v "$(pwd):/videos" --user $(id -u):$(id -g) -it --rm masterofzen/av1an:latest -i aa10.mkv -l logfile -o aa10h.mkv -e aom -c mkvmerge -a ' -an ' -v ' --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0 ' --keep
Scene detection
[00:00:01] [###########################################################################################################################################] 100% 242/242 (230.96 fps, eta 0s)
Queue: 3 Workers: 3 Passes: 2
Params: --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0
[00:00:28] [#############################################################################################################################################] 100% 242/242 (8.34 fps, eta 0s)
All IVFs (in temporary folder) for all runs have FPS of 24.
Do you have the ability to upload a source which is having this issue? I'd like to see if I can reproduce it as well. And if there's something av1an can do to handle it better.
@shssoichiro https://ufile.io/t1uh3fue
That's a vfr video encode with cbr ac3 audio. That aside using below with mkvmerge and ffmpeg both encode just fine.
av1an -i "aa10.mkv" --verbose --split-method av-scenechange -m lsmash -e aom -v " --threads=2 --cpu-used=4 --lag-in-frames=48 --kf-max-dist=240 --kf-min-dist=12 --arnr-strength=3 --enable-fwd-kf=1 --quant-b-adapt=1 --enable-chroma-deltaq=1 --min-q=1 --enable-qm=1 --qm-min=0 --tile-columns=1 --tile-rows=1 " --pix-format yuv420p10le -f " " -a " -c:a libopus -b:a:1 128k -ac:1 2 " -s aa10.csv --set-thread-affinity=2 -w 14 -o "aa10_AV1-ffmpeg.mkv"
Have you cut that file yourself from the full movie using mkvmerge ?
@menditsa
I cut it myself with ffmpeg (-t 10
), but I do not think it is relevant here, as the problems also occur with this exact video. IMO two things that may make a difference are: you keep audio and you do not use the version from docker.
I would try if the latest version work but i cannot because of #426 and if I build it myself without docker it crashes with a segfault.
Have you built the docker container yourself, or are you using the one from docker hub? If you build the container yourself from the latest git of this repo, it should be up to date.
I don't keep the ac3 audio, I change to opus ;) I use arch running on win 11 with wsl2 and also bare metal arch. Both work fine on that clip. Any reason for using docker ?
Any reason for using docker ?
without docker it crashes with a segfault.
Have you built the docker container yourself
Nope, I use masterofzen/av1an:latest
. If I build it myself I get #426 :
docker run --privileged -v "$(pwd):/videos" --user $(id -u):$(id -g) -it av1an:latest -i aa10.mkv -l logfile -o aa10k.mkv -e aom -c mkvmerge -a ' -an ' -v ' --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0 ' --keep
Scene detection
00:00:04 [##################################################################################] 100% 242/242 (52.41 fps, eta 0s)
Queue 4 Workers 4 Passes 2
Params: --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0
⠤ 00:00:19 [#########################>---------------------------------------------------------] 30% 73/242 (3.38 fps, eta 50s)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ffmpeg::Error(1381258232: Stream not found)', av1an-core/src/broker.rs:250:70
⠒ 00:00:28 [#######################################################>--------------------------] 67% 163/242 (5.55 fps, eta 14s)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ffmpeg::Error(1381258232: Stream not found)', av1an-c⠐ 00:00:41 [###########################################################################>-------] 91% 221/242 (5.32 fps, eta 4s)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ffmpeg::Error(1381258232: Stream not found)', av1an-c⠂ 00:00:54 [###################################################################################] 100% 242/242 (4.60 fps, eta 0s)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ffmpeg::Error(1381258232: Stream not found)', av1an-core/src/broker.rs:250:70
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', av1an-core/src/broker.rs:178:35
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', av1an-core/src/settings.rs:1049:21
@menditsa I meant leaving the audio out (-an
)
Can you try to use same parameters I use?
-i aa10.mkv -l logfile -o aa10k.mkv -e aom -c mkvmerge -a ' -an ' -v ' --cpu-used=7 --end-usage=q --cq-level=30 --threads=4 --arnr-strength=4 --bit-depth=10 --lag-in-frames=35 --enable-fwd-kf=1 --kf-max-dist=240 --max-partition-size=64 --enable-qm=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --tile-columns=1 --tile-rows=0 ' --keep
worked fine, took 13 seconds.
And the frame rate is 24p?
yes
@se17p If av1an crashes with a segfault, it basically means that there is some kind of ABI mismatch for dynamically linked libraries. Make sure that vapoursynth and ffmpeg are both correctly installed and up to date. You can also try building with cargo build --release --feature ffmpeg_static
to statically link ffmpeg. If the issue still persists, then it is an issue with your vapoursynth installation.
@redzic I still get "Segmentation fault". Is there a way to get more informative error message? Do I need to install any extra vapoursynth packages, e.g. filters?
I have the... opposite problem. My original fps is 30.04(my phone records it like that), but after encoding it, it became 30. I've tried ivf
(straight up extreme crash) mkvmerge
and ffmpeg
both yielded the same result.
I've also tried setting chunk method to lsmash
, there is also no help.
extreme crash by ivf
ERROR [av_ivf::demuxer] error reading headers: Error(Error { input: [26, 69, 223, 163, 159, 66, 134, 129, 1, 66, 247, 129, 1, 66, 242, 129, 4, 66, 243, 129, 8, 66, 130, 132, 119, 101, 98, 109, 66, 135, 129, 4, 66, 133, 129, 2, 24, 83, 128, 103, 1, 0, 0, 0, 0, 6, 61, 104, 17, 77, 155, 116, 186, 77, 187, 139, 83, 171, 132, 21, 73, 169, 102, 83, 172, 129, 110, 77, 187, 139, 83, 171, 132, 22, 84, 174, 107, 83, 172, 129, 164, 77, 187, 139, 83, 171, 132, 31, 67, 182, 117, 83, 172, 129, 204, 77, 187, 141, 83, 171, 132, 28, 83, 187, 107, 83, 172, 131, 6, 61, 54
this is not complete log, there are more numbers but you get what I mean