Editing Zoom recordings of teaching sessions with FFmpeg

FFmpeg logo

Based on student feedback, we have been organizing a new course for the TRANSMED MSc program about drug discovery and development. It is what you call in German a "Schupperkurs". I never have found a satisfactory translation of this word in English. It means that we just want to raise the students' interest in this course. If they like it, they can take any of the many in-depth courses that are offered e.g. at the Faculty of Pharmacy, where there will be more teaching in English in the coming years due to the planned International MSc program in Pharmacy.

We use the Zoom meeting software for all of the sessions. We encourage the teachers to record the sessions because nobody can guarantee a functioning internet connection. Unfortunately, some teachers cannot record, e.g. if they present unpublished data about a competitive project or data that they plan to use in a future patent application. The recorded sessions are made available internally. Before putting them to OneDrive, I try to do minimal post-processing, namely cutting out "slack" (e.g. breaks). I know that all 12-year-olds on TikTok can do this on their smartphones, but being a dinosaur I have done it on the command line using ffmpeg.

From yesterday's session, I wanted to cut out slack space from the beginning and the end and a 15 minutes break in between. In addition, we had played a song, which quality-wise did not work well via Zoom. Hence, I separately downloaded the song (Viva La Evidence) using youtube-dl, which had become recently famous due to the IRA take-down request to GitHub. I "knocked-in" this song to improve the audio quality.

Original Video: zoom_0.mp4 (video stream: 2560x1440, H.264, 25 fps; audio stream: MPEG-4 AAC Mono 32000Hz 126kbps)
Youtube video: Evidence.webm (video stream: 1920x1080, VP9, 24 fps; audio stream: MP3 Stero 48000Hz 128kps)

Here are the steps (you can do this in one go, but this way the individual steps are more understandable)

  1. Cut useful parts out (omitting the song and the break):
    • ffmpeg -i zoom_0.mp4 -vcodec copy -acodec copy -ss 00:01:44 -t 01:01:58 part1.avi
    • ffmpeg -i zoom_0.mp4 -vcodec copy -acodec copy -ss 1:07:55 -t 00:12:40 part2.avi
    • ffmpeg -i zoom_0.mp4 -vcodec copy -acodec copy -ss 1:36:18 part3.avi
  2. Change resolution of downloaded Youtube video to match the Zoom recording:
    ffmpeg -i Evidence.webm -vf scale=2560:1440 Evidence_rescaled.avi
  3. Change framerate of rescaled video:
    ffmpeg -i Evidence_rescaled.avi -filter:v fps=fps=50 Evidence_rescaled_reframed.avi
  4. Assemble all four parts:
    ffmpeg -i part1.avi -i Evidence_rescaled_reframed.avi -i part2.avi -i part3.avi -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0][3:v:0][3:a:0]concat=n=4:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output_final.avi
  5. In a final step, I adjusted the quality (2-pass) since the output from the previous command is >2GB:
    • ffmpeg -y -i output_final.avi -c:v libx264 -b:v 500k -pass 1 -an -f null /dev/null
    • ffmpeg -i output_final.avi -c:v libx264 -b:v 500k -pass 2 -c:a mp3 -b:a 128k final_output_reduced_filesize.mp4

Other useful ffmpeg commands:

  • To increase the volume by the factor 4:ffmpeg -i infile.mp4 -af volume=4 -vcodec copy outfile.mp4

However, the above commands copy the data, but do not take care of generating a keyframe at the start of the video. Therefore, the edited video might start with a black screen and the image will appear only when the next keyframe is encountered. If you want to avoid that, then you need to remove the "-vcodec copy -acodec copy" options. In that case, ffmpeg will re-encode the whole video (which is massively slower than copying). See here a good writeup about options how to avoid the black start screen: https://newbedev.com/cutting-the-videos-based-on-start-and-end-time-usin...