File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ type outputArgs struct {
3030 audioChannels int
3131 keyframeInterval int
3232 audioCodec string
33+ constantRateFactor int
3334 videoBitRate int
3435 videoBitRateTolerance int
3536 videoMaxBitrate int
Original file line number Diff line number Diff line change @@ -25,7 +25,11 @@ func NewCommand(ffmpegPath string) *Command {
2525 }
2626 return & Command {
2727 FFmpegPath : ffmpegPath ,
28- Args : & Args {},
28+ Args : & Args {
29+ output : outputArgs {
30+ constantRateFactor : - 1 , // Initialize to -1 because zero value is a valid parameter
31+ },
32+ },
2933 }
3034}
3135
Original file line number Diff line number Diff line change @@ -22,6 +22,15 @@ func (a *Args) GetAspectRatio() []string {
2222 return nil
2323}
2424
25+ // GetConstantRateFactor gets the constant rate factor (CRF) for video encoding
26+ func (a * Args ) GetConstantRateFactor () []string {
27+ if a .output .constantRateFactor != - 1 {
28+ return []string {"-crf" , fmt .Sprintf ("%d" , a .output .constantRateFactor )}
29+ }
30+
31+ return nil
32+ }
33+
2534// GetVideoBitRate returns returns the arguments for video bit rate
2635func (a * Args ) GetVideoBitRate () []string {
2736 if a .output .videoBitRate != 0 {
Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ func (c *Command) Resolution(v string) *Command {
1717 return c
1818}
1919
20+ // ConstantRateFactor sets the constant rate factor (CRF) for video encoding
21+ func (c * Command ) ConstantRateFactor (v int ) * Command {
22+ c .Args .output .constantRateFactor = v
23+
24+ return c
25+ }
26+
2027// VideoBitRate gets the video bit rate.
2128func (c * Command ) VideoBitRate (v int ) * Command {
2229 c .Args .output .videoBitRate = v
You can’t perform that action at this time.
0 commit comments