Files
privatestudio/notes.md
T
2026-09-19 23:20:14 -06:00

19 lines
1.4 KiB
Markdown

To output individual MP4 files for subsequent Bento4 packaging, you need to ensure the video streams are perfectly aligned. This requires forcing fixed GOP sizes (Keyframe intervals) and disabling scene-change detection.
The FFmpeg Command
This command takes input.mp4 and splits it into three separate, fragmented-friendly MP4 files (1080p, 720p, and 480p) plus one standalone audio track:
```bash
ffmpeg -y -i input.mp4 \
-map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:a:0 \
-g 72 -keyint_min 72 -sc_threshold 0 \
-c:v:0 libx264 -b:v:0 5000k -maxrate:v:0 5350k -bufsize:v:0 7500k -filter:v:0 "scale=-2:1080" -an output_1080p.mp4 \
-c:v:1 libx264 -b:v:1 2800k -maxrate:v:1 2996k -bufsize:v:1 4200k -filter:v:1 "scale=-2:720" -an output_720p.mp4 \
-c:v:2 libx264 -b:v:2 1400k -maxrate:v:2 1498k -bufsize:v:2 2100k -filter:v:2 "scale=-2:480" -an output_480p.mp4 \
-c:a aac -b:a 128k -vn output_audio.mp4
```
## Critical Settings for Bento4
* -g 72 -keyint_min 72: Forces a keyframe exactly every 72 frames. At 24fps, this yields an exact 3-second fragment duration.
* -sc_threshold 0: Disables adaptive scene-change keyframes. Without this, your streams will have misaligned keyframes, and Bento4 will fail to package them as a single adaptive HLS stream.
* -an and -vn: Separates the audio from the video files. Bento4 handles multiplexing and packaging best when audio and video tracks are fed as distinct source files.