开发者

Video editing with python or command line

I need to perform the following operations in my python+django project:

  • joining videos with same size and bitrate
  • joining videos and images (for the image manipulation I'll use PIL: writing text 开发者_如何学编程to an existing image)
  • fading in the transitions between videos

I already know of some video editing libraries for python: MLT framework (too complex for my needs), pygame and pymedia (don't include all the features I want), gstreamer bindings (terrible documentation).

I could also do all the work from command line, using ffmpeg, mencoder or transcode.

What's the best approach to do such a thing on a Linux machine.

EDIT: eventually I've chosen to work with melt (mlt's command line)


http://avisynth.org/mediawiki/Main_Page is a scripting language for video.


Because ffmpeg is available on GNU/Linux, i thing using it with modules such as pexpect or subprocess is the best solution....


You can use OpenCV for joining videos and images. See the documentation, in particular the image/video I/O functions.

However, I'm not sure if the library has functions that will do the fading for you.


What codec are you using?

There are two ways to compress video: lossy and lossless. It's easy to tell them apart. Depending on their length, lossy video files are in the megabyte range, lossless (including uncompressed) are in the gigabyte range.

Here's an oversimplification. Editing video files is a lot different from editing film, where you just glue the pieces of film together. It's not just about bitrate, frame rate and resolution. Most lossy video codecs (MPEG 1-4, Ogg Theora, H.26x, VC-1, etc.) start out with a full frame then record only the changes in movement. When you watch the video what you're actually seeing is a static scene with layer after layer of changes pasted on top of it. It looks like you're seeing full frame after full frame, but if you looked at the data in the file all you'd see would be a black background and scrambled blocks of video.

If it's uncompressed or uses a lossless codec (HuffYUV, Lagarith, FFV1, etc.) then you can edit your video file just like film. You still have to re-encode the video but it won't effect video quality and you can cut, copy and paste however you like as long as the resolution and frame rate are the same. If you're video is lossy you have to re-encode it with some loss of video quality, just like saving the same image in JPEG, over and over.

Another option might be to put several pieces of video into a container like MKV and use chapters to have it jump from piece to piece. I seem to remember being told this is possible but I've never tried it so maybe it isn't.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