Skip to content

Commit 62da332

Browse files
committed
rename video/audio profile config 'codec' to 'encoder'
The earlier change to 'codec' was based on a misunderstanding. This actually tells ffmpeg which encoder to use, so this identifier is more accurate. Example: 'copy' ("don't change anything") is a valid encoder, but it's clearly not a codec.
1 parent 6d276ec commit 62da332

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ vod:
111111
height: 1080
112112
bitrate: 5000
113113
# Optional ffmpeg video overrides
114-
codec: h264_nvenc # default "libx264"
114+
encoder: h264_nvenc # default "libx264"
115115
preset: p1 # default "faster"
116116
profile: high # default "high"
117117
level: auto # default "4.0"
@@ -131,7 +131,7 @@ vod:
131131
video-keyframes: false
132132
# Single audio profile used
133133
audio-profile:
134-
codec: aac # default "aac", but "copy" is an alternative
134+
encoder: aac # default "aac", but "copy" is an alternative
135135
bitrate: 192 # kbps
136136
# If cache is enabled
137137
cache: true

hlsvod/transcode.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ type VideoProfile struct {
2828
Bitrate int // in kilobytes
2929

3030
// Optional FFmpeg overrides
31-
Codec string
31+
Encoder string
3232
Preset string
3333
Profile string
3434
Level string
3535
ExtraArgs []string
3636
}
3737

3838
type AudioProfile struct {
39-
Codec string // audio codec (e.g., "aac", "copy", "libopus")
40-
Bitrate int // in kilobytes (0 means use codec default)
39+
Encoder string // audio encoder (e.g., "aac", "copy", "libopus")
40+
Bitrate int // in kilobytes (0 means use encoder default)
4141
}
4242

4343
// returns a channel, that delivers name of the segments as they are encoded
@@ -98,9 +98,9 @@ func TranscodeSegments(ctx context.Context, ffmpegBinary string, config Transcod
9898
}
9999

100100
// apply defaults if empty
101-
codec := profile.Codec
102-
if codec == "" {
103-
codec = "libx264"
101+
encoder := profile.Encoder
102+
if encoder == "" {
103+
encoder = "libx264"
104104
}
105105
preset := profile.Preset
106106
if preset == "" {
@@ -117,7 +117,7 @@ func TranscodeSegments(ctx context.Context, ffmpegBinary string, config Transcod
117117

118118
args = append(args, []string{
119119
"-vf", scale,
120-
"-c:v", codec,
120+
"-c:v", encoder,
121121
"-preset", preset,
122122
"-profile:v", prof,
123123
"-level:v", lvl,
@@ -142,8 +142,8 @@ func TranscodeSegments(ctx context.Context, ffmpegBinary string, config Transcod
142142
// Audio specs
143143
if config.AudioProfile != nil {
144144
profile := config.AudioProfile
145-
if profile.Codec != "" {
146-
args = append(args, "-c:a", profile.Codec)
145+
if profile.Encoder != "" {
146+
args = append(args, "-c:a", profile.Encoder)
147147
if profile.Bitrate > 0 {
148148
args = append(args, "-b:a", fmt.Sprintf("%dk", profile.Bitrate))
149149
}

internal/api/hlsvod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (a *ApiManagerCtx) HlsVod(r chi.Router) {
147147
Width: profile.Width,
148148
Height: profile.Height,
149149
Bitrate: profile.Bitrate,
150-
Codec: profile.Codec,
150+
Encoder: profile.Encoder,
151151
Preset: profile.Preset,
152152
Profile: profile.Profile,
153153
Level: profile.Level,

internal/config/config.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ type VideoProfile struct {
4949
Bitrate int `mapstructure:"bitrate"` // in kilobytes
5050

5151
// Optional FFmpeg overrides
52-
Codec string `mapstructure:"codec"`
52+
Encoder string `mapstructure:"encoder"`
5353
Preset string `mapstructure:"preset"`
5454
Profile string `mapstructure:"profile"`
5555
Level string `mapstructure:"level"`
5656
ExtraArgs []string `mapstructure:"extra-args"`
5757
}
5858

5959
type AudioProfile struct {
60-
Bitrate int `mapstructure:"bitrate"` // in kilobytes
60+
Encoder string `mapstructure:"encoder"`
61+
Bitrate int `mapstructure:"bitrate"` // in kilobytes
6162
}
6263

6364
type VOD struct {
@@ -267,8 +268,8 @@ func (s *Server) Set() {
267268

268269
// apply defaults to each video profile
269270
for k, vp := range s.Vod.VideoProfiles {
270-
if vp.Codec == "" {
271-
vp.Codec = "libx264"
271+
if vp.Encoder == "" {
272+
vp.Encoder = "libx264"
272273
}
273274
if vp.Preset == "" {
274275
vp.Preset = "faster"

0 commit comments

Comments
 (0)