If you are intending on displaying portrait video, you will need to ensure that Hierarchical B-frames (B-Pyramid) are disabled on your video content. This article will document the correct encoding process using Handbrake and MediaCoder.
Handbrake
Import your video by pressing File > Open Source or dragging and dropping into the application
Head to the Dimensions tab, change the Resolution Limit to Custom
Set the Maximum Size to 1080 x 1920, Anamorphic to Automatic and tick Optimal Size
Click on the Video tab and set the Video Encoder to H.265 (Intel QSV or AMD VCE dependent on what chipset is available on your device)
Set your framerate (30FPS Max) and tick Constant Framerate
In the Advanced Options: field, type b-pyramid=0 or no-open-gop
Next, hit Browse to rename your file and choose your export location
When ready, press Start Encode
MediaCoder
Import your video by pressing File > Add File or dragging and dropping into the application
Head to the Video tab, change the Format to H.265
Set the Rate Mode to Variable Bitrate
Look to the right-hand side of the application and click on the x265 tab
Set the Preset to Custom, change the right-hand drop-down next to B-Frames to None
Next, click on the Advanced radio button below the HEVC logo and ensure that Enable open-GOP is unticked.
Once you have configured the rest of your video encoding preferences as desired (see this article for more details), you can then press Start to begin the encoding process.