Videos: Tweak FFmpeg arguments for Intel QSV Encoder #1337
This commit is contained in:
parent
fce13182e6
commit
13d1abfb0d
2 changed files with 45 additions and 21 deletions
|
@ -24,5 +24,5 @@ tensorflow-amd64-avx2-install:
|
||||||
ldconfig
|
ldconfig
|
||||||
intel-graphics:
|
intel-graphics:
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install intel-opencl-icd intel-media-va-driver-non-free libmfx1
|
apt-get install intel-opencl-icd intel-media-va-driver-non-free libva i965-va-driver i965-va-driver-shaders libmfx libmfx1
|
||||||
apt-get -y autoremove && apt-get -y autoclean && apt-get clean && rm -rf /var/lib/apt/lists/*
|
apt-get -y autoremove && apt-get -y autoclean && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
@ -26,6 +26,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const DefaultAvcEncoder = "libx264" // Default FFmpeg AVC software encoder.
|
const DefaultAvcEncoder = "libx264" // Default FFmpeg AVC software encoder.
|
||||||
|
const IntelQsvEncoder = "h264_qsv"
|
||||||
|
|
||||||
// Convert represents a converter that can convert RAW/HEIF images to JPEG.
|
// Convert represents a converter that can convert RAW/HEIF images to JPEG.
|
||||||
type Convert struct {
|
type Convert struct {
|
||||||
|
@ -361,24 +362,47 @@ func (c *Convert) AvcConvertCommand(f *MediaFile, avcName, codecName string) (re
|
||||||
// Don't transcode more than one video at the same time.
|
// Don't transcode more than one video at the same time.
|
||||||
useMutex = true
|
useMutex = true
|
||||||
|
|
||||||
format := "format=yuv420p"
|
if codecName == IntelQsvEncoder {
|
||||||
result = exec.Command(
|
format := "format=rgb32"
|
||||||
c.conf.FFmpegBin(),
|
|
||||||
"-i", f.FileName(),
|
result = exec.Command(
|
||||||
"-c:v", codecName,
|
c.conf.FFmpegBin(),
|
||||||
"-c:a", "aac",
|
"-qsv_device", "/dev/dri/renderD128",
|
||||||
"-vf", format,
|
"-init_hw_device", "qsv=hw",
|
||||||
"-num_output_buffers", strconv.Itoa(c.conf.FFmpegBuffers()+8),
|
"-filter_hw_device", "hw",
|
||||||
"-num_capture_buffers", strconv.Itoa(c.conf.FFmpegBuffers()),
|
"-i", f.FileName(),
|
||||||
"-max_muxing_queue_size", "1024",
|
"-c:a", "aac",
|
||||||
"-crf", "23",
|
"-vf", format,
|
||||||
"-vsync", "vfr",
|
"-c:v", codecName,
|
||||||
"-r", "30",
|
"-vsync", "vfr",
|
||||||
"-b:v", c.AvcBitrate(f),
|
"-r", "30",
|
||||||
"-f", "mp4",
|
"-b:v", c.AvcBitrate(f),
|
||||||
"-y",
|
"-maxrate", c.AvcBitrate(f),
|
||||||
avcName,
|
"-f", "mp4",
|
||||||
)
|
"-y",
|
||||||
|
avcName,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format := "format=yuv420p"
|
||||||
|
|
||||||
|
result = exec.Command(
|
||||||
|
c.conf.FFmpegBin(),
|
||||||
|
"-i", f.FileName(),
|
||||||
|
"-c:v", codecName,
|
||||||
|
"-c:a", "aac",
|
||||||
|
"-vf", format,
|
||||||
|
"-num_output_buffers", strconv.Itoa(c.conf.FFmpegBuffers()+8),
|
||||||
|
"-num_capture_buffers", strconv.Itoa(c.conf.FFmpegBuffers()),
|
||||||
|
"-max_muxing_queue_size", "1024",
|
||||||
|
"-crf", "23",
|
||||||
|
"-vsync", "vfr",
|
||||||
|
"-r", "30",
|
||||||
|
"-b:v", c.AvcBitrate(f),
|
||||||
|
"-f", "mp4",
|
||||||
|
"-y",
|
||||||
|
avcName,
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, useMutex, fmt.Errorf("convert: file type %s not supported in %s", f.FileType(), txt.Quote(f.BaseName()))
|
return nil, useMutex, fmt.Errorf("convert: file type %s not supported in %s", f.FileType(), txt.Quote(f.BaseName()))
|
||||||
}
|
}
|
||||||
|
@ -461,9 +485,9 @@ func (c *Convert) ToAvc(f *MediaFile, encoderName string) (file *MediaFile, err
|
||||||
err = errors.New(stderr.String())
|
err = errors.New(stderr.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log original ffmpeg error (unless empty).
|
// Log ffmpeg output for debugging.
|
||||||
if err.Error() != "" {
|
if err.Error() != "" {
|
||||||
log.Error(err)
|
log.Debug(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log filename and transcoding time.
|
// Log filename and transcoding time.
|
||||||
|
|
Loading…
Reference in a new issue