What does the library do with non-video files? #81
Answered
by
akamhy
phirestalker
asked this question in
Q&A
-
I would like to know what the behavior is if I feed it a file that is not a video file. I am writing a simple program using this library for the command line. To keep it simple I would like to avoid having to check mime types. |
Beta Was this translation helpful? Give feedback.
Answered by
akamhy
Dec 25, 2021
Replies: 1 comment 1 reply
-
If you will pass URLs and don't know if video exits or not(including non-video files).
>>> from videohash import VideoHash
>>> videohash1 = VideoHash(url="https://github.com/akamhy/videohash/discussions/81")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/videohash.py", line 81, in __init__
self._copy_video_to_video_dir()
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/videohash.py", line 284, in _copy_video_to_video_dir
Download(
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/downloader.py", line 51, in __init__
self.download_video()
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/downloader.py", line 85, in download_video
raise DownloadFailed(
videohash.exceptions.DownloadFailed: '/tmp/test/venv/bin/yt-dlp' failed to download the video at 'https://github.com/akamhy/videohash/discussions/81'.
[generic] 81: Requesting header
[generic] 81: Downloading webpage
[generic] 81: Extracting information
WARNING: [generic] Falling back on generic information extractor.
ERROR: Unsupported URL: https://github.com/akamhy/videohash/discussions/81
>>> If you will pass the file path and the file type is not supported by FFmpeg because it's not a Video/Image.
Text file: >>> videohash1 = VideoHash(path="/tmp/test/abcd.txt")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/videohash.py", line 83, in __init__
FramesExtractor(self.video_path, self.frames_dir, interval=self.frame_interval)
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/framesextractor.py", line 76, in __init__
self.extract()
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/framesextractor.py", line 225, in extract
raise FFmpegFailedToExtractFrames(
videohash.exceptions.FFmpegFailedToExtractFrames: FFmpeg could not extract any frames.
"/usr/bin/ffmpeg" -i "/tmp/tmplmtyf5s3/temp_storage_dir/MWCnrs7Ac08NFGYLMIHO/video/video.txt" -s 144x144 -r 1 "/tmp/tmplmtyf5s3/temp_storage_dir/MWCnrs7Ac08NFGYLMIHO/frames/video_frame_%07d.jpeg"
ffmpeg version 4.4-6ubuntu5 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-7ubuntu1)
configuration: --prefix=/usr --extra-version=6ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=6ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
/tmp/tmplmtyf5s3/temp_storage_dir/MWCnrs7Ac08NFGYLMIHO/video/video.txt: Invalid data found when processing input
>>> Music file: >>> videohash1 = VideoHash(path="/home/akamhy/Music/Aaron_Smith_Dancin_KRONO_Remix.mp3")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/videohash.py", line 83, in __init__
FramesExtractor(self.video_path, self.frames_dir, interval=self.frame_interval)
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/framesextractor.py", line 76, in __init__
self.extract()
File "/tmp/test/venv/lib/python3.9/site-packages/videohash/framesextractor.py", line 225, in extract
raise FFmpegFailedToExtractFrames(
videohash.exceptions.FFmpegFailedToExtractFrames: FFmpeg could not extract any frames.
"/usr/bin/ffmpeg" -i "/tmp/tmpu2k9tn9h/temp_storage_dir/ctHXgLO6POBQsiBprs0W/video/video.mp3" -s 144x144 -r 1 "/tmp/tmpu2k9tn9h/temp_storage_dir/ctHXgLO6POBQsiBprs0W/frames/video_frame_%07d.jpeg"
ffmpeg version 4.4-6ubuntu5 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-7ubuntu1)
configuration: --prefix=/usr --extra-version=6ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=6ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, mp3, from '/tmp/tmpu2k9tn9h/temp_storage_dir/ctHXgLO6POBQsiBprs0W/video/video.mp3':
Metadata:
encoder : Lavf58.76.100
Duration: 00:03:24.53, start: 0.023021, bitrate: 123 kb/s
Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 123 kb/s
Metadata:
encoder : Lavc58.13
Output #0, image2, to '/tmp/tmpu2k9tn9h/temp_storage_dir/ctHXgLO6POBQsiBprs0W/frames/video_frame_%07d.jpeg':
Output file #0 does not contain any stream
>>> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
phirestalker
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@phirestalker
If you will pass URLs and don't know if video exits or not(including non-video files).
videohash.exceptions.DownloadFailed