-
Notifications
You must be signed in to change notification settings - Fork 55
Extended Usage
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
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
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")
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/'
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/'
- 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 thevideo_download_dir
and then copied to thevideo_dir
and if you pass a video path the video is directly copied to thevideo_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/'
The VideoHash objects have some useful attributes and they are described here.