yt-dlc icon indicating copy to clipboard operation
yt-dlc copied to clipboard

[Site Request] Asciinema

Open ghost opened this issue 3 years ago • 1 comments

Checklist

  • [x] I'm reporting a new site support request
  • [x] I've verified that I'm running youtube-dlcc version 2020.10.31 (2020.11.11-3)
  • [x] I've checked that all provided URLs are alive and playable in a browser
  • [x] I've checked that none of provided URLs violate any copyrights
  • [x] I've searched the bugtracker for similar site support requests including closed ones

Example URLs

  • Single video: https://asciinema.org/a/332708

Description

I opened this feature request on the legacy bug tracker, but the owner closed it as invalid because, as he said, the website does not host videos, that is just ascii art. I disagree with that, so let me convice you that there are videos and that it makes sense to add asciinema video downloader to yt-dlc.

The website provides a tool for recording console output and uses a special format to represent the console output in time. You can upload recorded "videos" (which are basically text files) to their website and they can play the files as videos by animating the text in the browser itself.

So, if you think about it, what the definition of a video actually is? The video is a sequence of images that are supposed to be played at some framerate. And each image is a 2D grid of pixels (colors). But a console that supports colors can actually be viewed as a video player. You can change the width/height of the console windows and you can customize the color palette, so that you can play any video by literally rendering ascii output of a program in the console window itself.

My suggestion is that we add support for asciinema to the yt-dlc by retrieving the "video" file (that is just a plaintext with special color codes and escape sequences) and then use python (on nodejs or some other program) to actually render each frame as a pixel matrix and then pass to ffmpeg that can read raw pixel data and save as mp4 file or some other format.

What do you think about this idea?

ghost avatar Nov 17 '20 14:11 ghost

Asciinema does not provide any video content , and asciinema doesn't turn the recorded output into some magical format it's just json that asciinema player reads and print like your regular terminal emulator. if you like to, here's a small script to download asciinema recordings for you then use some tool to convert it like asciicast2gif then use ffmpeg to convert gif to mp4, unfortunately yt-dlc does only care about media content and asciinema is not included.

import sys
import requests as req 

if __name__ == "__main__":
    if len(sys.argv) != 3: 
        print("./asciinema_download <URL> <OUTPUT_NAME>")
        exit(0)
    r = req.get(sys.argv[1]+'.cast?dl=1')
    open(sys.argv[2], 'w').write(r.text)
    print(f"Download Complete {sys.argv[2]}")

M1ndo avatar Nov 18 '20 00:11 M1ndo