Notes for Video-Production

Updated on 2022-11-15

I provide courses as https://en.wikipedia.org/wiki/Flipped_classroom which means I provide lectures on video. This page here is to keep a current state of the tools and configurations I use — for me and for others to take a (bad or good) example.

Disclaimer: I am not a video producer and even less a nerd-of-video-production. I am focussing more on volume and consistency of content and want to be my video-production process to be lean and fast.

Format

I use the current output format for my video lectures:

  • MP4-Container
    • Video: h264, 1280x720, 16:9, 25 fps
    • Audio: mp3, 48000 Hz, stereo

Matroska Format

I would like very much to publish my videos in Matroska format and will in the future switch from MP4, but at the beginning, there have been students who where unable to decode Matroska, so I changed my production chain for the time being.

Video editing with ffmpeg

Re-packaging a batch of videos from mkv to mp4. Videos have to be correctly ordered, will then be numbered in that order and renamed in subdirectory mp4:

i=1; for f in *.mkv; do ffmpeg -i $f -codec copy mp4/mathe2-02-$(printf "%02d" $i).mp4; i=$((i+1)) ; done

Concatenation of Videos

First write a file inputs.txt with all the paths to videos to be concatenated prepended by “file”:

# Comment in line with Hash
file `first_video.mkv`
file `second_video.mkv`
file `as_many_as_you_like.mkv`

And then apply:

ffmpeg -f concat -safe 0 -i inputs.txt -c copy new_file.mp4

Flag safe set to 0 to accept any filename, see ffmpeg concat options. As codec copy is used, all input videos should already have the same video- and audio-stream formats. Otherwise you need to specifiy the mapping explicitly.

Creating a static title

For creation of an image with automated inclusion of text, please see the Tutorial on ImageMagick by Oliver Radfelder.

Turn an image into a 3-second video, I use the following line.

ffmpeg -nostdin \
  -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \
  -loop 1 -i image.png \
  -c:a aac \
  -shortest -t 3 -r 25 -y video.mkv </dev/null 

ffmpeg is not easy to convince that it should overwrite an existing file hence the output flag -y seems necessary. Furthermore, if used within a script, it is necessary to prevent ffmpeg from interaction with the user. There are two ways to achieve this, either the flag -nostdin or the redirection of the input stream *> /tmp/vfifo


or to a video loopback:

ffmpeg -f v4l2 -video_size 800x600 -i /dev/video1 -i share/img/unsplash/mark-harrison-rooftop_hacker-unsplash-full.jpg -filter_complex “[0:v]colorkey=white:0.35:0.0[ckout];[1:v]scale=800:600[olout];[olout][ckout]overlay[out]” -map “[out]” -f v4l2 /dev/video2



Instead of an image, you could also loop a video in the background:

ffmpeg -f v4l2 -video_size 800x600 -i /dev/video0 -i Universe_Fury.mp4 -filter_complex “[0:v]colorkey=white:0.7:0.0[ckout];[1:v]loop=-1[loop];[loop]scale=800:600[olout];[olout][ckout]overlay[out];[out]crop=800:600:0:0[crop];[crop]format=yuv420p[enc]” -map “[enc]” -f v4l2 /dev/video2



### Play with mplayer from named pipe

cat /tmp/vfifo | mplayer -cache 1024 - ```

Tools

  • OBS Studio providing “scenes”, recording and streaming
  • Shotcut video editing software, alledgedly very easy to use
  • Flowblade video editing
    • there are simpler tools, but has been the first I found and I manage to assemble and cut video-snippets in here
    • will be rendered, which takes a lot of time, probably there is a copy-renderer inside
  • ffmpeg used for the fastest way to re-package or recode videos as a batch job. Loop over all files that have to be converted and the computer does the rest.