Saturday, 24 March 2018

ffmpeg - Automatically split large .mov video files into smaller files at black frames (scene changes)?

I have 65 .mov video files named tape_01.mov, tape_02.mov, ..., tape_65.mov. Each is about 2.5 hours long and takes up many gigabytes. They are digital copies of what were VHS tapes (my family's "home movies").


Each 2.5-hour .mov video file contains many "chapters" (in the sense that sometimes the scene ends in a fade to a black screen, and then a new scene fades in).


My main goal is have the 65 large files sliced into smaller files by chapter. And I want that to be done automatically via detection of the black frames between "scenes".


Could I use ffmpeg (or anything) to pass in the 65 original filenames and have it automatically iterate over each video and chop it down, naming the resulting pieces tape_01-ch_01.mov, tape_01-ch_02.mov, tape_01-ch_03.mov, etc? And I want it to do it without re-encoding (I want it to be a simple lossless slice).


How can I do this?


Here are the steps I want:



  1. Iterate over a folder of .mov files (named tape_01.mov, tape_02.mov, ..., tape_65.mov) to export them as mp4 files (named tape_01.mp4, tape_02.mp4, ..., tape_65.mp4). I want the compression settings to be easy to configure for this step. The original .mov files should still exist after the .mp4 files are created.

  2. Iterate over the mp4 files: for each mp4 file, generate a text file that specifies the start time and duration of black segments between "scenes". Each mp4 can have 0 or more of these black scene breaks. The start time and duration should be precise to a fraction of a second. HH:MM:SS format is not precise enough.

  3. I'll then be able to manually double-check these text files to see whether they correctly identify scene changes (black segments). I can adjust the timings if I want.

  4. Another script will read each mp4 file and its txt file and split (in a super fast and lossless way) the mp4 into as many pieces as necessary based on the lines of the text file (the timings indicated there). The splits should happen in the middle of each black segment. Here is a sample mp4 file (with audio removed for privacy purposes) that has fade-to-black scene changes. The original mp4 files should remain untouched as the smaller mp4 files are created. The smaller mp4 files should have the naming scheme of tape_01_001.mp4, tape_01_002.mp4, tape_01_003.mp4, etc.

  5. Bonus! It would be awesome if another script could then iterate over the small mp4 files and generate one .png image for each that is a mosaic of screenshots like this person is trying for: Meaningful thumbnails for a Video using FFmpeg


I'd like these scripts to be shell scripts that I can run in Mac, Ubuntu, and Windows Git Bash.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...