Code Monkey home page Code Monkey logo

video-analyzer's Introduction

Video Analyzer

This web app will compare and analyze two videos and determines the similarity score between them.

๐Ÿ“œ Instructions to run

  1. Clone the repository
    git clone https://github.com/MusfiqDehan/video-analyzer.git
  2. Change the working directory
    cd video-analyzer
  3. Setup and run pipenv environment
    pipenv shell
  4. Install dependencies
    pip3 install -r requirements.txt
  5. Run the app
    python3 app.py
  6. Go to http://127.0.0.1:5000/

๐Ÿ“š Libraries used and why I am using them

Here are the use cases of the library imports used in the app.py script and why they are used for this project:

  1. cv2: This is the OpenCV library, which is used for image and video processing. In this project, it is used to extract frames from video files.

  2. Flask: These are all part of the Flask web framework, which is used to create the web application. Flask is the main Flask class, redirect and url_for are used to redirect the user to different pages, render_template is used to render HTML templates, request is used to handle HTTP requests, and jsonify is used to return JSON responses.

  3. BadRequest: This is an exception class from the Werkzeug library, which is used to handle HTTP errors. In this project, it is used to raise a BadRequest exception if the user does not upload both videos.

  4. numpy: This is a numerical computing library for Python. In this project, it is used to perform numerical operations on arrays of video frames.

  5. os: This is a module for interacting with the operating system. In this project, it is used to join file paths and get the current working directory.

  6. pytube: This is a library for downloading YouTube videos. In this project, it is used to download YouTube videos for comparison.

  7. scipy.spatial.distance, scipy.io.wavfile, scipy.signal.resample: These are all part of the SciPy library, which is used for scientific computing. In this project, they are used to calculate the similarity between two videos based on their audio and visual features.

  8. skimage: These are part of the scikit-image library, which is used for image processing. In this project, they are used to calculate the structural similarity index (SSIM) between two video frames.

  9. python_speech_features: This is a library for computing Mel-frequency cepstral coefficients (MFCCs), which are commonly used in speech recognition. In this project, it is used to extract audio features for comparison.

  10. subprocess: This is a module for running external commands. In this project, it is used to run the ffmpeg command to extract audio from video files.

  11. tempfile: This is a module for working with temporary files and directories. In this project, it is used to create a temporary directory for storing downloaded videos.

  12. urllib.request: This is a module for working with URLs. In this project, it is used to download videos from URLs.

  13. librosa: This is a library for audio analysis. In this project, it is used to extract audio features for comparison.

  14. moviepy: This is a library for video editing. In this project, it is used to extract audio from video files.

  15. pyAudioAnalysis: This is a library for audio analysis. In this project, it is used to segment audio files into speech and non-speech regions.

video-analyzer's People

Contributors

imgbotapp avatar musfiqdehan avatar

Stargazers

 avatar

Watchers

 avatar

video-analyzer's Issues

Error after clicking "Compare"

I am using a MacBook Air M2 on MacOS 12.5.

I tried to compare two videos, but I got this error in the Terminal window:

127.0.0.1 - - [02/Jan/2024 14:11:02] "POST / HTTP/1.1" 302 -
[2024-01-02 14:11:02,130] ERROR in app: Exception on /compare [GET]
Traceback (most recent call last):
File "/Users/user/.local/share/virtualenvs/video-analyzer-MzrZxvID/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/Users/user/.local/share/virtualenvs/video-analyzer-MzrZxvID/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/user/.local/share/virtualenvs/video-analyzer-MzrZxvID/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/user/.local/share/virtualenvs/video-analyzer-MzrZxvID/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/Users/user/video-analyzer/app.py", line 171, in compare
similarity_percentage = calculate_similarity(video1_path, video2_path)
File "/Users/user/video-analyzer/app.py", line 143, in calculate_similarity
audio1_path = extract_audio(video1_path)
File "/Users/user/video-analyzer/app.py", line 61, in extract_audio
audio.write_audiofile(audio_path, logger=None)
AttributeError: 'NoneType' object has no attribute 'write_audiofile'
127.0.0.1 - - [02/Jan/2024 14:11:02] "GET /compare?video1=replicate-prediction-hgc6twjbvmodfahzh6zlbqwfwu.mp4&video2=replicate-prediction-aq42cmrbx5bi56isehhfgbbo3i.mp4 HTTP/1.1" 500 -

The webpage said this:

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Is there something I am missing? What should I do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.