Package: ffmpeg-editlist
ffmpeg editlist utilityOften, one wants to reprocess a video file using some basic
operations, such as removing certain segments.  Rather than opening a
video editor, it is nice to be able to define a text file (theeditlist) with processing instructions, and then run it.  This
allows collaboration in the processing, for example sharing the
editlist file via git.This utility takes a YAML definition of an editlist (segments to cut
out and re-assemble into a file), and does the re-assembling using the
ffmpeg command line utility.This is currently an alpha-level utility: it works, but expect it may
not exactly fit your use case without a bit of work.  Documentation is
minimal but still needs improvement.  However, it has been used for
several large events.Video demonstration:https://youtu.be/thvMNTBJg2YFeatures include:YAML edit list definition.Select segments to stitch together in the final video file.
Segments are either copied raw or re-encoded (--reencode).Give Table of Contents times (for example, '16:45: Lesson 2 begins')
relative to the source video, output mapped to times in
the output video automatically.Cover certain areas of video (for example, when an audience member
appears).Everything scripted and non-interactive.Cutting and re-splicing subtitles, too.Installation and dependenciesThis is on PyPI, may be installed withpip install ffmpeg-editlist.
The only dependency is PyYAML so it might be reasonable to install
withpip install --user.  This creates affmpeg-editlistcommand
in your environment.For usage without installing,ffmpeg_editlist.pyworks as
stand-alone with onlypyyaml.It depends on theffmpegcommand line utility, which must be
installed through the operating system.  Version requirements offfmpegare currently unknown.UsageStart with a directory of your videos (example:day1-raw.mkv).Create an edit list file (described in next section).  A minimal
example is:-input:day1-raw.mkv-output:part1.mkvtitle:This is the title of part1description:>-This is the multi-line descriptionof part 1.editlist:-start:00:00# These are time segments to include-4:00:Begin exercise 1-stop:5:00-start:6:13--:Going over the exercises# '-' means "latest start time".-stop:99:00The general usage is then:python ffmpeg-editlist.py EDITLIST.yaml INPUT-DIR [-o OUTPUT-DIR]WhereINPUT-DIRis the search path for input files andOUTPUT-DIR(default.) is the output path for files.  You can use the--limit PATTERNoption to reprocess only a few videos (example:--limit part1).Because of the way keyframes work, there may be missing segments
around the transition points.  After you have tested that your timings
seem reasonable, re-run with--reencodeand it will do a full
re-encoding and make a seamless videos.  The default encoding settings
are designed to be slow but good enough for all practical purposes:python ffmpeg-editlist.py EDITLIST.yaml --reencode INPUT-DIR [-o OUTPUT-DIR]OUTPUT-DIRwill get the encoded files, and.txtfiles with the
video descriptions ready to upload to your video hosting site.Subtitles: The option--srtwill make ffmpeg-editlist reprocess
subtitles just like video segments (cut to the segments and adjust
timestamps).  A.srtfile is expected alongside each input file
(input file's extension replaced with.srt), and an output is
similarly placed alongside each output.  Warning: make sure that no
segment's declared stop time goes beyond the actual file length.  It's
possible that there will be some weird effects around the
beginning/end of the segments if subtitles go beyond the start/stop.Editlist definitionMinimal example: single file# Input is taken from command line argument `input`.-output:output.mp4title:This is the titledescription:>-This is the multi-line description.editlist:-start:00:00# These are time segments to include-stop:5:00-start:6:13-stop:99:00Run withpython ffmpeg-editlist.py editlist.yaml input.mkv.Minimal example with multiple files-input:raw-day1.mkvoutput:day1-part1.mkveditlist:-start:1:12-stop:55:30# Previous input file is used if no new input is defined-output:day1-part2.mkveditlist:-start:1:00:12-stop:1:54:00Run withpython ffmpeg-editlist.py editlist.yaml $input_directory.Multi-file with video descriptionsThis is a full example that demonstrates all features.-workshop_description:>If this exists, it will be appended to the bottom of every videodescription.  For example, it can be general information about theoverall workshop.# This input will be used for all segments until redefined# Input relative to the input-dir command line argument.# If not given, use the raw input-dir argument as a filename.-input:cr-2021may-day1-obs.mov# A basic example# Output is relative to the output-dir command line argument.-output:day1-welcome.mp4# If given, do not reencode this segment even if --reencode is given# (useful for segments that start at 00:00).  'reencode: true' does# nothing, this is the default and --reencode must still be# specified on the command line.#reencode: falseeditlist:-start:12:20-stop:31:14# Git-intro day 1-output:day1-git-intro-1.mp4# Output filenametitle:YouTube Video Titledescription:>Description of the video.editlist:# These pairs are times to *include*-start:31:14-stop:38:13-start:41:28-stop:1:04:45# A sample including table of contents entries.# You need to map times from the raw file, to the output file, in# order to make a clickable YouTube table of contents.# They are times in the# original video, and they are converted to the equivalent times in# the processed videos. They must be within the ranges above (and# you get a unhandled error if they aren't):#   segment_start <= toc_time < segment_stop.# These can be interspersed with the segment definitions.# Example:-output:day2-git-intro-2.mp4editlist:-start:31:14# TOC entry:-31:14:Overview of the day-33:25:Motivation to version control-stop:38:13-start:41:28--:Basics of version control# '-' is an alias for "last start"-48:35:"Exercise:recordchanges"# has a ':', so must be quoted-stop:1:04:45#- 1:18:22: This will fail, timestamp after the endThis syntax is used to cover a segment of the video:-output:day3-has-audience-visible.mp4editlist:-start:00:00# Cover an area.  begin/end are clear.  w and h are width and# height.  x and y are offset (left, down) from the top-left corner-cover:{begin:"1:15:29",end:"1:51:34",w:840,h:300,x:360}-stop:5:00Alongside the.mp4output file, a.mp4.info.txtfile is created
with these contents.  This is designed for easy copying and pasting
into hosting sites:Title of Video

Video description.

01:53 Table of contents entry 1
15:45 Table of contents entry 2
...


Workshop description.Multiple inputsMultiple inputs in one segment might be useful when you are attaching
an introduction to the main video.  Note that things might go wrong if
the video sizes and codecs do not align perfectly.  (TODO: does this
work as expected?)-output:output.mp4editlist:-input:intro.mkv-start:00:00-stop:99:00-input:main.mkv-start:0:00-stop:99:00-input:outro.mkv-start:0:00-stop:99:00See alsohttps://trac.ffmpeg.org/wiki/Concatenatehttps://stackoverflow.com/q/7333232Inspired byhttps://github.com/mvdoc/budapest-fmri-data/blob/master/scripts/preprocessing-stimulus/split_movie.shmpv (https://mpv.io/) is a video player with good command line
interface, keyboard shortcuts, and scriptable so that you can make a
hotkey that copies the current time.script for the mpv video player, which can copy the time when you
push a button.  Might need some modification:https://github.com/Kr4is/mpv-copy-time[and]change the playback speed.Ocauses time to be
permanently shown.→and←seek,↑and↓seek longer, and--hr-seekallows seeking exactly.Control+→,Control+←allow seeking to the next/previous subtitle.Status / ContributingAlpha/beta, under development, it is starting to become reusable but
still development is for a few use cases.  In order to use this you
probably have to read some code / work around some bugs since it isn't
well tested yet.Bug reports or improvements welcome, but it is kind of a mess now.
Test withpytest ffmpeg-editlist.py, but note that main
functionality is not tested right now.