Skip to content

Instantly share code, notes, and snippets.

View mohit-0212's full-sized avatar

Mohit Agarwal mohit-0212

View GitHub Profile
@mohit-0212
mohit-0212 / fingerprint.py
Created March 18, 2018 14:44
Matching audio fingerprint
#After setting up, dejavu locally on my machine
#Credits and Reference: https://github.com/worldveil/dejavu
import warnings
import json
import subprocess
import moviepy.editor as mp
warnings.filterwarnings("ignore")
from dejavu import Dejavu
@mohit-0212
mohit-0212 / video_cover.py
Created March 1, 2018 23:08
Finding intro end time using end intro cover image
import cv2
import numpy as np
import matplotlib.pyplot as plt
from skimage.measure import compare_ssim
vid_frame = cv2.VideoCapture('/path for/video file/')
cover = cv2.cvtColor(cv2.imread('/path for/cover image/'), cv2.COLOR_BGR2GRAY)
length = vid_frame.get(cv2.CAP_PROP_FRAME_COUNT)
fps = vid_frame.get(cv2.CAP_PROP_FPS)
@mohit-0212
mohit-0212 / read_audio.py
Created February 23, 2018 22:13
Analysing audio signals of a video
import subprocess
import numpy as np
import scipy
import librosa
import matplotlib.pyplot as plt
file_input = "/path for/video file/"
file_output = "/path for/output audio file.wav/"
command = "ffmpeg -i " + file_input +" -t 300 -codec:a pcm_s16le -ac 1 "+ file_output #converts the first 5 minutes of video file to wav output
@mohit-0212
mohit-0212 / read_video.py
Created February 23, 2018 21:54
Detecting intro from video frames
import cv2
import numpy as np
import matplotlib.pyplot as plt
vid_frame = cv2.VideoCapture('/path for/video file/')
length = vid_frame.get(cv2.CAP_PROP_FRAME_COUNT)
fps = vid_frame.get(cv2.CAP_PROP_FPS)
num_frames = int(fps*300) #number of frames in first 5 minutes