Skip to content

sachac/subed-record

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

subed-record makes it easier to prepare text for subtitles, record a voiceover, and then compile a video that includes the visuals, audio, and subtitles specified by the text file.

I’m not sure it works for anyone but me at the moment, so if you run into a problem, it’s probably not you, it’s me. Let me know and/or help me figure it out! =)

Sacha Chua - sacha@sachachua.com - https://github.com/sachac/subed-record

Prerequisites

You will need:

  • subed is a mode for editing subtitles. It is not yet available as a package, but can get it from https://github.com/rndusr/subed .
  • mpv.el plays media files from within Emacs using the MPV command-line tool. mpv.el is available from MELPA, and MPV is available via either your operating system’s package manager or from https://mpv.io/ .
  • compile-media puts together the video.
  • subed-waveform is optional. You can use it to display the waveform for the current subtitle to help you fine-tune timestamps.

Process

Set things up

Take a look at the variables in M-x customize-group subed-record.

Draft the text and collect the visuals

You can draft your text in an Org Mode file, using file: links to include images or videos and #+CAPTION: to include captions. You may want to wrap your lines to be as short as they will be in captions.

Image and video information should be one per line. Here’s an example:

#+CAPTION: Emacs News Highlights - emacsconf.org/2021/talks/news
[[file:images/Screenshot_20211021_002952.png]]
I'm Sacha Chua, and here are
ten Emacs News highlights for 2021.
If you want to follow the links,
check out the wiki page at
https://emacsconf.org/2021/talks/news/ .
  • What if I want to include a section of a video or crop an image?
    • The current code doesn’t let you specify FFMPEG filters for a specific visual yet, but that’d be a neat addition. In the meantime, you can use your favourite editing tool to put the segment that you want into a file that can be included.

Create the subtitle file.

Create a subtitle file (ex: recording.vtt) with the segments you would like to record in one go.

WEBVTT

NOTE
#+CAPTION: Emacs News Highlights - emacsconf.org/2021/talks/news
[[[[file:images/Screenshot_20211021_002952.png]]]]

00:00:00.000 --> 00:00:00.000
I'm Sacha Chua, and here are
ten Emacs News highlights for 2021.

00:00:00.000 --> 00:00:00.000
If you want to follow the links,
check out the wiki page at
https://emacsconf.org/2021/talks/news/ .

If you’re starting with an Org Mode file, you can use subed-record-org-to-vtt to extract the text from the current Org subtree. It will keep captions and file links, and it will turn HTTP links into regular text. It creates a file based on the current filename, but with a .vtt extension.

Record the voiceover

Option A: Record the voiceover using Emacs

Pick an appropriate subed-record-backend, such 'sox if you have the command-line sox and rec tools.

Use subed-record to start the recording. It will save the recording into a file based on the name of the current subtitle file, but ending with subed-record-extension.

Default keybindings:

rightaccept current segment and continue
leftretry current segment
upgo back one segment
downgo forward one segment
RET or qstop recording

subed-record overwrites the recording file each time it is called. If you want to re-record a different segment and splice it into the rest of your presentation, you can create a new .vtt file and use subed-record to record into a different audio file. Then you can include that segment in your original .vtt file with an #+AUDIO: ... specification, like this:

00:00:45.864 --> 00:00:47.644
in his update, so check out his talk.

NOTE
#+AUDIO: native.ogg
#+CAPTION: emacsconf.org/2021/talks/native/
[[
00:00:00.970 --> 00:00:02.840
file:images/native-comp.png]]
Andrea Corallo's giving a talk

00:00:02.840 --> 00:00:04.475
#+AUDIO: native.ogg
on native compilation too.

NOTE: subed.el automatically sorts subtitles by timestamp. If you move subtitles around or use this technique to combine different audio files, you may need to disable automatic subed sorting with something like the following code:

(with-eval-after-load 'subed
  (remove-hook 'subed-sanitize-functions 'subed-sort))

Option B: Record the audio and edit it using your favourite tool, then create subtitles

Alternatively, you can start with an already-edited audio file and then use subed-mode’s commands to create, split, or adjust subtitles so that they match your audio file.

Split the subtitles into shorter captions

Load the recording with C-c C-v (subed-mpv-find-video). You may want to turn off looping with C-c C-l (subed-toggle-loop-over-current-subtitle).

