Code Monkey home page Code Monkey logo

playphrase's Introduction

PlayPhrase

Search for specific words or phrases in subtitle files and watch video fragments with mpv.

Inspired by videogrep and playphrase.me.

Video

YouTube: PlayPhrase for Movies

Usage

Run python playphrase.py -i <media_dir> _init_ to generate txt files from srt files that will be used for search (only the first time or when you add new movies in your folder).

After that use python playphrase.py -i <media_dir> <phrase>

Regular expressions can be used in search, for example, \b for word boundary.

Keyboard Shortcuts

Use Enter to move to the next clip or Shift + < and Shift + > to switch between clips, Ctrl + Left and Ctrl + Right to move to the prev/next subtitle, q to close video player.

More info: https://mpv.io/manual/stable/#keyboard-control

Batch Scripts

There's videogrep.bat (Windows) and videogrep.sh (Linux) files to simplify user input. First time before running edit them and update media_dir path. Use quit, exit or q, x to exit from the batch script.

Here's a quick demo how to set up and run videogrep.bat on Windows (YouTube).

Additional Options:

  • -ph, --phrases GAP_BETWEEN_PHRASES move start time of the clip to the beginning of the current phrase. Value is optional (default=1.25 seconds)
  • -l, --limit maximum duration of the phrase (default=60 seconds)
  • -p, --padding padding in seconds to add to the start and end of each clip (default=0.0 seconds)
  • -e, --ending play only matching lines (or phrases)
  • -r, --randomize randomize clips
  • -o, --output name of the file in which output of 'grep' command will be written
  • -d, --demo only show grep results
  • -a, --audio create audio fragments
  • -v, --video create video fragments
  • -vs, --video-sub create video fragments with hardcoded subtitles
  • -s, --subtitles create subtitles for fragments
  • -m, --mpv-options OPTIONS mpv player options

Optional Configuration Changes

For example, you can modify mpv.conf

autofit=900
geometry=50%:50%

and input.conf

ENTER playlist-next force

More info: https://mpv.io/manual/

Download

See https://github.com/kelciour/playphrase/releases

Usage with AudioBooks

It's possible to use audiobooks as media input. For that purpose there's audiogrep.bat and audiogrep.sh files to simplify user input. But you need to generate subtitles for every audio file. It can be done almost automatically using aeneas. Also csplit can be used to split text of the book by chapters and Pragmatic Segmenter to split chapter's content by "sentences".

Here's example video how it looks like (YouTube):

YouTube: PlayPhrase for AudioBooks

Requirements

  • python 2.7
  • grep
  • mpv
  • ffmpeg

Note

  • playphrase requires the subtitle track and the video file to have the exact same name, up to the extension.

playphrase's People

Contributors

kelciour avatar

Watchers

Vince Lynch avatar

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.