t_fischer: (cat face)
[personal profile] t_fischer

Think of the situation, where you created a presentation or a lecture consisting of a set of slides. Now, imagine that part of you audience cannot attend, as your presentation is at a remote conference or you are teacher in a distance education course having students all over the world.

There exist commercial solutions, where you can record you presentation slides along with commentary speech, but cannot you achieve the same result using free tools?

The answer is "Yes", as I will explain in this posting.

To follow this posting, you have to have the following prerequisits:

  1. Your presentation as a PDF file
  2. A microphone to record you own voice including software to record (e.g. Audacity or arecord)
  3. A recent Linux distribution or a comparable system with GhostScript, ImageMagick, FFmpeg, and Mencoder installed

The first step is to record single .wav files for each of your slides. As each slide will be shown for the duration of its audio recording, feel free to include silent pauses. Once you are satisfied with your recording, save each page's recoding in a filename like this: For the first slide page001.wav, for the secod slide page002.wav, ...

If you want to use Alsa's command line tool, use arecord -l to probe which recoding devices are available. The actual recording command may look like this arecord -D hw:1,0 -f dat -c 1 -r 22050 page003.wav. Press Ctrl+C to stop the recording.

Next, copy the script from below and your PDF file in the same directory where you stored the audio recordings. The script will use GhostScript to generate images from each page in the presentation, generate short movie clips for each page combining your audio recording and the image, and finally join all movie clips into one large file.

Save the script as makemovie.sh and run it via bash makemovie.sh PRESENTATION.pdf.

#!/bin/sh

pdffilename="$1"
joinedavifilename="${pdffilename/.pdf/.avi}"
if [ -z "${pdffilename}" ] ; then
	echo "You have to provide a PDF file as parameter" >&2
	exit 1
fi
if [[ ! -s "${pdffilename}" || ! -f "${pdffilename}" ]] ; then
	echo "The provided filename does not exist" >&2
	exit 1
fi
if [[ "${joinedavifilename}" = "${pdffilename}" ]] ; then
	echo "The provided filename does not end with .pdf" >&2
	exit 1
fi

for n in $(seq -f "%03.0f" 1 999) ; do
	avifilename="page${n}.avi"
	pngfilename="page${n}.png"
	wavfilename="page${n}.wav"
	if [ ! -f ${wavfilename} ] ; then continue ; fi

	echo "=== Slide $n ====================================="

	if [[ ! -s ${pngfilename} || ${pdffilename} -nt ${pngfilename} ]] ; then
		gs -sDEVICE=png16m -r512 -dSAFER -dNOPAUSE  -dFirstPage=${n} -dLastPage=${n} -sOutputFile=temp.png -dBATCH "${pdffilename}" || exit 2
		convert -scale 768x576 temp.png ${pngfilename}
		rm -f temp.png
	fi

	if [[ ! -s ${avifilename} || ${pngfilename} -nt ${avifilename} || ${wavfilename} -nt ${avifilename} ]] ; then
		rm -f ${avifilename}
		ffmpeg -loop_input -r 3 -shortest -i ${pngfilename} -i ${wavfilename} -aspect 4:3 -acodec libmp3lame -ab 96k -vcodec libx264 -vpre ultrafast ${avifilename} || exit 3
	fi
done

rm -f "${joinedavifilename}"
mencoder -forceidx -oac copy -ovc copy -o "${joinedavifilename}" page*.avi || exit 4

ls -l "${joinedavifilename}"
file "${joinedavifilename}"

(no subject)

Date: 2012-04-14 03:09 pm (UTC)
tonybaldwin: tony baldwin (Default)
From: [personal profile] tonybaldwin
I had to bookmark this.

Now, I know there must be a way to do this with image files, rather than a pdf.
Also, I'd be interesting in knowing how to take a list of image files and a single audio file and bring them together
to show on image after another, and match the duration of the audio file, so that the video will
show the images with the music.

There are numerous video editing programs, but they all confuse me, and I think managing such matters with a script, ffmpeg, etc., will make a lot more sense to me (weird, no? most people want gui tools, but those confuse me).

Profile

t_fischer: (Default)
Thomas Fischer

September 2017

S M T W T F S
     12
34567 89
10111213141516
17181920212223
24252627282930

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags