#!/bin/bash # muxsa-pngaac2mp4 # # part of muxsa, https://git-nks-public.tik.uni-stuttgart.de/edu/muxsa # # this script tells ffmpeg (https://ffmpeg.org/) to read # a series of slides in png file format (created with muxsa-kvm2png), # a soundtrack.aac (recorded with audacity), and # a ffmpeg concat multiplexer sequence file (created with muxsa-al2fc) # and multiplex everything together # into a mp4 video of the slideshow with background narration # MIT License # # Copyright (c) 2023 Sebastian Kiesel # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. ############################################################################ # see https://trac.ffmpeg.org/wiki/Slideshow echo "This is muxsa-pngaac2mp4." OUTFILE="out.mp4" if [ "$1" ] ; then OUTFILE="$1" # make sure that file ends on .mp4 OUTFILE="${OUTFILE%%.mp4}.mp4" fi if [ ! -f slides.concat ] ; then echo "error: file slides.concat missing. abort." echo "consider using muxsa-al2fc for creating one." exit 1 fi if [ -f soundtrack.m4a ] ; then AUDIOFILE="-i soundtrack.m4a" AUDIOOPTS="-c:a copy" else if [ -f soundtrack.wav ] ; then AUDIOFILE="-i soundtrack.wav" AUDIOOPTS="-c:a aac -b:a 128k" else if [ -f audio.concat ] ; then AUDIOFILE="-f concat -i audio.concat" AUDIOOPTS="-c:a aac -b:a 128k" else echo "neither soundtrack.m4a, .wav, nor audio.concat found. abort." exit 1 fi fi fi ffmpeg -f concat -i slides.concat ${AUDIOFILE} \ -vsync cfr -vf fps=25 \ -c:v libx264 -preset slow -tune stillimage -crf 23 -pix_fmt yuv420p \ ${AUDIOOPTS} \ -movflags +faststart -brand mp42 "${OUTFILE}" ############################################################################