upgrade: gwencoder v3.1 with interactive menu and Tdarr alignment
This commit is contained in:
74
gwencoder/scripts/add_resolution_feature.sh
Executable file
74
gwencoder/scripts/add_resolution_feature.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
# Script to add resolution preset support to main.go
|
||||
# This script will guide you through the manual changes needed
|
||||
|
||||
echo "================================================================"
|
||||
echo "Resolution Preset Integration Script"
|
||||
echo "================================================================"
|
||||
echo ""
|
||||
echo "Since main.go is in .gitignore, please make the following changes manually:"
|
||||
echo ""
|
||||
|
||||
cat << 'EOF'
|
||||
|
||||
STEP 1: Add Resolution field to EncodingOptions struct
|
||||
-------------------------------------------------------
|
||||
Find the EncodingOptions struct (search for "type EncodingOptions struct")
|
||||
Add this field:
|
||||
|
||||
Resolution string // Resolution preset (480p, 720p, 1080p, original)
|
||||
|
||||
|
||||
STEP 2: Add resolution flag in parseFlags() function
|
||||
----------------------------------------------------
|
||||
Find where flags are defined (search for "flag.String" or "flag.Bool")
|
||||
Add this line with the other flag definitions:
|
||||
|
||||
resolution := flag.String("resolution", "", "Target resolution (480p, 720p, 1080p, original)")
|
||||
|
||||
Then in the EncodingOptions initialization, add:
|
||||
|
||||
Resolution: *resolution,
|
||||
|
||||
|
||||
STEP 3: Integrate into encodeFile() function
|
||||
--------------------------------------------
|
||||
Find the encodeFile() function and locate where FFmpeg command is built.
|
||||
Add this code BEFORE building the 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 the FFmpeg args array, if scaleFilter is not empty,
|
||||
add it to the command arguments (typically after video codec args).
|
||||
|
||||
|
||||
STEP 4: Update printHelp() function
|
||||
-----------------------------------
|
||||
Find the printHelp() function and add in the appropriate section:
|
||||
|
||||
fmt.Println("\n📐 Resolution Options:")
|
||||
fmt.Println(" --resolution <preset> Scale video to target resolution")
|
||||
fmt.Println(" Options: 480p, 720p, 1080p, original")
|
||||
fmt.Println(" Only scales down, never upscales")
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "================================================================"
|
||||
echo "After making these changes:"
|
||||
echo " 1. Save main.go"
|
||||
echo " 2. Run: make clean && make build"
|
||||
echo " 3. Test with: ./build/gwencoder --help"
|
||||
echo "================================================================"
|
||||
Reference in New Issue
Block a user