#ffmpeg #summarize #shorten #performance

app video-summarizer

Application that uses FFMPEG to summarize video. Infers which parts of the video are silent or loud and speeds them up at different rates. Great for long lecture videos.

3 stable releases

1.2.3 Jan 1, 2020
1.2.2 Dec 30, 2019
1.2.1 Sep 30, 2019

#209 in Video

Custom license

34KB
614 lines

DISCLAIMER: This is work in progress. It is not yet to be used anywhere where it's important that it doesn't fail. If it doesn't work, file a github issue. Things generally work, but workarounds often include "not messing too much with piping video in/out".

PROGRESS: We are working on implementing much faster and efficient way to use this tool. From hours of processing to few seconds. The disadvantage is that vlc media player will become mandatory dependency. You can track progress in the vlc branch.

This application lets user speed up video at varying rates, based on current loudness. For example, I can speed up loud parts of a lecture 1.5x, and the silent parts 5x. Application does this by taking audio and search where the audio has suspiciously constant level for big amount of time. Afterwards, I just split it, speed it up, and concatenate it via ffmpeg. This was done primarily to learn more about Rust, but the result are actually much better than I thought. I think this would actually be viable to use in case of internet lectures.

See the Results section for analysis I did few versions ago.

Usage

Convert multiple lecture files. Speed up loud parts 1.5x and silent parts 5x.

for lecture-video in *.mp4; do
	video-summarizer -l 1.5 -s 5 "$lecture_video" -o "NEW-$lecture_video"
done

I don't care about quality, I need it NOW.

video-summarizer -l 2.5 -s 7 --fast video.mp4 -o new-video.mp4

Cut silent parts out of a video.

video-summarizer -s 100 video.mp4 -o video-cut.mp4

Download audio of a very long talk from youtube, speed up loud parts 2x and silent parts 4x, and pipe that into VLC.

youtube-dl -f 'bestaudio[ext=m4a]' 'https://www.youtube.com/watch?v=KSWqx8goqSY' -o - |
video-summarizer --audio -l 2 -s 4 - -o - |
vlc -

Install

Make sure you have required dependencies and either download binary from releases, or build it yourself. I suggest you to download binary if you want to just try it, but the best option is building directly from Rust repository. Everything, including updates, is taken care of.

Install ffmpeg [apt] [pacman] in order to use this program.

If you want to build it yourself, you'll need to install rust [apt] [pacman] and git [apt] [pacman] as well.

Build from Rust repository

cargo install video-summarizer

Build from source

# Clone this repository
git clone https://github.com/SoptikHa2/video-summarizer.git
# Compile debug build to verify everything works
cd video-summarizer
cargo build
target/debug/video-summarizer -h
# Install release build
cargo install
# Run
# this will speedup loud parts 1.5x and completely drop silent parts (as speedup factor is >= 100)
video-summarizer -l 1.5 -s 100 path/to/video

Dependencies

Build dependencies

Runtime dependencies

Results

Everything was tested with ffmpeg 4.2, and video summarizer 1.1.1. Settings: -l 1.5 -s 100.

Name Duration (s) Silent time (%) Saved time (s)
DEFCON 17: That Awesome Time I Was Sued For Two Billion Dollars 1887 15.32% 822 (43.55%)
1. Introduction and Scope (MIT AI course) 2838 40.12% 1706 (60.08%)
Black Mirror: White Christmas 4326 11.93% 1786 (41.29%)
Puella Magi Madoka Magica Ep 10 1449 7.22% 553 (38.15%)

Known issues

  • The youtube piping example fails for some reason.

Dependencies

~6MB
~108K SLoC