Videos: Reduce bitrate estimate #703

This commit is contained in:
Michael Mayer 2021-02-15 15:52:35 +01:00
parent 0c1bdbfac6
commit 0747b6d667
2 changed files with 10 additions and 7 deletions

View file

@ -309,7 +309,10 @@ func (c *Convert) AvcBitrate(f *MediaFile) string {
return "8M"
}
bitrate := int(math.Ceil(float64(f.Width()*f.Height()*15) / 1000000))
// Baseline: 15
quality := 12
bitrate := int(math.Ceil(float64(f.Width()*f.Height()*quality) / 1000000))
if bitrate <= 0 {
return "8M"

View file

@ -249,7 +249,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
conf := config.TestConfig()
convert := NewConvert(conf)
t.Run("1M", func(t *testing.T) {
t.Run("low", func(t *testing.T) {
fileName := filepath.Join(conf.ExamplesPath(), "gopher-video.mp4")
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)
@ -263,7 +263,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
assert.Equal(t, "1M", convert.AvcBitrate(mf))
})
t.Run("20M", func(t *testing.T) {
t.Run("medium", func(t *testing.T) {
fileName := filepath.Join(conf.ExamplesPath(), "gopher-video.mp4")
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)
@ -277,10 +277,10 @@ func TestConvert_AvcBitrate(t *testing.T) {
mf.width = 1280
mf.height = 1024
assert.Equal(t, "20M", convert.AvcBitrate(mf))
assert.Equal(t, "16M", convert.AvcBitrate(mf))
})
t.Run("32M", func(t *testing.T) {
t.Run("high", func(t *testing.T) {
fileName := filepath.Join(conf.ExamplesPath(), "gopher-video.mp4")
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)
@ -294,10 +294,10 @@ func TestConvert_AvcBitrate(t *testing.T) {
mf.width = 1920
mf.height = 1080
assert.Equal(t, "32M", convert.AvcBitrate(mf))
assert.Equal(t, "25M", convert.AvcBitrate(mf))
})
t.Run("50M", func(t *testing.T) {
t.Run("very_high", func(t *testing.T) {
fileName := filepath.Join(conf.ExamplesPath(), "gopher-video.mp4")
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)