You can then use the following keyboard shortcuts to divide the subtitles into shorter captions if needed.

M-jsubed-mpv-jump-to-current-subtitle
M-SPCsubed-mpv-toggle-pause
M-.subed-split-subtitle

Fine-tune the starting and ending timestamps

You can adjust the timestamps by manually typing in new values or by using the following keyboard shortcuts:

M-[subed-decrease-start-time
M-]subed-increase-start-time
M-{subed-decrease-stop-time
M-}subed-increase-stop-time=

It can be easier to determine the starting and stopping timestamps from the waveform instead of trying to pause at the right moment. subed-waveform allows you to see the waveform for the current subtitle, play samples at different positions, and set the start or stop times.

Test the flow of different segments

To test whether the audio flows together, mark a region and use M-x subed-record-compile-try-flow. You may want to bind this to a convenient shortcut with something like the following:

(with-eval-after-load 'subed-record
  (define-key subed-mode-map
    (kbd "C-c C-c") 
    #'subed-record-compile-try-flow))

This exports the audio segments in the region to a new file specified by subed-record-compile-output-filename (default: output.webm), overwriting existing files. After processing, it will play it in a separate MPV process. You can stop playing with M-x mpv-kill.

Test the visuals

You can test the visuals as well. M-x subed-record-compile-test-visuals compiles all the images, animated GIFs, and videos from the subtitle file into the output file specified by subed-record-compile-output-filename (default: output.webm) with a duration of 1 second per visual.

To tweak the display, consider customizing the following variables:

  • subed-record-compile-description-height
  • subed-record-compile-caption-height
  • subed-record-compile-output-video-width
  • subed-record-compile-output-video-height
  • subed-record-compile-description-drawtext-filter-params

Compile the video

Clear the region or select the whole buffer, then run M-x subed-record-compile-video. This will compile the video, audio, and subtitles into the output file specified by subed-record-compile-output-filename (default: output.webm).

Audio segments will be concatenated, one after the other. Visuals (specified by file: links) will be stretched or squeezed to fit the time until the next visual is specified. Visual information will be removed from the subtitles, and the resulting subtitles will accompany the audio segments.

Multiple output files

You can specify multiple output files with the #+OUTPUT: keyword, like this:

WEBVTT

NOTE
[[file:/home/sacha/proj/emacsconf/assets/in-between/journalism.png]]
#+OUTPUT: journalism.webm

00:00:04.794 --> 00:00:07.559
The next talk is called "Emacs journalism

00:00:07.560 --> 00:00:09.879
(or everything's a nail if you hit it with Emacs)",

00:00:09.880 --> 00:00:10.800
by Alfred Zanini.

00:00:11.393 --> 00:00:14.026
They will answer questions via BigBlueButton.

00:00:14.027 --> 00:00:16.744
You can join using the URL from the talk page

00:00:16.745 --> 00:00:20.394
or ask questions through Etherpad or IRC.

NOTE
[[file:/home/sacha/proj/emacsconf/assets/in-between/school.png]]
#+OUTPUT: school.webm

00:00:27.526 --> 00:00:30.606
The next talk is called "Back to school with Emacs".

00:00:33.860 --> 00:00:36.251
Daniel Rosel demonstrates Lectorg,

00:00:36.332 --> 00:00:39.881
a package that he wrote to make note taking faster and simpler.

00:00:39.882 --> 00:00:44.319
Afterwards, he will handle questions over IRC.

Keywords

#+AUDIO:
specify the audio file
#+OUTPUT:
everything until the next output comment goes into the specified file.
#+CAPTION:
text that will be displayed at the top
#+SKIP
skip the following subtitle
[[file:...]]
include that image or video

Notes

subed-record timestamps might overlap if you use multiple audio sources. You may want something like this at the end of your file:

NOTE
Local Variables:
subed-enforce-time-boundaries: nil
End:

If you like to move sections around, you’ll also want to (remove-hook 'subed-sanitize-functions 'subed-sort).

While testing, it can be useful to add "-r" "1" to compile-media-ffmpeg-arguments. It makes a video with one frame per second, which is choppy but still handy for checking the flow.

If you’re compiling or trying part of a video and you’re midway between visuals, the previous visual won’t be included. To work around this, start with a caption that has a file link for the visual.

Related posts:

https://sachachua.com/blog/category/subed/

About

Record audio in segments and compile it into a file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published