scivision / PyLivestream

Pure Python FFmpeg-based live video / audio streaming to YouTube, Facebook, Periscope, Twitch, and more
Apache License 2.0
707 stars 156 forks source link

How to enable "Now Playing" text on audio stream? #53

Closed z0mn closed 1 year ago

z0mn commented 4 years ago

Describe the bug Hi! I've looked at ffmpeg.py and see a reference to drawing text of the currently playing audio file. How do I enable this? Here's the function in /usr/local/lib/python3.8/site-packages/pylivestream:

    def drawtext(self, text: str = None) -> List[str]:
        # fontfile=font.ttf:
        if not text:  # None or '' or [] etc.
            return []

        fontcolor = "fontcolor=white"
        fontsize = "fontsize=24"
        box = "box=1"
        boxcolor = "boxcolor=black@0.5"
        border = "boxborderw=5"
        x = "x=(w-text_w)/2"
        y = "y=(h-text_h)*3/4"

        return [
            "-vf",
            f"drawtext=text='{text}':{fontcolor}:{fontsize}:{box}:{boxcolor}:{border}:{x}:{y}",
        ]

Here's an example file name: 1992-12-12 - <Program> - <Feature>.flac

System Parameters My standard command is as follows: FileGlobLivestream <absolute path to directory of audio files> youtube -glob "*.flac" -image <absolute path to image>/thumb.png -loop -shuffle

ph33nx commented 3 years ago

As mentioned here. If you have installed the optional tinytag Python module, the Title - Artist will be added automatically onto the video from the audio/video files.