cut-the-crap 2.3.0 → 2.3.1
raw patch · 6 files changed
+45/−20 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Cut.Analyze: instance GHC.Generics.Generic (Cut.Analyze.Interval e)
Files
- Changelog.md +5/−0
- Readme.md +1/−8
- cut-the-crap.cabal +2/−2
- src/Cut/Analyze.hs +35/−9
- src/Cut/Options.hs +1/−1
- src/Cut/Shell.hs +1/−0
Changelog.md view
@@ -1,5 +1,10 @@ # Change log for cut-the-crap +## Version 2.3.1 - 2020.11.05+++ Fix ssl cert check failure for the bundle. We disable it.++ Fix final segment being cut off.+ ## Version 2.3.0 - 2020.11.01 + Hide extractDir from cutvideo
Readme.md view
@@ -41,19 +41,12 @@ ``` ## Bundle build (staticly linked bundled with runtime deps)- From version 2.1.1 and onwards these nix bundles will be attached to releases on the [release page](https://github.com/jappeace/cut-the-crap/releases). These should work on any Linux distribution.-The cost is that they are large files however (500mb+) because everything is bundled within.-Including runtime dependencies such as ffmpeg and youtube-dl.- Download the executable from the [release page](https://github.com/jappeace/cut-the-crap/releases). -Releases of this kind trail the main release by a week because we rely on the-hackage release being merged into nixpkgs.-At the moment this appears to happen every Friday.-This approach guarantees nix reproducibility without having to install nix. Under the hood we use [nix-bundle](https://github.com/matthewbauer/nix-bundle) for this.+These are so large because everything from libc to youtube-dl are packaged within. ## Nix/Nixos
cut-the-crap.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a94f8d4d0113c8b65676de74ee32dab0a435060472c513bc16cc2036c2fb1adb+-- hash: 557a97d6569976501592fb79ffc6d8141f2fd410ba6d31c394c1f408e2058021 name: cut-the-crap-version: 2.3.0+version: 2.3.1 synopsis: Cuts out uninteresting parts of videos by detecting silences. description: Cut the crap is an automatic video editing program for streamers. It can cut out uninteresting parts by detecting silences. This was inspired by [jumpcutter](https://github.com/carykh/jumpcutter), where this program can get better quality results by using an (optional) dedicated microphone track. This prevents cutting of [quieter consonants](https://youtu.be/DQ8orIurGxw?t=675) for example. Using ffmpeg more efficiently also produces faster results and is less error prone. category: video
src/Cut/Analyze.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE DataKinds #-}+ module Cut.Analyze ( detectSoundInterval , Interval(..)@@ -27,17 +29,24 @@ import Data.Text.Lens import Shelly hiding (find, shelly) import Text.Regex.TDFA hiding (empty)+import GHC.Generics (Generic) data Silent data Sound -data Interval e = Interval+-- | I think we can only detect silence with ffmpeg, so we flip the+-- silent to sounded intervals, and :+-- if x indicates silence:+-- silence: xxx___xxx__xxxx____xxxxx__xx+-- sounded: ___xxx___xx____xxxx_____xx__+data Interval e =+ Interval { interval_start :: Double , interval_end :: Double , interval_duration :: Double , interval_input_start :: Text , interval_input_end :: Text- } deriving Show+ } deriving (Show, Generic) detectSoundInterval :: (MonadMask m, MonadUnliftIO m) => ListenCutOptions -> m [Interval Sound] detectSoundInterval opts = do@@ -76,6 +85,11 @@ liftIO $ putStrLn "-----------------------------------------" liftIO $ traverse_ print parsed + liftIO $ putStrLn "-----------------------------------------"+ liftIO $ putStrLn "-----------------sounds-----------------"+ liftIO $ putStrLn "-----------------------------------------"+ liftIO $ traverse_ print fancyResult+ if isJust negativeResult then do liftIO $ traverse_ print fancyResult@@ -103,21 +117,33 @@ detectSilence :: ListenCutOptions -> [Interval Silent] -> [Interval Sound] detectSilence _ = coerce +-- TODO: we can't process videos that are longer then a week.+finalSound :: Interval Silent+finalSound = Interval week (week+1) 1 "" ""+ where+ week = day * 7+ day = 60*60*24+ detectSound :: ListenCutOptions -> [Interval Silent] -> [Interval Sound]-detectSound opts =- -- -- TODO figure out why these durations get recorded as < 0- reverse . snd . foldl' (flip (compare' opts)) (Interval 0 0 0 "" "", [])+detectSound opts silences =+ reverse $ snd $ fun soundedParts finalSound+ where+ soundedParts :: (Interval Silent, [Interval Sound])+ soundedParts = foldl' fun (Interval 0 0 0 "" "", []) silences -compare'+ fun = flip $ silentIntoSounded opts+++silentIntoSounded :: ListenCutOptions -> Interval Silent -> (Interval Silent, [Interval Sound]) -> (Interval Silent, [Interval Sound])-compare' opts current prev = (current, soundedInterval : snd prev)+silentIntoSounded opts current prev = (current, soundedInterval : snd prev) where soundedInterval = Interval- { interval_start = interval_end $ fst prev- , interval_end = interval_start current - margin+ { interval_start = soundStart+ , interval_end = soundEnd - margin , interval_duration = (soundEnd - soundStart) + margin , interval_input_start = interval_input_start (fst prev) <> "," <> interval_input_end (fst prev)
src/Cut/Options.hs view
@@ -43,7 +43,7 @@ import Data.Generics.Sum import qualified Data.Text as Text import Data.Text.Lens-import GHC.Generics hiding (to)+import GHC.Generics (Generic) import Options.Applicative import Network.URI
src/Cut/Shell.hs view
@@ -59,4 +59,5 @@ args = [Text.pack $ show uri , "-o", Text.pack path' , "--merge-output-format", "mkv"+ , "--no-check-certificate" ]