mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-08-12 22:45:57 +08:00
Let users know they need ffmpeg to use this library & record screen (#469)
* Let users know they need ffmpeg to use this library * Added example to record screen of Windows OS Co-authored-by: digitalcircuits <digitalcircuits@github>
This commit is contained in:
parent
29b6f09298
commit
228b491e50
@ -81,6 +81,15 @@ Real-world signal graphs can get a heck of a lot more complex, but `ffmpeg-pytho
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Before using ffmpeg-python, you need to have ffmpeg installed and in your PATH environment. You can install ffmpeg through the official website [here](https://ffmpeg.org/download.html). Once you have it installed, make sure the folder ffmpeg is located is set in your environment path. You can check if your environment path is set correctly by opening up a command window and typing this
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ffmpeg
|
||||||
|
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
|
||||||
|
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
The latest version of `ffmpeg-python` can be acquired via a typical pip install:
|
The latest version of `ffmpeg-python` can be acquired via a typical pip install:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
22
examples/record_windows_screen.py
Normal file
22
examples/record_windows_screen.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import ffmpeg, time
|
||||||
|
|
||||||
|
#Setup for recording windows desktop to mp4 file
|
||||||
|
process = (
|
||||||
|
ffmpeg
|
||||||
|
.input(format='gdigrab',framerate=30,filename="desktop")
|
||||||
|
.output(crf="0",preset="ultrafast",filename="./output.mp4",c= "libx264" )
|
||||||
|
.overwrite_output()
|
||||||
|
)
|
||||||
|
#Launch video recording
|
||||||
|
process = process.run_async(pipe_stdin=True)
|
||||||
|
|
||||||
|
|
||||||
|
#Let it record for 20 seconds
|
||||||
|
time.sleep(20)
|
||||||
|
|
||||||
|
#Stop video recording
|
||||||
|
process.communicate(str.encode("q")) #Equivalent to send a Q
|
||||||
|
|
||||||
|
# To be sure that the process ends I wait 3 seconds and then terminate de process (wich is more like kill -9)
|
||||||
|
time.sleep(10)
|
||||||
|
process.terminate()
|
Loading…
x
Reference in New Issue
Block a user