https://github.com/ryanfox/retread
Detect reused frames in video
https://github.com/ryanfox/retread
Last synced: about 1 year ago
JSON representation
Detect reused frames in video
- Host: GitHub
- URL: https://github.com/ryanfox/retread
- Owner: ryanfox
- Archived: true
- Created: 2016-05-26T02:09:01.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-05-03T03:53:59.000Z (about 4 years ago)
- Last Synced: 2024-08-03T20:12:13.043Z (almost 2 years ago)
- Language: HTML
- Size: 6.84 KB
- Stars: 29
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# retread
Detect reused frames in video with Python.
Retread works by computing a hash for each frame in a video (dhash, [described here](http://www.hackerfactor.com/blog/?/archives/529-Kind-of-Like-That.html) if you're interested).
It then counts how many times in the video that frame is reused. Once the duplicates are calculated, the data is output in JSON format, suitable for use in e.g. [D3.js](https://d3js.org/).
A video with low reuse across the board doesn't repeat many frames - not many duplicated shots, and not very long static images either. For example, _Mad Max Fury Road_, a fast-moving film with short shots and quick cuts:

A video with high spikes reuses a lot of short shots or single images. For example, _Memento_, a film notable for its nonlinear story, cutting forward and backward across the same scenes:

## Installation
Clone the repository:
$ git clone git@github.com:ryanfox/retread.git
Install dependencies:
$ cd retread
$ pip install -r requirements.txt
## Usage
### Quickstart
$ python retread.py my_video.mp4 > scores.json
Open `bar.html` in a browser to see the data plotted.
### Advanced usage
Process a video file:
$ python retread.py my_video.mp4 > scores.json
`scores.json` will contain a list of integers, where each element is the number of duplicates that frame had in the original.
Processing a video can take a while - several minutes for a feature-length file. There are a lot of frames to analyze! If you want to reprocess the same video without waiting, you can use the flag `-s` (for "save") to save the hashes for later:
$ python retread.py -s my_video.mp4 > scores.json
The hashes will be saved in `my_video.mp4.json`. retread will overwrite the file if it already exists.
To reuse saved hashes, use the flag `-u` (for "use"):
$ python retread.py -u my_video.mp4.json > scores.json
This will read the saved hashes (much faster than re-processing the whole video), do the duplicate analysis, and write the duplicate counts to standard out as usual.
To see what the most-duplicated frames are, you can save a jpeg image of the N most common frames. Use the flag `-c` (for "common"):
$ python retread.py -c 5 my_video.mp4 > scores.json
$ ls
0.jpg
1.jpg
2.jpg
3.jpg
4.jpg
my_video.mp4
[etc...]
This can be combined with `-u`, but you still need to specify the video file):
$ python retread.py -u my_video.mp4.json -c 5 my_video.mp4 > scores.json
$ ls
0.jpg
1.jpg
2.jpg
3.jpg
4.jpg
my_video.mp4
my_video.mp4.json
[etc...]