Skip to main content

A Python cli tool for generating your own music playlist video

Project description

About

  • Author: shrimp2845
  • Version: 0.2.0
  • requirement: Python 3.10+, FFmpeg
  • License: MIT

Musics2Video is a Python CLI tool for automatically generating music playlist videos. It can fetch music from online sources like YouTube or use your local audio files, combine them with a dynamic playlist display, and render a single video file.

Features

Flexible Music Sources: Create videos from a list of online URLs (yt-dlp supported sources) or local audio files.

Batch Processing: Use a simple text file to define a mixed playlist of online and local tracks.

Customizable Visuals: Choose from built-in styles (classic,modern) or create and use your own custom HTML/CSS templates for a unique look.

Automatic Metadata: Automatically fetches song titles and thumbnails from online sources.

Custom Artwork: Specify unique cover art for each track in your playlist.

Configurable Output: Control video resolution, FPS, audio quality, and output formats.

Installation

FFmpeg: This tool relies on FFmpeg for video and audio processing. You can download it from the official FFmpeg website.

Musics2Video: Install the package using pip.

Python 3.10 ~ 3.12

pip install musics2video

Python 3.13+

pip install musics2video
pip install audioop-lts

Usage

The tool is accessed using musics2video command, which has two main sub-commands: download and list.

1. download Command

Generates a video from a list of online URLs. Audio is downloaded, and titles/thumbnails are fetched automatically.

Example:

musics2video download "https://www.youtube.com/watch?v=xxxxxx" "https://www.youtube.com/watch?v=yyyyyy" --name "my_playlist.mp4" --style modern

2. list Command

Generates a video from a text file that specifies a sequence of local and online tracks. This method provides fine-grained control over the playlist content and artwork.

List File Format: Create a text file (e.g., songs.txt). Each line represents a track and follows this format: source{{NEXT}}path_or_url{{NEXT}}optional_cover_path

  • source: Can be local or download.
  • path_or_url: A file path for local or a URL for download.
  • optional_cover_path: An optional path to a local image file to use as the track's cover art.

Example songs.txt:

download{{NEXT}}https://www.youtube.com/watch?v=xxxxxx
local{{NEXT}}/path/to/my/song.mp3{{NEXT}}/path/to/my/album_art.png
download{{NEXT}}https://www.youtube.com/watch?v=yyyyyy{{NEXT}}/path/to/custom_cover.jpg
local{{NEXT}}/another/path/to/music.wav

Command:

musics2video list songs.txt --name "my_mixed_playlist.mp4" --style classic

Command-line Options

Both download and list commands accept the following options to customize the output:

Option Alias Description Default
--name -n The filename for the final output video. output.mp4
--out-dir -o Target output directory path for the final video. ./
--style -s Built-in visual style template (classic, modern). classic
--custom-tmpl Path to a folder containing a custom template.html and style.css. None
--width Output video resolution width in pixels. 1920
--height Output video resolution height in pixels. 1080
--fps Frames per second for the final video. 10
--yt-cover / --no-yt-cover Fetch and use thumbnails from online video sources. --yt-cover
--shorten / --no-shorten Truncate long track titles to fit the layout. --shorten
--audio-fmt Target audio format for internal processing. opus
--audio-q Audio extraction quality (0=best, 9=worst). 0
--video-fmt Output video file container format. mp4
--level -l Logging level (DEBUG, INFO, WARNING, ERROR). INFO
--keep-temp/--no-keep-temp whether to remove temporary files or not --no-keep-temp

Built-in templates display

Two Built-in templates provided in current version:

1.classic

classic

2.modern

modern

(These songs are pretty good! You should take a look at their official website)

Custom Templates

If you don't like buit-in templates, you can provide your own template directory using the --custom-tmpl option. The directory must contain:

1.template.html: The HTML structure for your video frame.

2.style.css: The CSS for styling the frame.

Template Requirements

template.html:

It must contain the {{SONGS}} placeholder. musics2video will replace this with the generated HTML for the song list.

It should reference a cover image. The generator places an image named cover.png in the rendering directory. You can reference it in your HTML like this: <img src="cover.png">.

style.css:

The playlist generated at {{SONGS}} will consist of <div class="song">...</div> elements.

The currently playing song will have an additional class: <div class="song active">...</div>. You can use .song.active to highlight it.

Example Custom Template Structure:

/my_project
├── my_template/
│   ├── template.html
│   └── style.css
└── songs.txt

Command:

musics2video list songs.txt --custom-tmpl ./my_template

Disclaimer

If you want to redistribute the videos generated by this tool, please make sure to obtain permission from the original author. The author of this project takes no responsibility if you run into any issues.

Note

This project is maintained by a beginner.
Any feedback, suggestions, issues are very welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

musics2video-0.2.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

musics2video-0.2.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file musics2video-0.2.0.tar.gz.

File metadata

  • Download URL: musics2video-0.2.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for musics2video-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4c4c2e848a57ca5de4561f347ad9e0fb623b6a0987310899691e105fd32641d1
MD5 0574e799169ba6ac1a57265da949a58e
BLAKE2b-256 c369e38c450e5605b59007f3220028ddac6bbd1d1c78edd416e95fd97b34473a

See more details on using hashes here.

Provenance

The following attestation bundles were made for musics2video-0.2.0.tar.gz:

Publisher: publish.yml on shrimp2845-tw/Musics2Video

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file musics2video-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: musics2video-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for musics2video-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af50b9ca6ff1681f662c1125b2ed0a6b561ebf211fede0e0b4b7de6cafc3ce1a
MD5 02f16a29d94480c4a89f80571c4cf7fb
BLAKE2b-256 803a541be04d31a822c34846409752e44d4e2601965bcd9c8ad35eb4cfdb72b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for musics2video-0.2.0-py3-none-any.whl:

Publisher: publish.yml on shrimp2845-tw/Musics2Video

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page