Selecting which streams from which inputs will go into which output is either done automatically or with the -map option. The hwupload filter also requires a device to upload to, which needs to be defined before the filter graph is created which I did with -vaapi_device. It will upload to a surface with the same layout as the software frame, so it may be necessary to add a format filter immediately before to get the input into the right format (hardware generally wants the nv12 layout). If the input is in normal memory, it will need to be uploaded before giving the frames to the encoder - in the ffmpeg utility, the hwupload filter can be used for this. The encoders only accept input as VAAPI surfaces. vf 'format=nv12,hwupload' creates the filtergraph and use it to filter the stream. MPEG-2 streams are one of the few options were it works. not all video files can be concatenated with concat filter. If your source video file is only one file then -i whatever_file.mp4 works too of course. concat is analogous to using cat on UNIX-like systems. So I’ve to concat the files which happens here: -i "concat:00001.ts|00002.ts|00003.ts". ts file suffix) in files using two GByte chunks. vaapi_device /dev/dri/renderD128 (which is a shortcut to -init_hw_device vaapi=vaapi0:/dev/dri/renderD128 -filter_hw_device vaapi0) initializes a new hardware device of type vaapi. Let’s talk about the FFmpeg parameters used above:
It should be included in every Linux distribution so just use your package manager to install it. In case of ffmpeg that means v4.3.1 at the moment. I’m running Archlinux which means that I’ve normally the latest package versions installed. It’s a complete, cross-platform solution to record, convert and stream audio and video (in case you never had heard of it). So to get started you obviously need FFmpeg installed.
So if you’re in a hurry you might prefer H.264 -) But for 1080p and even 1280p videos H.265 produces better results and smaller files. To give you an impression about encoding speed ( H.264 vs H.265): Using the same parameter just with the different encodings I get around 350-400 frames per second (fps) with H.265 and with H.264 I get around 800 fps. As you can see also Main 10 profile is supported if you want to use that one and of course H.264. VAProfileHEVCMain10 : VAEntrypointEncSliceįor all entries with a value of VAEntrypointEncSlice hardware encoding can be used and I’m using VAProfileHEVCMain (which is HEVC/H.265 Main profile). VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264ConstrainedBaseline: VAEntrypointVLD
Vainfo: VA-API version: 1.10 (libva 2.10.0 ) vainfo: Driver version: Mesa Gallium driver 20.3.4 for AMD Radeon RX 5700 XT (NAVI10, DRM 3.40.0, 5.10.14-arch1-1, LLVM 11.0.1 ) vainfo: Supported profile and entrypoints I tried various video settings and compared again.įor the impatient here is what I came up with finally after playing around a while with various FFmpeg parameters: On the left the original video and on the right the one with the H.265 encoding. So what I did to judge about the video quality was comparing two videos side by side with mpv. That said I’m by no means a video encoding expert and my main focus just was to keep the same “visual” quality when converting from the MPEG-2 streams in H.264 to H.265 and reduce the size of the original recording by about 50%+. Without expecting to much I played around a bit and the outcome was surprisingly good - and with way less power needed!
So I knew that my AMD RX 5700XT GPU supports H.265 hardware encoding. This works quite well but uses quite some power. First I used my CPU AMD 3900X for this task. And of course it should be fast and maybe even power efficient.
I was wondering how to shrink these kind of videos without lowering the “visual” quality too much.
This is quite a lot if you want to archive your videos. So for an hour of video it could take easily around 6 GByte on disk. Most public TV channels (via satellite) in Germany that I’m interested in are using MPEG-2 streams with H.264 encoding with a bitrate of about 10000-16000 kb/s.