Search code examples
videovideo-processing

CLI tool splits AVI file with JPEG format video


I'm a newbie in video processing, and I'm trying to write a program in Python. The program is to split a long video into some short videos by timestamp.

For example, I have an input, video long_video.avi, which is 15 minutes long. I want extract to 2 videos, short_1_5_video.avi (1'-5') and short_6_10_video.avi (6'-10'). The input video has container AVI and video format JPEG. This is information of video (show in mediainfo tool):

enter image description here

I want find a CLI (command line interface) tool which I can invoke from Python. I tried some tools:

  • mp4box(http://www.videohelp.com/tools/mp4box):

    But mp4box not support AVI file. It only supports MKV and MP4 file.

  • mkvmerge(in mkv tool):

    But mkvmerge only supports MKV file.

  • ffmgeg:

    But It seem not support split video by timestamp("seem" because I didn't find It in specification of ffmpeg).

I thought about convert input video from AVI to MP4 or MKV and then splitting it, but the time taken to do the conversion is too long. Please suggest me a tool can splits AVI file with JPEG format video that can be controlled from the command line.

In addition, I also want to find a GUI tool that can do this.


Solution

  • Assuming that you want to split this file into 3 parts: beginning -> 00:00:05 -> 00:00:10 -> end, try this:

    mencoder -endpos 00:00:05 -oac copy -ovc copy input.avi -o part1.avi
    mencoder -ss 00:00:05 -oac copy -ovc copy input.avi -o tmp.avi
    
    mencoder -endpos 00:00:10 -oac copy -ovc copy tmp.avi -o part2.avi
    mencoder -ss 00:00:10 -oac copy -ovc copy tmp.avi -o part3.avi