-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
TextClip produces low quality text #1472
Comments
I'm seeing now your implementation of
|
Indeed. The other alternative to Gizeh is just to use PIL directly. I was working on this before: https://github.com/tburrows13/moviepy/blob/redo-textclip/moviepy/video/NewTextClip.py. With the following added to your demo (and adjusting the rest of the code to be compatible with ~v2.0.0.dev1 which this fork is currently based off): def create_PILTextClip_demo():
bg_clip = ColorClip(size=SIZE, color=BG_COLOR, duration=DURATION).set_position(
TEXT_POSITION
)
text_clip = (
NewTextClip(TEXT, color=TEXT_COLOR_HEX, size=TEXT_SIZE, fontsize=FONT_SIZE, bg_color=(0, 0, 0, 0))
.set_position(TEXT_POSITION)
.set_duration(DURATION)
)
text_clip = text_clip.rotate(TEXT_ROTATION, unit="deg", expand=True)
return CompositeVideoClip([bg_clip, text_clip]).set_duration(DURATION) I get textdemo.mp4Which admittedly looks bad. Maybe that's just a bug in my implementation though? I've not worked on it for a while. Feel free to take over my effort, or start again from scratch with Gizeh. The main advantage of getting rid of ImageMagick, besides the poor quality that you've demonstrated, is that it is tricky for users to get setup. Pillow is great because it is already a dependency. As long as Gizeh is pip-installable it shouldn't matter too much adding it as a dependency. |
Yep, as I noted, I'd like to completely remove ImageMagick (it is only used here and as one of 3 optional gif renderers - I don't think it will be missed). This allows us to remove a lot of the complexity of installation. Between PIL and Cairo/Gizeh, if PIL can get equivalent results, then it is preferable. If Gizeh is as easy to install as PIL is, then that would be fine as well. |
Perfect 👍 I'm going to try to create the same results with PIL.
I agree completely, that would be the most reasonable approach. |
+1 to remove ImageMagick (which was a 10-minute decision I took at the very beginning of the project and am not proud of). I made a "Gizeh text clip for moviepy" some time ago here. It is much better than ImageMagick, but Cairo can be difficult to install on some machines. PIL would be the best in terms of user installation experience. But can PIL access any user-installed font easily? Last time I checked (years ago...) it required the complete path to a font file. |
You can see that I changed some of the more niche parameters in the PIL TextClip to align with what got passed to PIL. I think that that is fine. It makes sense to align the TextClip parameters with whatever is being used to underly it. |
I've updated the issue description with the complete example: Gizeh vs PIL vs TextClip. It seems that, as @Zulko said, Cairo render with best quality.
It seems that Pycairo provides a wheel with cairo 1.17.2 included for Windows, so I think that we can go with it. In other systems the installation is easy.
Matplotlib has a multiplatform system fonts discovering feature that we could reuse in the case of providing a PIL-based TextClip. |
I've integrated your example inside a
With that I could create a |
If you manage that I would vote for it (@tburrows13 what do you think?). Note that this would require some work to update the scripts that use the current ImageMagick-based text API, but that's allowed by the major version bump in v2.0. |
Yep. As long as it is pip-installable (which the current ImageMagick solution isn't), then I'm very happy. Breaking changes are fine, so presumably make the TextClip parameters fit as neatly around the underlying library possible. |
@tburrows13 While trying your PIL-based TextClip you linked here, I found that the default
Otherwise it works fine 👍 |
good solutions. |
Thank you for your contributions and for reporting issues in this repository. With the release of v2, which introduces significant changes to the codebase and API, we’ve reviewed the backlog of open PRs and issues. Due to the length of the backlog and the likelihood that many of these are either fixed or no longer applicable, we’ve made the decision to close all previous PRs and issues. If you believe that any of these are still relevant to the current version or if you'd like to reopen a related discussion, please feel free to create a new issue or pull request, referencing the old one. Thank you for your understanding and continued support! |
I think that the usage of ImageMagick to render texts is a bad option, but maybe I'm wrong and someone could explain me how to achieve good quality texts using
TextClip
. To illustrate this, I've done a comparison betweengizeh
vsPIL
vsTextClip
:Rendered result (MP4)
The result is that Gizeh creates a text with good quality using Cairo (first scene), followed by PIL (second scene) and moviepy using ImageMagick creates a low quality text (third scene).
Specifications
The text was updated successfully, but these errors were encountered: