Long lecture videos are terrible for quick revision. You cannot Ctrl+F a two-hour recording. So I built a pipeline that samples frames from each video and turns them into ordered PDFs, one per lecture, plus a merged master document I can flip through the night before an exam.
#The problem: you can't Ctrl+F a video
Before exams I did not want to scrub through hours of recorded lectures just to find one slide. Taking screenshots by hand is tedious and easy to lose. So the tool samples frames at a low frame rate with ffmpeg and stitches them into a PDF you can skim, search visually, and annotate.
#How it works
- 1Recursively scan
video/for supported files (.mp4,.webm,.mkv,.mov,.avi) - 2Sort videos by leading number when present (001, 002, ...)
- 3Extract sampled frames per video with ffmpeg
- 4Convert the frames into one PDF per video
- 5Mirror the source folder structure under
pdf/ - 6Optionally merge everything into
pdf/final_merged.pdf
#Install and run
pip install pillow pypdf tqdmDrop your videos into video/ (nested course folders are fine) and run:
python main.pyA few flags make it flexible:
python main.py --fps 0.05 --workers 2 --keep-frames- ▹
--fpscontrols how many frames ffmpeg samples - ▹
--workersprocesses several videos in parallel - ▹
--use-gpuenables CUDA acceleration for ffmpeg - ▹
--keep-frameskeeps the extracted JPGs after the PDF is built - ▹
--skip-mergeskips creating the merged master PDF
#Nested folders stay organised
Point it at a whole course and the output mirrors the input tree. This input:
video/
└── Python Course/
├── Module 01/
│ ├── 001 Intro.mp4
│ └── 002 Setup.mp4
└── Module 02/
└── 001 Variables.mp4becomes this output:
pdf/
├── Python Course/
│ ├── Module 01/
│ │ ├── 001.pdf
│ │ └── 002.pdf
│ └── Module 02/
│ └── 001.pdf
└── final_merged.pdf#What I improved along the way
- ▹Renamed the cryptic entry script to a clear
main.py - ▹Added real CLI flags for fps, workers, GPU, frame retention, and merge control
- ▹Validates that ffmpeg actually ran instead of silently continuing on failure
- ▹Auto-creates
video/andpdf/on first run - ▹Skips merging
final_merged.pdfback into itself on reruns - ▹Writes clearer logs to
run.logwhen a step fails
Tip
001 Intro.mp4 and your notes stay in lecture order automatically. Videos without a number still work; they just use a cleaned-up filename.It turned a folder of recorded lectures into a searchable stack of PDF notes in one command. The full script and options are on GitHub.