packages feed

cut-the-crap 2.2.0 → 2.3.0

raw patch · 7 files changed

+70/−20 lines, 7 files

Files

Changelog.md view
@@ -1,5 +1,18 @@ # Change log for cut-the-crap +## Version 2.3.0 - 2020.11.01+++ Hide extractDir from cutvideo+  this is just a string, so shouldn't matter.++ Better default options.+  The result is cut much less aggressive making it more watchable.+  These defaults are also used on [videocut.org](https://videocut.org/)++ Improve CLI docs on various options.++ Fix bug where setting a relative workdir breaks the program.++ Add better bundle support which now isn't depended on nixpkgs+  releases.++ Add version to help output.+ ## Version 2.2.0 - 2020.10.28  + Add wrapper for shelly that always flushes stdout
Readme.md view
@@ -193,3 +193,19 @@ Since this program doesn't use scipy it doesn't have that issue.  It also appears like jumpcutter is unmaintained.++# Alternatives+This idea is obviously not new,+considering ffmpeg has first class support for it.+These are listed in no particular order:+++ [jumpcutter](https://github.com/carykh/jumpcutter)++ [jumpcutter laumans fork](https://github.com/Lamaun/jumpcutter)++ [Auto editor](https://github.com/WyattBlue/auto-editor)++ https://www.kapwing.com/tools/mute-video++ https://www.videomaker.com/forum/topic/how-to-remove-silence-from-a-video-automatically++Auto editor seems actively maintained and packed with features.+It's target audience is different, whereas I wish to host this project on+[videocut.org](https://videocut.org/) and make it available to everyone,+auto editor is to be a command line tool.
cut-the-crap.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 874f6bde8ebc71a27602d7507482631c4fce2134727e7205c01e989a952cdcaf+-- hash: a94f8d4d0113c8b65676de74ee32dab0a435060472c513bc16cc2036c2fb1adb  name:           cut-the-crap-version:        2.2.0+version:        2.3.0 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
@@ -57,10 +57,13 @@   liftIO $ putStrLn "-----------------------------------------"   liftIO $ Text.putStrLn $ Text.unlines (linesRes ^.. traversed . _Left) -  let linedUp        = zipped lines'+  let linedUp        :: [(Text, Text)]+      linedUp        = zipped lines'+      parsed         :: [Interval Silent]       parsed         = parse <$> linedUp-      detector       = if opts ^. cut_noise then detectSilence else detectSound+      fancyResult    :: [Interval Sound]       fancyResult    = detector opts parsed+      negativeResult :: Maybe (Interval Sound)       negativeResult = find ((0 >) . interval_duration) fancyResult    liftIO $ putStrLn "-----------------------------------------"@@ -79,6 +82,10 @@       liftIO $ print negativeResult       error "Found negative durations"     else pure fancyResult++  where+      detector       :: ListenCutOptions -> [Interval Silent] -> [Interval Sound]+      detector       = if opts ^. cut_noise then detectSilence else detectSound  takeOnlyLines :: Text -> Bool takeOnlyLines matchWith = matches
src/Cut/Crap.hs view
@@ -36,6 +36,9 @@ import           Shelly                       hiding (FilePath, shelly) import           System.IO.Temp import Cut.Download+import Paths_cut_the_crap (version)+import Data.Version (showVersion)+import Text.Printf  -- | reads settings from terminal and runs whatever command was --   given in program options@@ -85,9 +88,13 @@ readSettings :: IO (ProgramOptions InputSource) readSettings = customExecParser (prefs showHelpOnError) $ info   (parseProgram <**> helper)-  (fullDesc <> header "Cut the crap" <> progDesc+  (fullDesc <> header (printf "Cut the crap %s" curretVersion) <> progDesc     "Automated video extracting, can cut out silences"   )+++curretVersion :: String+curretVersion = showVersion version  musicFile :: FilePath musicFile = "music.mp3"
src/Cut/CutVideo.hs view
@@ -3,7 +3,6 @@ -- | Extract sounded parts, and combine again module Cut.CutVideo   ( extract-  , extractDir   , Interval(..)   , Silent   , Sound@@ -50,7 +49,7 @@   duration = floatToText $ interval_duration inter  extractDir :: FilePath-extractDir = "/extract"+extractDir = "extract"  extract :: ListenCutOptions -> FilePath -> [Interval Sound] -> IO () extract options tempDir intervals = do@@ -63,10 +62,10 @@         pure ["expection"]       )     $   toArgs options exdir <$> intervals-  liftIO $ putStrLn "finish extracting"+  liftIO $ putStrLn "finished extracting"    where-    exdir = tempDir <> extractDir+    exdir = tempDir </> extractDir  combineOutput :: FilePath combineOutput = "combined-output.mkv"@@ -86,14 +85,18 @@     , Text.pack (tempDir <> "/input.txt")     , "-c"     , "copy"-    , Text.pack $ tempDir <> "/" <> combineOutput+    , Text.pack $ tempDir </> combineOutput     ]  combineDir :: ListenCutOptions -> FilePath -> [Interval Sound] -> Sh () combineDir options tempDir intervals = do+  liftIO $ putStrLn "start combining the dir"   let paths = Text.unlines $ flip (<>) "'" . ("file '" <>) <$> res   writefile (fromText $ Text.pack $ tempDir <> "/input.txt") paths   combine tempDir   where     res = Text.pack . toFileName options exdir <$> intervals-    exdir = tempDir <> extractDir+    -- for relative dirs ffmpeg doesn't accept prepending of tempdir+    exdir = if hasWorkDir then extractDir else tempDir </> extractDir+    hasWorkDir :: Bool+    hasWorkDir = has (lc_fileio . work_dir . _Just) options
src/Cut/Options.hs view
@@ -66,7 +66,7 @@ simpleOptions = ListenCutOptions                         { lc_fileIO = simpleFileIO                         , lc_silentTreshold = _Just # def_silent-                        , lc_detectMargin   = _Just # def_margin+                        , lc_detectMargin   = _Just # def_detect_margin                         , lc_voiceTrack     = _Just # def_voice_track                         , lc_musicTrack     = Nothing                         , lc_silentDuration = _Just # def_duration@@ -111,8 +111,8 @@ def_voice_track :: Int def_voice_track = 1 -def_margin :: Double-def_margin = 0.05+def_detect_margin :: Double+def_detect_margin = def_duration / 2  def_cut_noise :: Bool def_cut_noise = False@@ -121,7 +121,7 @@ def_silent = 0.075  def_duration :: Double-def_duration = 0.25+def_duration = 0.5  def_voice :: Int def_voice = 1@@ -130,7 +130,7 @@ lc_fileio = field @"lc_fileIO"  detect_margin :: Lens' (ListenCutOptionsT a) Double-detect_margin = field @"lc_detectMargin" . non def_margin+detect_margin = field @"lc_detectMargin" . non def_detect_margin  silent_treshold :: Lens' (ListenCutOptionsT a) Double silent_treshold = field @"lc_silentTreshold" . non def_silent@@ -211,20 +211,24 @@             auto             (  long "silentDuration"             <> help-                 "The duration before soemthing can be considered a silence (d: https://ffmpeg.org/ffmpeg-filters.html#silencedetect)"+                 "The duration before something can be considered a silence (https://ffmpeg.org/ffmpeg-filters.html#silencedetect)"+            <> value def_duration <> showDefault             )           )     <*> optional           (option             auto-            (long "detectMargin" <> help "Margin seconds around detection")+            (long "detectMargin" <> help "Margin seconds around detection"+            <> value def_detect_margin <> showDefault+            )           )     <*> optional           (option             auto-            (long "voiceTrack" <> help "The track to detect the silences upon" <> value def_voice_track <> showDefault)+            (long "voiceTrack" <> help "The track to detect the silences upon"+             <> value def_voice_track <> showDefault)           )     <*> optional           (option auto (long "musicTrack" <> help "The track to integrate"))     <*> switch-          (long "cutNoise" <> help "Whether to cut noise instead of silence")+          (long "cutNoise" <> help "Do the opposite: Cut noise instead of silence")