The resources

  • moviepyOfficial website address:

Pypi.org/project/mov…

  • moviepyDocument Address:

zulko.github.io/moviepy/


instructions

  • Clips the specified video file based on the entered start and end seconds.
  • mp4Format test passed, other file types not tested.
  • You need to installmoviepyModule:pip install moviepy.
  • If there is norequestsModules also need to be installed.
  • usepipInstall the bestChange the domestic source.
  • The script is downloaded the first time you run itffmpegThe program.

code

# website https://pypi.org/project/moviepy/
# documentation at http://zulko.github.io/moviepy/

from moviepy.editor import *

while True:
    start = input('Please enter the starting seconds:')
    end = input('Please enter end seconds:')
    try:
        start = int(start)
        end = int(end)
    except Exception:
        print('Input error, please re-enter! ')
        continue
    if start > end:
        print('Start seconds greater than end seconds! ')
        print('Please re-enter! ')
    elif start < 0:
        print('Start seconds less than 0, please re-enter! ')
    elif end < 0:
        print('End seconds less than 0, please re-enter! ')
    else:
        break

file = input('Please enter the file name:')
name, ext = file.split('. ')
clip = VideoFileClip(file).subclip(start, end)
new_file = name + '_edited.' + ext
clip.write_videofile(new_file)

Copy the code

Completed in 20181116