Live data from Hacker News

Programmatic Video Editing with Python

github.com

1–10 of 44 posts

Re: Programmatic Video Editing with Python

#2
I've always thought "from lib import star" is somewhat of a anti-pattern.

Personally I think that makes sense - because sometimes when I read code, I just have no idea where something comes from.

But I've seen import star everywhere, couple of examples:

Doc for this product

FastAI's course

Bing ads code base

So I'm guessing it is more of accepted than I expected? What does HackerNews think?

Re: Programmatic Video Editing with Python

#3
What are some good / mature / performant libraries to programmatically achieve compositions of text, audio and image files, perhaps with a timeline in which these can be declared at various timestamps, and the output is a video file?

Does this one do it?

Re: Programmatic Video Editing with Python

#4
this looks great. I normally use Premiere Elements but the overhead for short compositing is too high and there's little automation (at least I don't know how) so something like this is great. The example of compositing using regions found with a template line drawing is intriguing.

Re: Programmatic Video Editing with Python

#5

I've always thought "from lib import star" is somewhat of a anti-pattern. Personally I think that makes sense - because sometimes when I read code, I just have no idea where something comes from. But I've seen import star everywhere, couple of examples: Doc for this product FastAI's course Bing ads code base So I'm guessing it is more of accepted than I expected? What does HackerNews think?

pep8 discourages it, but context matters. a half page readme example trying to demonstrate API usage succinctly is not the sames as a 10 year old 40k line codebase that 25 devs work on

Re: Programmatic Video Editing with Python

#6

I've always thought "from lib import star" is somewhat of a anti-pattern. Personally I think that makes sense - because sometimes when I read code, I just have no idea where something comes from. But I've seen import star everywhere, couple of examples: Doc for this product FastAI's course Bing ads code base So I'm guessing it is more of accepted than I expected? What does HackerNews think?

> I've always thought "from lib import star" is somewhat of a anti-pattern

Like patterns, anti-patterns are context sensitive. “from lib import *” is usually an anti-pattern, but doing it exactly once in a source file, especially a short one, and especially for demonstration code for the library so imported, is not a problem.

But if you do it two or more times in the same source file...

Re: Programmatic Video Editing with Python

#7
post #3

What are some good / mature / performant libraries to programmatically achieve compositions of text, audio and image files, perhaps with a timeline in which these can be declared at various timestamps, and the output is a video file? Does this one do it?

I've had a lot of fun with https://github.com/mifi/editly. It seems a bit RAM hungry as you define lots (dozens?) of clips thought.

I found it super useful to write a quick Python script to auto-generate JSON in the format it wants, combining screenshots, headers, footers, and such into a nice demo-video.

Re: Programmatic Video Editing with Python

#8
post #3

What are some good / mature / performant libraries to programmatically achieve compositions of text, audio and image files, perhaps with a timeline in which these can be declared at various timestamps, and the output is a video file? Does this one do it?

gstreamer is mature... still hard to say if it matches the other requirements (it is notoriously difficult to figure out and use from its docs)

Re: Programmatic Video Editing with Python

#9

I've always thought "from lib import star" is somewhat of a anti-pattern. Personally I think that makes sense - because sometimes when I read code, I just have no idea where something comes from. But I've seen import star everywhere, couple of examples: Doc for this product FastAI's course Bing ads code base So I'm guessing it is more of accepted than I expected? What does HackerNews think?

Here's my take: Don't use "import-star" in library code. Like you say, it obscures where elements of the namespace came from.

When using Python interactively, esp. if the interactive session is to be thrown away at the end, then import-star can be fine and can be a good time-saver. Video editing is a great example of when this is appropriate. See also manim. Other examples might be one-off html parsing or one-off data manipulation tasks.

Similar to "import-star" is multiple inheritance. Just like import-star, multiple inheritance can make it ambiguous where methods come from, and imo it should similarly be avoided by default unless there's a compelling reason to use it.

Re: Programmatic Video Editing with Python

#10

I've always thought "from lib import star" is somewhat of a anti-pattern. Personally I think that makes sense - because sometimes when I read code, I just have no idea where something comes from. But I've seen import star everywhere, couple of examples: Doc for this product FastAI's course Bing ads code base So I'm guessing it is more of accepted than I expected? What does HackerNews think?

An anti-pattern, but I think it's somewhat acceptable for one-offs, examples, ... where there is really only one thing it can come from.
Post reply on HN