1.7 KiB
Executable File
1.7 KiB
Executable File
Resolution Preset Code Integration
Quick Integration Steps
Since you have main.go open in your editor, here are the exact code additions needed:
1. EncodingOptions Struct
Find type EncodingOptions struct and add:
Resolution string // Resolution preset (480p, 720p, 1080p, original)
2. Flag Parsing
In parseFlags(), add with other flag definitions:
resolution := flag.String("resolution", "", "Target resolution (480p, 720p, 1080p, original)")
And in the EncodingOptions initialization:
Resolution: *resolution,
3. encodeFile() Integration
Add this near the start of encodeFile(), before building FFmpeg command:
// Build scale filter for resolution preset
scaleFilter := ""
if opts.Resolution != "" {
filter, err := encoding.BuildScaleFilter(file, opts.Resolution)
if err != nil {
fmt.Printf("⚠️ Warning: Could not build scale filter: %v\n", err)
} else if filter != "" {
scaleFilter = filter
targetHeight := encoding.GetResolutionPresetHeight(opts.Resolution)
fmt.Printf("📐 Scaling video to %dp\n", targetHeight)
}
}
Then when building FFmpeg args, add the scale filter if not empty:
if scaleFilter != "" {
ffmpegArgs = append(ffmpegArgs, strings.Fields(scaleFilter)...)
}
4. Help Text
In printHelp(), add:
fmt.Println("\n📐 Resolution Options:")
fmt.Println(" --resolution <preset> Scale to target resolution (480p, 720p, 1080p)")
fmt.Println(" Only scales down, maintains aspect ratio")
Test Commands
After saving and rebuilding:
make clean && make build
./build/gwencoder --help | grep -A 5 "Resolution"
./build/gwencoder --fast --resolution 720p input.mp4