The resources
moviepy
Official website address:
Pypi.org/project/mov…
moviepy
Document Address:
zulko.github.io/moviepy/
instructions
- Clips the specified video file based on the entered start and end seconds.
mp4
Format test passed, other file types not tested.- You need to install
moviepy
Module:pip install moviepy
. - If there is no
requests
Modules also need to be installed. - use
pip
Install the bestChange the domestic source. - The script is downloaded the first time you run it
ffmpeg
The 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