This project allows you to record your desktop screen using OBS Studio, process the video to fit Instagram Stories (1080x1920 resolution), and speed it up to create a 15-second high-quality video suitable for Instagram.
- Record your desktop screen using OBS Studio.
- Automatically resize the video to Instagram Stories resolution (1080x1920).
- Speed up the video to fit within 15 seconds.
- Ensure high video quality with Instagram-compliant settings (8 Mbps bitrate, H.264 codec).
Before running the script, ensure you have the following installed:
-
OBS Studio:
- Download and install OBS Studio from https://obsproject.com/download.
-
Python:
- Download and install Python from https://www.python.org/downloads/.
-
OBS WebSocket Plugin:
- The OBS WebSocket plugin is required for communication between the script and OBS Studio. Follow the steps below to enable it.
-
Enable WebSocket:
- Open OBS Studio.
- Go to
Tools>WebSocket Server Settings. - Enable the WebSocket server and set a password (e.g.,
123456789). - Click
ApplyandOK.
-
Add Window Capture:
- In the
Sourceswindow, click the+button and selectWindow Capture. - Choose the window or application you want to record.
- In the
-
Set Video Resolution:
- Go to
File>Settings>Video. - Set both
Base (Canvas) ResolutionandOutput (Scaled) Resolutionto1080x1920(Instagram Stories resolution).
- Go to
-
Set Video Recording path:
- Go to
File>Settings>Outputand setVideo Recording pathto current application path.
- Go to
-
Start Recording:
- Ensure OBS Studio is running and ready to record.
-
Clone the Repository:
git clone https://github.com/ebrahimkhodadadi/MtScreenRecorder.git cd MtScreenRecorder -
Install Dependencies: Install the required Python libraries:
pip install -r requirements.txt
Alternatively, install the libraries manually:
pip install obs-websocket-py moviepy
-
Run the Script:
- Execute the script using Python:
python main.py
- Execute the script using Python:
-
Set Script Settings:
- When prompted, enter the following settings:
- OBS WebSocket Host:
localhost(or the IP address of the machine running OBS). - OBS WebSocket Port:
4444(default port). - OBS WebSocket Password: The password you set in OBS WebSocket settings.
- OBS WebSocket Host:
- When prompted, enter the following settings:
-
Start Recording:
- The script will connect to OBS Studio and start recording.
- After recording, it will process the video to fit Instagram Stories and save it as
instagram_video.mp4.
-
Connect to OBS:
- The script connects to OBS Studio via WebSocket.
-
Start Recording:
- The script sends a command to OBS to start recording.
-
Stop Recording:
- After a predefined duration (e.g., 30 seconds), the script stops the recording.
-
Process Video:
- The recorded video is resized to 1080x1920 (Instagram Stories resolution).
- The video is sped up to fit within 15 seconds.
- The video is encoded with high-quality settings (8 Mbps bitrate, H.264 codec).
-
Save Output:
- The processed video is saved as
instagram_video.mp4in the current directory.
- The processed video is saved as
You can customize the script by modifying the following variables in main.py:
-
OBS WebSocket Settings:
host = "localhost" # Replace with the IP address of the machine running OBS port = 4444 # Default WebSocket port password = "123456789" # Password set in OBS WebSocket settings
-
Video Processing Settings:
target_duration = 15 # Target duration for the Instagram Story video (in seconds)
The processed video will be saved as instagram_video.mp4 in the current directory. The video will:
- Have a resolution of 1080x1920 (Instagram Stories).
- Be sped up to fit within 15 seconds.
- Comply with Instagram's maximum bitrate limit (8 Mbps).
-
Connection Issues:
- Ensure OBS Studio is running and the WebSocket server is enabled.
- Verify the host, port, and password in the script match the OBS WebSocket settings.
-
Low Video Quality:
- Ensure the source video recorded by OBS is high quality.
- Check the resolution and bitrate settings in OBS.
-
File Not Found:
- Ensure the recorded
.mkvfile is in the same directory as the script.
- Ensure the recorded
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
- OBS Studio for providing a powerful open-source recording tool.
- obs-websocket-py for the Python WebSocket client.
- MoviePy for video processing.
Let me know if you need further assistance!