Video editing

Video recordings could be useful for people attending a course later, but also are (perhaps more) useful for immediate review and catching up after missing a day in a workshop. For this, they need to be released immediately, within a few hours of the workshop. CodeRefinery can do this.

Hypothesis: videos must be processed the same evening as they were recorded, otherwise (it may never happen) or (it’s too late to be useful). To do that, we have to make processing good enough (not perfect) and fast and distributeable

Primary articles

Summary

  • Basic principle: privacy is more important than any other factor. If we can’t guarantee privacy, we can’t release videos at all.

    • Disclaimers such as “if you don’t want to appear in a recording, leave your video off and don’t say anything”, since a) accidents happen especially when coming back from breakout rooms. b) it creates an incentive to not interact or participate in the course.

  • Livestreaming is important here: by separating the instruction from the audience audio/video, there is no privacy risk in the raw recording. They could be released or shared unprocessed.

  • Our overall priorities

    1. No learner (or anyone not staff) video, audio, names, etc. are present in the recordings.

    2. Good descriptions.

    3. Removing breaks and other dead time.

    4. Splitting videos into useful chunks (e.g. per-episode), perhaps equal with the next one:

    5. Good Table of Contents information so learners can jump to the right spots (this also helps with “good description”.)

  • ffmpeg-editlist allows us to define an edit in a text file (crowdsourceable on Github), and then generate videos very quickly.

Exercises

Exercise A

These exercises will take you through the whole sequence.

Editing-1: Get your sample video

Download a sample video:

Editing-2: Run Whisper to generate raw subtitles and test video.

First off, install Whisper and generate the base subtitles, based on the. Since this is probably too much to expect for a short lesson, they are provided for you (above), but if you want you can try using Whisper, or generating the subtitles some other way.

You can start generating subtitles now, while you do the next steps, so that they are ready by the time you are ready to apply the editlist. ffmpeg-editlist can also slice up the subtitles from the main video to make subtitles for each segment you cut out.

Whisper is left as an exercise to the reader.

Editing-3: Create the basic editlist.yaml file

Install ffmpeg-editlist and try to follow its instructions, to create an edit with these features:

  • The input definition.

  • Two output sections: the “Intro to the course”, and “From data storage to your science” talks (Remember it said the recording started at 11:35… look at the schedule for hints on when it might start!). This should have a start/end timestamp from the original video.

A basic example:

- input: day1-raw.mkv

# This is the output from one section.  Your result should have two of these sections.
- output: part1.mkv
  title: something
  description: >-
    some long
    description of the
    segment
  editlist:
    - start: 10:00    # start timestamp of the section, in *original* video
    - end: 20:00      # end timestamp of the section, in the *original* video

Discussion: what makes a video easy to edit?

  • Clear speaking and have high audio quality.

  • For subtitle generation: Separate sentences cleanly, otherwise it gets in a “stream of words” instead of “punctuated sentences” mode.

  • Clearly screen-sharing the place you are at, including section name.

  • Clear transitions, “OK, now let’s move on to the next lesson, LESSON-NAME. Going back to the main page, we see it here.”

  • Clearly indicate where the transitions are

  • Hover mouse cursor over the area you are currently talking about.

  • Scroll screen when you move on to a new topic.

  • Accurate course webpage and sticking to the schedule

All of these are also good for learners. By editing videos, you become an advocate for good teaching overall.

Editing-4: Run ffmpeg-editlist

Install ffmpeg-editlist: pip install ffmpeg-editlist[srt] (you may want to use a virtual environment, but these are very minimal dependencies).

The ffmpeg command line tool must be available in your PATH.

Editing-5: Add more features

  • Several chapter definitions.(re-run and you should see a .info.txt file also generated). Video chapter definitions are timestamps of the original video, that get translated to timestamps of the output video.

    - output: part1.mkv
      editlist:
      - start: 10:00
      - -: Introduction    #  <-- New, `-` means "at start time"
      - 10:45: Part 1      #  <-- New
      - 15:00: Part 2      #  <-- New
      - end: 20:00
    

    Look at the .info.txt files that come out now. What is new in it?

  • Add in “workshop title”, “workshop description”, and see the .info.txt files that come out now. This is ready for copy-pasting into a YouTube description (first line is the title, rest is the description).

    Look at the new .info.txt files. What is new?

Editing-6: Subtitles

Re-run ffmpeg-editlist with the --srt option (you have to install it with pip install ffmpeg-editlist[srt] to pull in the necessary dependency). Notice how .srt files come out now.

Use some subtitle editor to edit the original subtitle file, to fix up any transcription mistakes you may find. You could edit directly, use subtitle-editor on Linux, or find some other tool.

What do you learn from editing the subtitles?

Editing-6: Subtitles

Re-run ffmpeg-editlist with the --srt option (you have to install it with pip install ffmpeg-editlist[srt] to pull in the necessary dependency). Notice how .srt files come out now.

Use some subtitle editor to edit the original subtitle file, to fix up any transcription mistakes you may find. You could edit directly, use subtitle-editor on Linux, or find some other tool.

What do you learn from editing the subtitles?

Editing-7: Generate the final output file.

  • Run ffmpeg-editlist with the --reencode option: this re-encodes the video and makes sure that there is no black point at the start.

  • If you re-run with --check, it won’t output a new video file, but it will re-output the .info.txt and .srt files. This is useful when you adjust descriptions or chapters.

Discussion: how to distribute this?

Create a flowchat of all the parts that need to be done, and which parts can be done in parallel. Don’t forget things that you might need to do before the workshop starts.

How hard was this editing? Was it worth it?

Exercise B

This is similar to the above but more brief and not on a real example video.

Use ffmpeg-editlist to edit this sample video

Prerequisites: ffmpeg must be installed on your computer outside of Python. Be able to install ffmpeg-editlist. This is simple in a Python virtual environment, but if not the only dependency is PyYAML.

See also