Skip to content

Latest commit

 

History

History
66 lines (41 loc) · 2.69 KB

video.md

File metadata and controls

66 lines (41 loc) · 2.69 KB

Play Videos

Main Guide

Introduction

  • You can stream videos directly on terminal with the functions play_video() and play_youtube().

  • The function show() is not necessary in both cases, as it is called internally.

  • The frames size will adapt to the screen size, unless plot_size() is used before the steaming functions.

  • To download videos from the given YouTube url to the specified path, use the get_youtube() method.

  • Both streaming functions may require further development. Any bug report or development idea is welcomed.

Main Guide, Play Videos

Video Plot

To play a video with audio, use the the play_video() function. Set the parameter from_youtube to True to make sure that the color rendering is correct for videos downloaded from YouTube.

In this example, a test video is downloaded in the home folder, streamed and finally removed:

import plotext as plt
path = 'moonwalk.mp4'
plt.download(plt.test_video_url, path)
plt.play_video(path, from_youtube = True)
plt.delete_file(path)

or directly on terminal:

python3 -c "import plotext as plt; path = 'moonwalk.mp4'; plt.download(plt.test_video_url, path); plt.play_video(path, from_youtube = True); plt.delete_file(path)"

which will render this video on terminal. Yes! I am a Michael Jackson fan: he is number one (also innocent), not my fault!

More documentation can be accessed with doc.play_video().

Main Guide, Play Videos

Play YouTube

To play a YouTube video from url use the function play_youtube(), as in this example:

import plotext as plt
plt.play_youtube(plt.test_youtube_url)

or directly on terminal:

python3 -c "import plotext as plt; plt.play_youtube(plt.test_youtube_url)"

which will render this youtube video on terminal.

Main Guide, Play Videos