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,7 +362,29 @@ 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
|
||||||
|
|
||||||
|
if codecName == IntelQsvEncoder {
|
||||||
|
format := "format=rgb32"
|
||||||
|
|
||||||
|
result = exec.Command(
|
||||||
|
c.conf.FFmpegBin(),
|
||||||
|
"-qsv_device", "/dev/dri/renderD128",
|
||||||
|
"-init_hw_device", "qsv=hw",
|
||||||
|
"-filter_hw_device", "hw",
|
||||||
|
"-i", f.FileName(),
|
||||||
|
"-c:a", "aac",
|
||||||
|
"-vf", format,
|
||||||
|
"-c:v", codecName,
|
||||||
|
"-vsync", "vfr",
|
||||||
|
"-r", "30",
|
||||||
|
"-b:v", c.AvcBitrate(f),
|
||||||
|
"-maxrate", c.AvcBitrate(f),
|
||||||
|
"-f", "mp4",
|
||||||
|
"-y",
|
||||||
|
avcName,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
format := "format=yuv420p"
|
format := "format=yuv420p"
|
||||||
|
|
||||||
result = exec.Command(
|
result = exec.Command(
|
||||||
c.conf.FFmpegBin(),
|
c.conf.FFmpegBin(),
|
||||||
"-i", f.FileName(),
|
"-i", f.FileName(),
|
||||||
|
@ -379,6 +402,7 @@ func (c *Convert) AvcConvertCommand(f *MediaFile, avcName, codecName string) (re
|
||||||
"-y",
|
"-y",
|
||||||
avcName,
|
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