A
topic derail in a Cock Hero thread lead me to prototype the idea of a video playlist that is interrupted randomly by other clips. The attached Python script does that.
Current version:
Old versions:
- Spoiler: show
-
Change log:
- Spoiler: show
-
playlist_0_6.py:
- Runtime configuration changes are saved.
- First GUI usage via Tkinter library.
- Dialog window prompts for missing and incorrect configuration variables.
- Configuration can be made through the program without a playlist.json existing at the start.
- Add shebang for POSIX users.
playlist_0_5.py:
- Logging starts earlier, chooses its filename from the script's name, and is written to the script's directory.
- Move configuration to playlist.json in the script's directory.
- Move configuration comments to README.
- Add exception catching for log.
playlist_0_4.py:
- Add a check that FFprobe executable is found.
- Add checks that configurable variables are in order and that directories exist.
- Add logging.
playlist_0_3.py:
- get_length() now ignores special characters in file path names.
playlist_0_2.py:
- Selections from both video directories are randomized.
- Playlist ends on the current interruptible video when all interruption clips have been used.
- Interruptions are at random intervals.
- Playlist has a maximum length.
- Playlist finishes the current interruptible video when maximum length is reached.
playlist_0_1.py:
- Add interruption range variables.
- Playlist file now encoded as utf-8.
- File paths now support NTFS hard links and symlinks.
Given two directories the script will choose a random amount of times to interrupt videos from "video_dir" with ones from "video_interruption_dir". It builds an m3u8 playlist of these videos. Playlist works in
VLC Media Player. The playlist uses m3u8 extensions provided by VLC for start-time and stop-time.
The script depends on
Python 3 and
FFmpeg. For FFmpeg
use the shared build if you're also doing other audio or video work.
You may also use file system linking, hard links or symlinks, to make your video directories for this. In Windows use
Link Shell Extension to assist.
Configuration is now guided by GUI prompts when
playlist.json doesn't exist, or when a variable tests invalid.
If configuring manually, these variables in
playlist.json need to be set correctly:
Code: Select all
{
"ffprobe": "ffprobe",
"video_playlist_file": "C:/playlist/playlist.m3u8",
"video_dir": "C:/playlist/videos",
"video_interruption_dir": "C:/playlist/interruptions",
"min_interruptions": 2,
"max_interruptions": 7,
"max_playlist_minutes": 120,
"video_player": "vlc"
}
Windows directory paths require double backslash, or single forward slash. Python emits single forward slash paths when GUI configuration is used.