Live data from Hacker News

Programmatic Video Editing with Python

github.com

21–30 of 44 posts

Re: Programmatic Video Editing with Python

#21
post #16

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?

Side question: how do you prevent import statements from being imported by "from lib import star"? (Without explicitly mentioning all the stuff that is not import statements). For example, this is mymod.py: import numpy as np def f(x): return 2*x And here it is imported: from mymod import * f(10) # Works as expected. np.sum([10, 20]) # Works, but shouldn't work.

Any non-trivial python module is going to be broken up into multiple files and have an __init__.py which you can explicitly define what's imported and exposed. You can hoist a single file module into a folder-based module if you need direct control and don't want to split it apart into multiple files yet too.

Re: Programmatic Video Editing with Python

#22
I love MoviePy! It's great when you have a lot of bits of audio, video, and text you need to glue together. I have used it to create some GPT-2-generated Peppa Pig cartoons (https://www.youtube.com/watch?v=1TEwCA3KDtg) -- stick the image, text, and speech together (aligned to the speech length), concat all the clips, and finally apply some fancy ffmpeg effects.

Re: Programmatic Video Editing with Python

#23
post #20

If you're interested in high performance video processing with Python and want something more than just a fancy ffmpeg wrapper, then I can highly recommend checking out Vapoursynth: https://www.vapoursynth.com/ It's been around for ~9 years and has a relatively large community around it, most visibly found on the Doom9 forums: http://forum.doom9.org/forumdisplay.php?f=82 I'm personally still mostly using Avisynth the…

For those desiring a GUI interface around VapourSynth and other advanced A/V processing tools, I strongly recommend StaxRip: https://github.com/staxrip/staxrip

Re: Programmatic Video Editing with Python

#24
Ya' know... This is exactly what I was looking for a few months back, when I started playing with video editing. I couldn't find anything like this, so I went with kdenlive to produce things like https://www.youtube.com/watch?v=C4Aw4sWM6sM from things like https://www.youtube.com/watch?v=zk5K3sfbsqY.

Re: Programmatic Video Editing with Python

#25
What a nice surprise to see MoviePy on the HN front page!

I was tinkering with moviepy over the weekend to add subtitles to my standup comedy routine. I used a hand edited simple ".srt" file. It was easy and fun to implement.

Here is the finished result, https://fb.watch/v/17oesJhB3/

Re: Programmatic Video Editing with Python

#26

I love MoviePy! It's great when you have a lot of bits of audio, video, and text you need to glue together. I have used it to create some GPT-2-generated Peppa Pig cartoons ( https://www.youtube.com/watch?v=1TEwCA3KDtg ) -- stick the image, text, and speech together (aligned to the speech length), concat all the clips, and finally apply some fancy ffmpeg effects.

Oh, so you’re the guy.

Re: Programmatic Video Editing with Python

#27

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?

No, you’re right. It’s like picking your nose. Don’t ever do it. I don’t ever do it.

Unless no one can see.

Somewhat more seriously, don’t do it in anything other than one-off code once you’ve experimented enough to get the result you want unless you aren’t scared of the people who will yell at you about circular imports.

Re: Programmatic Video Editing with Python

#29
I'm creating a web version of flash, the animation software, I was considering adding video support to it, so people could import video clips and make animations on top of it. Right now I'm exporting movies using the canvas capture stream, but I'm considering using ffmpeg (js) also. Cool project, I'm gonna star it so I could use it later.

Re: Programmatic Video Editing with Python

#30

The 3Blue1Brown YouTube channel (a well regarded channel that publishes visualizations of various mathematical and other processes) also uses Python to programmatically generate the videos: https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw

Note: that's for making the animations. Editing is done in a video editor, though I'm not sure which one he uses anymore
Post reply on HN