master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.51k stars 155 forks source link

Av1an generates 2 (or more) extra frames on sources. #140

Closed RozeFound closed 4 years ago

RozeFound commented 4 years ago

I've seen this only on Geforce Experience generated videos. ConEmu64_Mvw5tXooGa

master-of-zen commented 4 years ago

@RozeFound can you send video, so I can examine that myself? :blush:

master-of-zen commented 4 years ago

Also does video have audio desync after encode is done? Try using aomenc, which is default encoder

RozeFound commented 4 years ago

There are 3 video, source, av1 encoded in ffmpeg, and av1 encoded in Av1an with rav1e encoder. And, yes, audio desync is expectedly. https://drive.google.com/file/d/1A-kRYEu_9nztOsImKNTfavhZ-IpFmLSq/view?usp=sharing I will try encode video in av1an with default encoder as soon as possible.

RozeFound commented 4 years ago

@master-of-zen encoding with aomenc have the same problem. I think problem exactly in Av1an.

master-of-zen commented 4 years ago

As works around I recommend use -s 0 which will disable splitting, and you will encode whole video with single instance of encoder

RozeFound commented 4 years ago

But it's much slower than with splitting... You don't know how to fix this? Without -s 0, encode speed is 2.7 frames per second, otherwise it is 1.3 frames per second...

EDIT: And this is not help. Problem is still exists. Even with -s 0.

n9Mtq4 commented 4 years ago

Often there are no new frames being added and instead it is an issue with the expected number of frames. Can you try getting a frame count of the source and the final encoded video with ffmpeg -i input.mkv -map 0:v:0 -c copy -f null - and see if they match?

RozeFound commented 4 years ago

@n9Mtq4 No, they not match. In source 712 frames, in encoded 723.

master-of-zen commented 4 years ago

@RozeFound does transcoding source to lossless x264 and later using av1an helps?

RozeFound commented 4 years ago

@master-of-zen Oh, I'm so sorry. I forgot one very important thing, it's not Geforce Experience generated video, it's video edited in Movavi, and saved in x264. And this video can't be encoded in av1an correctly. Original Geforce Experience generated video can be properly encoded into AV1 using av1an.

Fuchs4 commented 4 years ago

@RozeFound is it possible that your source has a variable framerate? Av1an decodes with ffmpeg and then pipes to the encoder. Pipes do not support variable framerates and ffmpeg automatically converts to a fixed framerate by dropping and duplicating frames. You can check for variable framerate with ffmpeg -i source.avi -vsync 1 -f null -. -vsync 1 forces a fixed framerate. ffmpeg will print dup= and drop= in its output if it had to duplicate or drop frames to achieve a fixed framerate.

krakow10 commented 4 years ago

I run shadowplay recordings through ffmpeg -r 60 -i shadowplay.mp4 -c copy 60fps.mkv to get rid of the variable framerate weirdness that goes all the way through to YouTube and appears as like 55fps if you don't fix it. I haven't seen audio desync problems when I do that but that is a possible issue with my fix

Fuchs4 commented 4 years ago

Sorry I missed your link. I checked it and it is variable framerate. The problem appears to be only in the first few frames, which appears to be quite common for screen recordings.

ffmpeg -r 60 -i shadowplay.mp4 -c copy 60fps.mkv

I would recommend using -vsync 1, that way you do not need to care which framerate the source is, ffmpeg can detect it automatically.

To fix this in av1an we would need to get rid of all pipes. That is only possible for encoders that are supported by ffmpeg and for chunking methods that use ffmpeg to read a chunk.

master-of-zen commented 4 years ago

Closing the issue, looks resolved