FFMS / ffms2

An FFmpeg based source library and Avisynth/VapourSynth plugin for easy frame accurate access
Other
576 stars 104 forks source link

HW acceleration with ffms #337

Closed Vpstr closed 5 years ago

Vpstr commented 5 years ago

Hello! I'm running an avisynth script which uses ffms source filters and I extremely need the filters to do the hardware acceleration while running. Is this possible in some way? I thought I could recompile ffms with HWA-enabled ffmpeg, but as ffmpeg is not using HWA automatically and I assume the filter doesn't tell it to, I don't think it makes sense.

myrsloik commented 5 years ago

We've never tested doing it. It will probably expose a whole new set of exciting bugs if we enable it...

Vpstr commented 5 years ago

Still I want to give it a try. Can I do it by myself without programming or it requires you to make changes in the code?

Vpstr commented 5 years ago

Hello there! I want to get some answer here.

myrsloik commented 5 years ago

Can I do it by myself without programming? - obviously not, you're asking here Does it requires you to make changes in the code? - yes

dwbuiten commented 5 years ago

It requires quite a bit of extra work, to use HWAccel'd AVFrames, with specialized paths for every hwaccel. I don't forsee any of the current FFMS2 devs wanting to put in that amount of work. Patches welcome...

See ffmpeg_hw.c, ffmpeg_qsv.c, ffmpeg_cuvid.c, ffmpeg_videotoolbox.c, etc. from here: https://git.ffmpeg.org/gitweb/ffmpeg.git/tree/HEAD:/fftools - A very nontrival amount of work. It woul practically dwarf all the code even in FFMS2 as-is.

Vpstr commented 5 years ago

So it's complicated, I see. I was hoping it could be some one parameter that could be just switched on for the acceleration to work. And I can't make a patch, because I'm not a programmer. The story behind this need is I have a rare movie with faulty compression. It was encoded by some moron who decided that 25 frames would be better than 23.976 that the original had, but converted it incorrectly, so the encoded video ended up with every 24th frame repeated once, which causes irritating visual twitching. The only way of correcting this without re-encoding is an avisynth script, which throws out every 25th frame and plays the remaining frames at 24 fps with audio unchanged. But as I'm also using SVP for smooth playback and a player's sharpening shader, the CPU gets overloaded sometimes and frames drop. The only way of making it manage the load is to turn on HWA, which your filter can't do. And doing it with DirectShowSource leads to an unbearable AV desynchronisation. That's it.

dwbuiten commented 5 years ago

Even if FFMS2 did support hw acceleration, AVS doesn't support hardware textures; you'd have to memcpy back into a software buffer to get it into an AVS filter anyway, negating a lot of the point of hw accel.

In any case, I think this is outside scope...