Difference between revisions of "Help:Scripting"

From DFM Wiki
(When generating videos from slides, don't "copy" the video track, as it generates a video/png!)
m (Text replacement - "Category:Main" to "Category:Featured")
 
(One intermediate revision by one other user not shown)
Line 21: Line 21:
  
 
<code>for I in *.PNG; do ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -r 25 -f image2 -loop 1 -i $I -t 4 -c:a aac -shortest ${I%.*}.mp4; done</code>
 
<code>for I in *.PNG; do ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -r 25 -f image2 -loop 1 -i $I -t 4 -c:a aac -shortest ${I%.*}.mp4; done</code>
 +
 
[[Category:Project management]]
 
[[Category:Project management]]
 +
[[Category:Featured]]

Latest revision as of 16:13, 12 October 2021

These are command-line scripts for advanced processing of DFM documents.

Converting a PDF to a set of images

This is mainly useful for extracting images from a PDF slideshow submitted as a PDF, to be reused in other contexts (e.g., bulk insertion of slides into a workshop report).

convert -verbose -density 300 -trim DFM_PRS_slideshow.pdf -flatten -sharpen 0x1.0 slide-%d.png 

Normalizing Zoom recordings for editing or concatenation

Zoom recordings may have different resolutions/screen dimensions and bitrates, depending on the computer settings of whoever is making the recording. To edit or concatenate recordings, re-encode as follows:

ffmpeg -ss <start> -i <input>.mp4 -t <duration> -avoid_negative_ts 1 -ac 1 -b:a 192k -ar 44100 -vf "scale=w=1920:h=1080:force_original_aspect_ratio=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black" <output>.mp4

In the above, use -ss HH:MM:ss for the start time, and -t HH:MM:ss for the duration if you want to trim the start and end of the recording. This command will both scale and pad to fit an HD frame, which should be adequate for YouTube uploads; source video dimensions are likely to be something other than 16:9.

Turning PowerPoint slides into video segments

Ensure that the slide dimensions correspond to the video resolution (e.g., 1920x1080).

Export the PowerPoint deck as a series of PNG images.

Convert each PNG image to a video with a silent audio track. (Omitting the audio track altogether can cause audio/video sync issues when concatenating with other clips.) In the command below, the framerate is set with -r 25 (25 fps) and the duration is set with -t 4 (4 seconds).

for I in *.PNG; do ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -r 25 -f image2 -loop 1 -i $I -t 4 -c:a aac -shortest ${I%.*}.mp4; done