Coder Social home page Coder Social logo

x264 lossless about libtas HOT 21 CLOSED

clementgallet avatar clementgallet commented on July 23, 2024
x264 lossless

from libtas.

Comments (21)

clementgallet avatar clementgallet commented on July 23, 2024 1

Thanks! That was pretty much what I was doing before. Now I'm putting packet into a Nut container using code from Bizhawk, so there is no more ffmpeg API code. I'm quite happy with this solution actually, because I know I won't have to dig into the code every 6 months when ffmpeg people deprecate, remove functions and add new ones all the time.

EDIT: I tested the settings from your first post, and it works correctly afaik.

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

I added two fields in the Encoding Options to set codec-specific options (77ee8c1). The format is: key1=value1:key2=value2:etc. Also, you should remove the - from the key name, so your example becomes (for the relevant part): qp=0:preset=ultrafast. You can verify on the console the codec settings that ffmpeg is printing when the encode is starting. You'll also see if an option wasn't recognized.

I didn't check how Bizhawk is using ffmpeg, I'm using the ffmpeg API (avcodec/avformat/avutil) and feeding the raw images/waveforms.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

BTW, Mari0 dump reports 600fps, while the game actually runs at 60, and the video just has 10 dup frames for every unique frame (Mediainfo reports 600, but media players advance frames like it's 60). I suspected that it overshoots the dumping procedure due to some odd behavior of the game engine. Could you check this?

Another thing we noticed, it uses subsampling (to 420) for ffv1, which makes it lossy. Does it look preventable? From looking at the docs, maybe Qt sends -level 3 (whch means ffv1 version 3 instead of 1) and mistakenly uses wrong colorspace? We need ffv1 version 1 here.

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

About mari0, I correctly get a 60 fps (ish) video as reported by mediainfo. What are your settings ?

Indeed, ffvi seems to switch to yuv440. What I'm currently doing is checking if the pixel format of the stored images (usually rgba) is compatible with the codec, and if not, I let ffmpeg choose the codec preferred pixel format. I could override this to choose rgb specifically for ffvi codec.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

Can you check what VirtualDub says? Here are the dumps fsvgm777 got: https://yadi.sk/d/nnShqYmX3a92eV

from libtas.

fsvgm777 avatar fsvgm777 commented on July 23, 2024

Hi, the dumps I made were with software rendering disabled. I believe I didn't touch any setting at all (and well, I can't do a whole lot in the encoding configuration dialog box, since there's only a field for encode file path as well as drop-down menus for video and audio codec (+ bitrate if it's a lossy codec).

EDIT: Forgot to mention the game is mari0, a game made on the Lรถve framework.

EDIT 2: The movie framerate is set at 60 FPS.

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

From what I am reading, the muxer can override the video codec specified framerate to choose a "better one", so this is why I usually end up with a 1000 fps video, maybe this is also what is happening to you. However, I'm taking this into account during the encode so the timestamp for the video frames should be correct. I'll look again into the ffmpeg muxer if I can override this override, but really this API is a mess.

EDIT: To be more precise, I'm setting AVCodecContext.time_base to 1/60, and at some point AVStream.time_base is set to 1/1000.

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

I found the right parameter, which actually fills the framerate in the file header (9f9e008). Could you test again with this change ?

from libtas.

fsvgm777 avatar fsvgm777 commented on July 23, 2024

Just tested, and it still reports a frame rate of 600 FPS. I also noticed a regression: It dumps a lot slower than before.

I also tested x264 RGB lossless, but alas, it doesn't take any arguments from ffmpeg, just the codec-specific options, so it defaults to yuv420p. It did correctly process the other codec options, though.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

For AVI file, framerate is set by writing to 2 fields of AVIFILEINFOW: dwRate (numerator) and dwScale (denominator).

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

Now I choose BGR0 pixel format by default, for codecs that accept it (af6f0e8). Now FFV1 dumps in RGB colorspace.

It dumps slower by just changing a field in the header ? OK. You are using Arch right ? I could set it up on a VM to see if I can reproduce it.

libx264rgb seems broken to me also. It chooses nv21 pixel format (basically yuv420) even if it is supposed to only accept bgr24, bgr0 and rgb24 formats.

EDIT: Also, I'm testing with LOVE 11.1 and the latest mari0 commit

from libtas.

fsvgm777 avatar fsvgm777 commented on July 23, 2024

Nope, I'm using a Kubuntu 18.04 VM (with everything updated).

What I did notice is that in the terminal output, it states the framerate is 0.02 FPS (when in reality, the resulting dump is at 600 FPS):
Output #0, avi, to '/home/fsvgm777/libTAS/build/loveffv1.avi':
Stream #0:0: Video: ffv1, bgr0, 800x448, q=2-31, 4000 kb/s, 0.02 fps
Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s

This is the only thing related to the recent change. It dumped about as fast as the game ran before the change.

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

Oh, you are using AVI container. Indeed, I'm getting the same problems as you with this container.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

In theory, it's possible to process mp4 and mkv dumps, but avi is just our odious legacy container that works the best with avisynth (which is also an odious legacy thing, and we hope to move away from it).

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

I'm going to drop the current solution and feed data to a ffmpeg process instead, like Bizhawk is doing. This should solve most of the problems by translating most of the work to ffmpeg (or least make it easier to debug), and also would not require users to use a specific version of the librairies as ffmpeg API is constantly changing.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

Oh wow! Thank you for this decision! ffmpeg supports basically endless variety of workflows, and we already now several that work for our "odious legacy" needs. And just as easily, it supports all the modern stuff like direct vp9+webm output, And indeed this removes the unhelpful wrapper layer where we have to really please Qt first if we want something to be told over to ffmpeg. Which, as we've learned yesterday, doesn't feel like hearing us out in the first place. Best of luck with reimplementation, we have a lot of test cases for this!

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

Almost done with the rewriting. I just have one problem: the file is not written on disk, despite ffmpeg telling that it is written. I think this is because ffmpeg is called from a forked process, and the fork process is also getting the libTAS preload with all the function hooks, which probably is messing with ffmpeg file writing.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

We need @nattthebear here!

from libtas.

nattthebear avatar nattthebear commented on July 23, 2024

I agree with your assessment, it sounds like you want to avoid the consequences of fork in this situation, but I don't know what you'd use to do it in linux; is there something like posix_spawn that also lets you redirect stdioerr?

from libtas.

clementgallet avatar clementgallet commented on July 23, 2024

I managed to unset LD_PRELOAD, which surprisingly worked (881c48d). Now encoding to raw video/audio seems to work. I have trouble with vorbis codec which puts audio out of place despite pts looking ok.

from libtas.

vadosnaprimer avatar vadosnaprimer commented on July 23, 2024

For the reference, here's what dolphin is doing. Dunno if it's applicable here tho:
https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/AVIDump.cpp#L298

from libtas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.