Video: Update ffmpeg transcoding parameters #703 #1060

This commit is contained in:
Michael Mayer 2021-02-17 16:48:20 +01:00
parent e732a7b860
commit 0414e09d58
3 changed files with 11 additions and 7 deletions

View file

@ -319,8 +319,8 @@ func (c *Convert) AvcBitrate(f *MediaFile) string {
if bitrate <= 0 { if bitrate <= 0 {
return "8M" return "8M"
} else if bitrate >= 50 { } else if bitrate >= 100 {
return "50M" return "100M"
} }
return fmt.Sprintf("%dM", bitrate) return fmt.Sprintf("%dM", bitrate)
@ -337,13 +337,17 @@ func (c *Convert) AvcConvertCommand(f *MediaFile, avcName, codecName string) (re
c.conf.FFmpegBin(), c.conf.FFmpegBin(),
"-i", f.FileName(), "-i", f.FileName(),
"-c:v", codecName, "-c:v", codecName,
"-c:a", "copy", "-c:a", "libmp3lame",
"-vf", format, "-vf", format,
"-num_output_buffers", strconv.Itoa(c.conf.FFmpegBuffers()+8), "-num_output_buffers", strconv.Itoa(c.conf.FFmpegBuffers()+8),
"-num_capture_buffers", strconv.Itoa(c.conf.FFmpegBuffers()), "-num_capture_buffers", strconv.Itoa(c.conf.FFmpegBuffers()),
"-max_muxing_queue_size", "1024",
"-crf", "23", "-crf", "23",
"-vsync", "vfr",
"-r", "30",
"-b:v", c.AvcBitrate(f), "-b:v", c.AvcBitrate(f),
"-f", "mp4", "-f", "mp4",
"-y",
avcName, avcName,
) )
} else { } else {

View file

@ -311,6 +311,6 @@ func TestConvert_AvcBitrate(t *testing.T) {
mf.width = 4096 mf.width = 4096
mf.height = 2160 mf.height = 2160
assert.Equal(t, "50M", convert.AvcBitrate(mf)) assert.Equal(t, "100M", convert.AvcBitrate(mf))
}) })
} }

View file

@ -24,9 +24,9 @@ func ConvertWorker(jobs <-chan ConvertJob) {
case job.convert == nil: case job.convert == nil:
continue continue
case job.file.IsVideo(): case job.file.IsVideo():
if _, err := job.convert.ToJson(job.file); err != nil { _, _ = job.convert.ToJson(job.file)
logError(err, job)
} else if _, err := job.convert.ToJpeg(job.file); err != nil { if _, err := job.convert.ToJpeg(job.file); err != nil {
logError(err, job) logError(err, job)
} else if metaData := job.file.MetaData(); metaData.CodecAvc() { } else if metaData := job.file.MetaData(); metaData.CodecAvc() {
continue continue