Skip to content

Commit

Permalink
video bitrate
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikvedvik committed Sep 15, 2023
1 parent 507272b commit 25d0fa9
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions services/transcode/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,39 @@ func VideoH264(input common.VideoInput, cb ffmpeg.ProgressCallback) (*common.Vid
}

params := []string{
"-progress", "pipe:1",
"-hide_banner",
"-progress", "pipe:1",
"-i", input.Path,
"-vf", "yadif=0:-1:0",
"-c:v", h264encoder,
"-b:v", input.Bitrate,
}
switch h264encoder {
case "libx264":
params = append(params,
"-profile:v", "high",
"-level:v", "1.3",
"-crf", "18",
"-maxrate", input.Bitrate,
)
}

params = append(params,
"-r", fmt.Sprintf("%d", input.FrameRate),
"-vf", fmt.Sprintf("scale=%[1]d:%[2]d:force_original_aspect_ratio=decrease,pad=%[1]d:%[2]d:(ow-iw)/2:(oh-ih)/2",
input.Width,
input.Height,
),
}
)

filename := filepath.Base(input.Path)
filename = filename[:len(filename)-len(filepath.Ext(filename))] +
fmt.Sprintf("_%dx%d.mp4", input.Width, input.Height)

outputPath := filepath.Join(input.DestinationPath, filename)

params = append(params, "-y", outputPath)
params = append(params,
"-y", outputPath,
)

info, err := ffmpeg.GetStreamInfo(input.Path)
if err != nil {
Expand Down

0 comments on commit 25d0fa9

Please sign in to comment.