This Python script, 'iptvEventRecorder.py', allows you to record a live IPTV stream for a specified duration and saves the recording as an MP4 file. You can easily modify the code to customize the script according to your needs.
This script uses the ffmpeg software which needs to be installed and available in your system's PATH. You can download it from here. The script has been tested with Python 3.8, but it should work with other Python 3 versions as well.
-
Download the 'iptvEventRecorder.py' file or clone the entire repository.
-
Open 'iptvEventRecorder.py' in any text editor.
-
Look for this line in the code:
'-i', 'https://your_stream_url_here', -
Replace
'https://your_stream_url_here'with your IPTV stream's URL. -
To specify a recording duration, go to the top of the script and find this line:
RUNTIME = 30 -
Replace
30with your desired recording duration in minutes. -
Save and close the file.
-
Open a terminal/command prompt.
-
Navigate to the directory where 'iptvEventRecorder.py' is located using the
cdcommand. -
Run the script by typing:
python iptvEventRecorder.py
The script will then start recording the stream and save it as 'output_file.mp4'. You can stop the recording at any time by pressing Ctrl+C in the terminal where the script is running.
You can customize the script according to your needs by modifying the code.
-
Changing the Output File Name and Format: The script currently saves the recording as 'output_file.mp4'. You can change this by modifying the
'output_file.mp4'part of the command array in the code. -
Changing the Recording Duration: The script currently records for 30 minutes by default. You can change this by modifying the
RUNTIMEvariable at the top of the script.
If you encounter any issues while using the script, try the following steps:
-
Check the Stream URL: Make sure the stream URL you've entered in the script is correct and working. You can test it by opening the URL in VLC or another media player that supports streaming.
-
Check Your Internet Connection: Make sure your internet connection is stable and fast enough to handle the stream.
-
Update
ffmpegand Python: Make sure you're using the latest versions offfmpegand Python.
If you're still having issues, feel free to open an issue on GitHub.
This script is released under the MIT License. See the LICENSE file for more details.