Add checkEncoderLimits() call at start of Transcode() function that will adjust output resolution to be at least the size of minimum supported resolution.
Hardcoded constraints are taken from 7th Gen NVENC card
360p and 240p profiles don't cause the bug, but produce incorrect output size for portrait video inputs.
When input video is in portrait mode and specified output in landscape mode we convert desired output resolution to be in portrait mode.
output resolution
converted
640x360
360x640
426x240
240x426
When output resolution is converted then limits are checked. In case of 144p resolution that causes Invalid argument bug converted resolution is larger than requested to accommodate hardware capabilities.
output resolution
converted
256x144
146x259
How to test
Nvidia card is required.
cd ffmpeg
go test . -v -count 1 -tags nvidia -run TestTranscoder_Portrait
=== RUN TestTranscoder_Portrait
decoder.c:185] No audio stream found in input
--- PASS: TestTranscoder_Portrait (0.43s)
PASS
ok github.com/livepeer/lpms/ffmpeg 0.439s
Fix for TestTranscoder_Portrait test
Add
checkEncoderLimits()
call at start ofTranscode()
function that will adjust output resolution to be at least the size of minimum supported resolution.Hardcoded constraints are taken from 7th Gen NVENC card
Fix for mistaking landscape for portrait
360p
and240p
profiles don't cause the bug, but produce incorrect output size for portrait video inputs.When input video is in portrait mode and specified output in landscape mode we convert desired output resolution to be in portrait mode.
640x360
360x640
426x240
240x426
When output resolution is converted then limits are checked. In case of
144p
resolution that causesInvalid argument
bug converted resolution is larger than requested to accommodate hardware capabilities.256x144
146x259
How to test
Nvidia card is required.