2023-03-14 18:00:55 +01:00
|
|
|
package ffmpeg
|
|
|
|
|
2023-07-18 15:15:04 +02:00
|
|
|
import "fmt"
|
|
|
|
|
2023-03-14 18:00:55 +01:00
|
|
|
// Options represents transcoding options.
|
|
|
|
type Options struct {
|
2023-07-18 15:15:04 +02:00
|
|
|
Bin string
|
|
|
|
Encoder AvcEncoder
|
|
|
|
Size int
|
|
|
|
Bitrate string
|
|
|
|
MapVideo string
|
|
|
|
MapAudio string
|
|
|
|
}
|
|
|
|
|
|
|
|
// VideoFilter returns the FFmpeg video filter string based on the size limit in pixels and the pixel format.
|
|
|
|
func (o Options) VideoFilter(format PixelFormat) string {
|
|
|
|
// scale specifies the FFmpeg downscale filter, see http://trac.ffmpeg.org/wiki/Scaling.
|
|
|
|
if format == "" {
|
|
|
|
return fmt.Sprintf("scale='if(gte(iw,ih), min(%d, iw), -2):if(gte(iw,ih), -2, min(%d, ih))'", o.Size, o.Size)
|
|
|
|
} else {
|
|
|
|
return fmt.Sprintf("scale='if(gte(iw,ih), min(%d, iw), -2):if(gte(iw,ih), -2, min(%d, ih))',format=%s", o.Size, o.Size, format)
|
|
|
|
}
|
2023-03-14 18:00:55 +01:00
|
|
|
}
|