Skip to content
Akash Mahanty edited this page Oct 17, 2021 · 33 revisions

Downloading the best quality video(if possible from sites like YouTube and Vimeo)

The VideoHash class has a download_worst parameter and the default argument is True, this is to save bandwidth but sometimes the worst files might have very big black borders and the hash-value might not match. To overcome this issue you can set the argument Value of download_worst to False and make youtube-dl/yt-dlp download the best available video.

VideoHash(url="https://www.youtube.com/watch?v=PapBjpzRhnA", download_worst=False) # To download the best video

Deleting the storage path

The delete_storage_path() method deletes the storage path, please remember that deleting the storage directory will also delete the collage, extracted frames, and the downloaded video. If you passed an argument to the storage_path that directory will not be deleted but only the files and directories created inside that directory will be deleted, this is a feature(not a bug) to ensure that multiple instances of the same program are not deleting the storage path while other instances still require that storage directory.

>>> videohash1 = VideoHash(url="https://www.youtube.com/watch?v=PapBjpzRhnA", download_worst=False)
>>> videohash1.delete_storage_path() # Delete the storage_path

Accessing files created by VideoHash instance

Whenever a VideoHash instance is created, it creates some directories and files. It should also download the video if an URL is used to calculate the videohash value.

>>> videohash1 = VideoHash(url="https://www.youtube.com/watch?v=PapBjpzRhnA")

Accessing the collage_path and collage_dir

The collage_path is the absolute path of the collage generated by the instance and collage_dir is the absolute path of the directory in which the collage is stored.

>>> videohash1.collage_path
'/tmp/tmprf3g8gqi/temp_storage_dir/jbdz59cjosxf/collage/collage.jpg'
>>> videohash1.collage_dir
'/tmp/tmprf3g8gqi/temp_storage_dir/jbdz59cjosxf/collage/'

Accessing the frames_dir

The frames of the input video are extracted and stored in the frames_dir by the instance.

>>> videohash1.frames_dir
'/tmp/tmprf3g8gqi/temp_storage_dir/jbdz59cjosxf/frames/'

Accessing the video_dir, video_download_dir and video_path

  • The video_path is the absolute path of the video from which the frames are extracted.
  • The video_dir is the directory containing the video from which instance extracts the frames, if you passed an URL the video is download in the video_download_dir and then copied to the video_dir and if you pass a video path the video is directly copied to the video_dir.
  • The video downloaded are stored in video_download_dir.
>>> videohash1.video_path
'/tmp/tmprf3g8gqi/temp_storage_dir/jbdz59cjosxf/video/video.webm'
>>> videohash1.video_dir
'/tmp/tmprf3g8gqi/temp_storage_dir/jbdz59cjosxf/video/'
>>> videohash1.video_download_dir
'/tmp/tmprf3g8gqi/temp_storage_dir/jbdz59cjosxf/downloadedvideo/' 

Attributes of VideoHash objects

The VideoHash objects have some useful attributes and they are described here.

hash

hash_hex

bits_in_hash

bitlist

collage_path

image

path

url

storage_path

video_path

task_uid

Clone this wiki locally