Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename profile.CRF to profile.Quality #374

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,16 +697,16 @@ func createCOutputParams(input *TranscodeOptionsIn, ps []TranscodeOptions) ([]C.
"preset": "slow",
"tier": "high",
}
if p.Profile.CRF != 0 {
if p.Profile.CRF <= 63 {
p.VideoEncoder.Opts["crf"] = strconv.Itoa(int(p.Profile.CRF))
if p.Profile.Quality != 0 {
if p.Profile.Quality <= 63 {
p.VideoEncoder.Opts["crf"] = strconv.Itoa(int(p.Profile.Quality))
} else {
glog.Warning("Cannot use CRF param, value out of range (0-63)")
}

// There's no direct numerical correspondence between CQ and CRF.
// From some experiments, it seems that setting CQ = CRF + 7 gives similar visual effects.
cq := p.Profile.CRF + 7
cq := p.Profile.Quality + 7
if cq <= 51 {
p.VideoEncoder.Opts["cq"] = strconv.Itoa(int(cq))
} else {
Expand Down
10 changes: 5 additions & 5 deletions ffmpeg/videoprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ type VideoProfile struct {
Encoder VideoCodec
ColorDepth ColorDepthBits
ChromaFormat ChromaSubsampling
// CRF is used to set CRF and CQ
// Quality is used to set CRF and CQ
// If set, then constant rate factor is used instead of constant bitrate
// If both CRF and Bitrate are set, then Bitrate is used only as max bitrate
CRF uint
// If both Quality and Bitrate are set, then Bitrate is used only as max bitrate
Quality uint
}

// Some sample video profiles
Expand Down Expand Up @@ -235,7 +235,7 @@ type JsonProfile struct {
Encoder string `json:"encoder"`
ColorDepth ColorDepthBits `json:"colorDepth"`
ChromaFormat ChromaSubsampling `json:"chromaFormat"`
CRF uint `json:"crf"`
Quality uint `json:"quality"`
}

func ParseProfilesFromJsonProfileArray(profiles []JsonProfile) ([]VideoProfile, error) {
Expand Down Expand Up @@ -281,7 +281,7 @@ func ParseProfilesFromJsonProfileArray(profiles []JsonProfile) ([]VideoProfile,
ColorDepth: profile.ColorDepth,
// profile.ChromaFormat of 0 is default ChromaSubsampling420
ChromaFormat: profile.ChromaFormat,
CRF: profile.CRF,
Quality: profile.Quality,
}
parsedProfiles = append(parsedProfiles, prof)
}
Expand Down
Loading