File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Use the official Python base image
2
+
3
+ FROM alpine:latest
4
+
5
+ RUN apk update && apk add ffmpeg && apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev libffi-dev openssl-dev && wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py && pip install ffmpeg-python && apk del .build-deps && rm -rf /var/cache/apk/*
6
+
7
+
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " ffmpeg-python-dev-container" ,
3
+ "dockerFile" : " Dockerfile" ,
4
+ "settings" : {
5
+ "terminal.integrated.shell.linux" : " /bin/bash"
6
+ },
7
+ "extensions" : [
8
+ " ms-python.python"
9
+ ],
10
+ "forwardPorts" :
8000
[],
11
+ "postCreateCommand" : " echo 'Welcome to your ffmpeg-python dev container!'"
12
+ }
13
+
Original file line number Diff line number Diff line change
1
+
2
+ import requests
3
+ import ffmpeg
4
+ import tempfile
5
+
6
+ # Download a video file from the internet
7
+ video_url = 'https://download.samplelib.com/mp4/sample-5s.mp4'
8
+
9
+ response = requests .get (video_url , stream = True )
10
+ response .raise_for_status ()
11
+
12
+ # Save the video to a temporary file
13
+ with tempfile .NamedTemporaryFile (delete = False , suffix = '.mp4' ) as temp_video_file :
14
+ for chunk in response .iter_content (chunk_size = 8192 ):
15
+ temp_video_file .write (chunk )
16
+ temp_video_file .flush ()
17
+
18
+ # Process the video using ffmpeg-python
19
+ input_video = ffmpeg .input (temp_video_file .name )
20
+ output_video = input_video .filter ('scale' , 320 , 240 ).output ('output_video.mp4' )
21
+ output_video .run ()
22
+
23
+ print ("Video processing completed. The output video is saved as output_video.mp4." )
You can’t perform that action at this time.
0 commit comments