forked from kkroening/ffmpeg-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_script.py
More file actions
23 lines (17 loc) · 762 Bytes
/
sample_script.py
File metadata and controls
23 lines (17 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests
import ffmpeg
import tempfile
# Download a video file from the internet
video_url = 'https://download.samplelib.com/mp4/sample-5s.mp4'
response = requests.get(video_url, stream=True)
response.raise_for_status()
# Save the video to a temporary file
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_video_file:
for chunk in response.iter_content(chunk_size=8192):
temp_video_file.write(chunk)
temp_video_file.flush()
# Process the video using ffmpeg-python
input_video = ffmpeg.input(temp_video_file.name)
output_video = input_video.filter('scale', 320, 240).output('output_video.mp4')
output_video.run()
print("Video processing completed. The output video is saved as output_video.mp4.")