Metadata-Version: 2.4
Name: privatestudio
Version: 0.2.dev1+g72b4fcc10.d20261026
Summary: Video transcoding tools with multi-profile H.264 encoding support
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: PyYAML>=6.0
Requires-Dist: FastAPI>=0.100.0
Requires-Dist: uvicorn[standard]>=0.23.0
Requires-Dist: SQLAlchemy>=2.0.0
Requires-Dist: python-multipart>=0.0.5
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: httpx>=0.27.0; extra == "dev"

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.


# Configuring for quicksync

1:N transcoding workflow that leverages the GPU hardware filter scale_qsv. This reads the input frame once, scales it on the Intel GPU, and encodes both outputs simultaneously.

```bash
ffmpeg -hwaccel qsv -c:v h264_qsv -i input.mp4 \
  -filter_complex "[0:v]split=2[s1][s2]; \
                   [s1]scale_qsv=w=1280:h=720[v720]; \
                   [s2]scale_qsv=w=854:h=480[v480]" \
  -map "[v720]" -c:v h264_qsv -b:v 2500k -maxrate 2500k -bufsize 5000k \
    -g 60 -keyint_min 60 -sc_threshold 0 -forced-idr 1 -an video_720p.mp4 \
  -map "[v480]" -c:v h264_qsv -b:v 1000k -maxrate 1000k -bufsize 2000k \
    -g 60 -keyint_min 60 -sc_threshold 0 -forced-idr 1 -an video_480p.mp4 \
  -map 0:a? -c:a aac -b:a 128k audio.mp4
```

Key Argument Explanations:
 * -hwaccel qsv -c:v h264_qsv: Invokes hardware decoding and initialization.
 * scale_qsv=w=...:h=...: Tells the Intel GPU to handle the video resizing directly inside the Quick Sync processing pipeline.
 * -g 60 -keyint_min 60: Dictates the GOP size (assuming a 30fps input video, a GOP of 60 forces a keyframe exactly every 2 seconds).
 * -sc_threshold 0: Disables scene change detection to ensure keyframes are purely fixed.
 * -forced-idr 1: Forces the QSV encoder to use actual IDR frames instead of basic I-frames at the GOP boundary, which is necessary for fragmenting tools.
 * -an: Strips audio out of the video streams so Bento4 can package them as clean, isolated tracks.
