Slides from a seminar video
scripts/ holds one tool in two forms that do the same thing:
| Script | Use on |
|---|---|
scripts/extract_slides.sh | Linux, macOS, Git Bash or WSL on Windows |
scripts/extract_slides.ps1 | Windows PowerShell, no bash needed |
scripts/slides.tex | Beamer template the scripts copy next to the frames |
How it works: yt-dlp downloads the video stream only (no audio, at most
1080p). ffmpeg samples it at 1 frame/s and keeps the first frame plus every
frame whose scene-change score clears a threshold, so each kept frame is a new
slide or a new build step. The showinfo log gives each frame's video time.
The output folder then holds:
slide_001.png,slide_002.png, ...: one per slide changetimestamps.txt: the video time of each, in secondsframe_list.texandslides.tex:pdflatex slides.texgives one page per slide with itsh:mm:sstime underneath
Steps
-
Check the tools. Run
ffmpeg -versionandyt-dlp --version. If one is missing, install it (below) or tell the user how. yt-dlp is not needed for a local file. -
Pick the script for the platform. On Windows, use the PowerShell one unless the user is clearly in Git Bash or WSL.
-
Run it on the URL or file the user gave, into a folder named after the talk (for example
-o speaker_topic_frames), not inside the skill folder.bash scripts/extract_slides.sh -u "https://www.youtube.com/watch?v=ID" -o talk_frames bash scripts/extract_slides.sh -i "recording.mp4" -o talk_framespowershell -ExecutionPolicy Bypass -File scripts\extract_slides.ps1 -Url "https://www.youtube.com/watch?v=ID" -OutDir talk_frames powershell -ExecutionPolicy Bypass -File scripts\extract_slides.ps1 -InputFile "C:\path\to\recording.mp4" -OutDir talk_frames-ExecutionPolicy Bypassgets past Windows' default block on scripts, for that run only. -
Look at the frames before reporting. Open a few PNGs (first, middle, last) and check:
- Webcam or speaker view beside the slides: the speaker's movement
triggers false slide changes. Find the slide area in one frame and rerun
with a crop,
-c W:H:X:Y/-Crop W:H:X:Y(ffmpeg crop syntax: width, height, then top-left corner). - Too few frames (builds or small changes missed): rerun with a lower
threshold,
-t 0.05/-Threshold 0.05. - Too many frames (video, animations, camera noise): raise it to
0.2-0.3, or crop. - Duplicates: delete the extra PNGs and their lines in
frame_list.tex.
- Webcam or speaker view beside the slides: the speaker's movement
triggers false slide changes. Find the slide area in one frame and rerun
with a crop,
-
Build the PDF if the user wants one:
cdinto the output folder and runpdflatex slides.tex(orlatexmk -pdf slides.tex). -
Report the frame count, the output folder, the PDF, and anything left for the user, such as duplicates you kept on purpose.
Options
| bash | PowerShell | Meaning | Default |
|---|---|---|---|
-u URL | -Url URL | Video to download (any site yt-dlp supports) | |
-i FILE | -InputFile FILE | Local video instead of a download | |
-o DIR | -OutDir DIR | Output folder | video_frames |
-t X | -Threshold X | Scene-change threshold, 0-1 | 0.10 |
-c W:H:X:Y | -Crop W:H:X:Y | Crop to the slide area first | none |
-b NAME | -Browser NAME | Use this browser's login cookies (chrome, firefox, edge, ...) | none |
Installing the tools
- Windows:
winget install --id yt-dlp.yt-dlpandwinget install --id Gyan.FFmpeg, then close and reopen PowerShell so it finds them. - macOS:
brew install yt-dlp ffmpeg - Linux:
sudo apt install ffmpeg(or the distro's equivalent) andpip install -U yt-dlp - LaTeX (only for the PDF): TeX Live or MiKTeX. MiKTeX's
latexmkneeds Perl; plainpdflatexdoes not.
Troubleshooting
- Recording behind a sign-in (Panopto, Zoom cloud, a university portal):
pass
-b chrome/-Browser chrome(or the browser the user is signed in with). If yt-dlp still cannot get it, ask the user to download the video and use-i. $'\r': command not foundorpipefail: invalid option namein Git Bash: the.shfile has Windows line endings. Runsed -i 's/\r$//' scripts/extract_slides.shonce.- yt-dlp errors on YouTube ("Sign in to confirm", format errors): update
it first,
yt-dlp -Uorpip install -U yt-dlp, which fixes most of them. - No network to the video host (sandboxed or cloud session): say so, and give the user the command to run on their own machine.
Only fetch recordings the user is allowed to access, and keep the frames for their own notes and study unless the talk's licence says otherwise.