Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder #77

Open
aaronth07 opened this issue Mar 30, 2020 · 15 comments
Open

Encoder #77

aaronth07 opened this issue Mar 30, 2020 · 15 comments

Comments

@aaronth07
Copy link

I have no interest in real time encoding, yet a encoder to re-encode anime in an upscaled would be extremely useful. Is there a way to do this with Anime4k?

@TianZerL
Copy link
Contributor

TianZerL commented Mar 31, 2020

Try this.
https://github.com/TianZerL/Anime4KCPP
Witch have a GUI and support GPU acceleration

@ThoughtfulDev
Copy link

Hey,
i had the same problem. Here is what i did.

  1. Compile the newest mpv version
  2. encode the file using mpv with the shaders (sadly only x264 but you can convert to x265 after the fact)
    keep in mind that the next step will loose audio or subs so you have to mux the manually using for example mknixtools.
  3. mpv --vf=format=yuv420p input.mkv --vf=gpu="w=3840:h=2160" --glsl-shaders=~/Anime4K_Hybrid_v2.1a_L.glsl --ovc=libx264 --ovcopts="preset=slow:tune=animation:crf=18" --o=shader.mkv
    this outputs a 4k file (you can change the width and height) of the input. Please change your shader paths and such.

@bloc97
Copy link
Owner

bloc97 commented Apr 26, 2020

@ThoughtfulDev May I ask which options did you use for the compilation and what OS you are on? The default official build for windows does not support -vf=gpu...

@ThoughtfulDev
Copy link

ThoughtfulDev commented Apr 26, 2020

@bloc97 yes i noticed that windows does not work.
I am using POP OS (Ubuntu basically) and added the mpv ppa (http://ppa.launchpad.net/mc3man/mpv-tests/ubuntu)
I didn't compile from source (sorry :D).
But i am sure its in the official build from 0.31 onward on Linux at least.
The -vf=gpu option is only available on Linux afaik.

This is the mpv version output (0.32 has no bugs for me):
mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
built on Sat Apr 4 05:54:47 UTC 2020
ffmpeg library versions:
libavutil 56.31.100
libavcodec 58.54.100
libavformat 58.29.100
libswscale 5.5.100
libavfilter 7.57.100
libswresample 3.5.100
ffmpeg version: 4.2.2

The new filters Ver 3 (the single filters) all work also flawlessly and also when chained.

I havent been able to encode to x265 directly with MPV thought since i get a error about not support 4:4:4.
I am not that good with encoding so i just left it at x264 and encode with ffmpeg after upscaling.
If you are interested i am currently writing a python script with uses the currently up to date V3 of your shaders.
It extracts the audio, subs of a file, scales it, then adds the audio and subs back and then converts it back to x265 if desired. But it still needs some work.

Edit: here is the commit which adds the gpu filter: mpv-player/mpv@90df6c7

@bloc97
Copy link
Owner

bloc97 commented Apr 26, 2020

@ThoughtfulDev I see... I'm currently deciding if I am going to do a full Tensorflow+ffmpeg+Python port of Anime4K for easier use in non-real time applications, and I'm not entirely confident that mpv will introduce gpu encoding for all platforms. I guess I will simply start working on the port first and see from there...

@ThoughtfulDev
Copy link

@bloc97 seems like a good Idea. With the keras implementation in tensorflow integrated this shoulnt be that complicated instead of pure tensorflow (god i hate that).

Good luck. Looking forward to that.

@NightMachinery
Copy link

@ThoughtfulDev Do share your script! BTW, what does vf=gpu.. do? If I am on a CPU-only laptop, is that even needed?

@ThoughtfulDev
Copy link

@NightMachinary i am not ready yet. I have to do some tests still.
You need to use the vf=gpu option since the shaders need to be rendered on the GPU. Thats why you need mpv >= 0.32 since if you want to transcode the shader run on the gpu and then encode on cpu (x264 yuv444 - needs reencoding after that to x265 with ffmpeg to yuv420) or encoding on gpu nvenc(x265 already yuv420).

@ThoughtfulDev
Copy link

@bloc97 and @NightMachinary i just published my repository with the scripts: https://github.com/ThoughtfulDev/Anime4K

@ducomeon
Copy link

@ThoughtfulDev I see... I'm currently deciding if I am going to do a full Tensorflow+ffmpeg+Python port of Anime4K for easier use in non-real time applications, and I'm not entirely confident that mpv will introduce gpu encoding for all platforms. I guess I will simply start working on the port first and see from there...

Hope to get out early, my computer configuration is very low, can not use Anime4K smooth real-time, and transcoding can be better shared

@ThoughtfulDev
Copy link

You can have a look at my repository Anime4K which does offline encoding using the Anime4K shaders.
https://github.com/ThoughtfulDev/Anime4K

@ducomeon
Copy link

You can have a look at my repository Anime4K which does offline encoding using the Anime4K shaders.
https://github.com/ThoughtfulDev/Anime4K

Thank you very much!
But I tested that this doesn't work on my Windows pc, and I'd appreciate your answer anyway.

@dark-swordsman
Copy link

dark-swordsman commented Sep 16, 2021

Just to note about X264 encoding. Apparently you can do "i-frame only" encoding. So it saves a picture for each frame. It is incredibly expensive in terms of video size, but it's quality is technically infinite and you can use that to encode into other formats.

I will certainly try out your MPV solution with that and see if it works.

@78Alpha
Copy link

78Alpha commented Sep 18, 2021

https://github.com/AaronFeng753/Waifu2x-Extension-GUI

Let's you encode with anime 4 land a number of other things, could be a good example for making a standalone one.

@SwayStar123
Copy link

@ThoughtfulDev I see... I'm currently deciding if I am going to do a full Tensorflow+ffmpeg+Python port of Anime4K for easier use in non-real time applications, and I'm not entirely confident that mpv will introduce gpu encoding for all platforms. I guess I will simply start working on the port first and see from there...

Hello is this possible yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants