That made the trick. Now I only have to test if it did work :D
Ok, I run:
ffmpeg -y -vsync 0 -hwaccel vaapi -hwaccel_output_format vaapi -i sample.mp4 -c:a copy -c:v h264_nvmpi -b:v 5M output.mp4
An it run !!! Around 70fps with a 1920x1080 file in my Jetson Nano 2GB
The command I used is inspired by the one found in the NVIDIA documentation on how to compile ffmpeg with cuda support, just replacing cuda with vaapi
It is true that while running, I see this message as output:
[AVHWDeviceContext @ 0x55c3e76ec0] Failed to initialise VAAPI connection: -1 (unknown libva error). Device creation failed: -5. [h264 @ 0x55c3e7f670] No device available for decoder (device type vaapi for codec h264). Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvmpi)) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [h264 @ 0x55c3fc5ff0] A hardware device or frames context is required for VAAPI decoding.
That seems related to the decoding part that worries me less as the python library I’m using doesn’t enable me to pass parameters to ffmpeg, but it does for encoding !!!
sample.mp4 uses h264 format, in your command you are missing
-c:v h264_nvmpi before
-i (position is important,
-i tells ffmpeg how to decode the stream, and after
-i it says how to encode it). Also, options
-hwaccel vaapi -hwaccel_output_format vaapi are not needed and just cause errors as far as I can tell. However, the errors seem to be harmless and do not affect performance. But providing just a single
-c:v option instead of both does affect the performance.
I suggest to use the following command instead:
ffmpeg -y -vsync 0 -c:v h264_nvmpi -i sample.mp4 -c:a copy -c:v h264_nvmpi -b:v 5M output.mp4
You may need to use
hevc_nvmpi instead of
sample.mp4 contains HEVC stream.
Just an update. I could make docker containers out of the packages and it runs well. Since I am running Ubuntu 20.04 on nano I could not install as it were.