What defines if the content will be transcoded to h264 or h265?

If you have a suggestion for a feature, post it here
Post Reply
Heiler
Posts: 40
Joined: Sun Mar 13, 2016 1:04 pm

What defines if the content will be transcoded to h264 or h265?

Post by Heiler »

In "ffmpeg video" we can choose the acceleration method, although nothing but libx265 worked here (GTX3060Ti), but what defines if my PC is going to use mpeg2, h264 or h265? It seems this is defined in the renderer's config but it's my cpu/gpu that should matter, or at least I should be able to choose the default anywhere!!
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: What defines if the content will be transcoded to h264 or h265?

Post by mik_s »

The transcoding profile in the renderer's conf.

From DefaultRenderer.conf

Code: Select all

#-----------------------------------------------------------------------------
# TRANSCODING AND MUXING CAPABILITIES
#
# It is very likely that a renderer cannot render all file formats. If this is
# the case, UMS should transcode or mux the file to a format that the renderer
# can display. This section defines the format that UMS should transcode or
# mux to.
#

# Profile to use for transcoding video files.
# Options:
#
#    Profile               Video           Audio   Container   Notes
#    ---------------------------------------------------------------
#    HLS-MPEGTS-H264-AAC   H.264           AAC     MPEG-TS     Allows adaptive quality
#    HLS-MPEGTS-H264-AC3   H.264           AC-3    MPEG-TS     Allows adaptive quality
#    MP4-H264-AAC          H.264 (AVC)     AAC     MP4
#    MP4-H265-AC3          H.265 (HEVC)    AC-3    MP4
#    MPEGPS-MPEG2-AC3      MPEG-2          AC-3    MPEG-PS     VLC only outputs 2-channel AC-3 audio
#    MPEGTS-MPEG2-AC3      MPEG-2          AC-3    MPEG-TS     VLC only outputs 2-channel AC-3 audio
#    MPEGTS-H264-AC3       H.264 (AVC)     AC-3    MPEG-TS     VLC only outputs 2-channel AC-3 audio
#    MPEGTS-H264-AAC       H.264 (AVC)     AAC     MPEG-TS     Not DLNA-compliant
#    MPEGTS-H265-AC3       H.265 (HEVC)    AC-3    MPEG-TS     Only FFmpeg outputs H.265, others will output H.264
#    MPEGTS-H265-AAC       H.265 (HEVC)    AAC     MPEG-TS     Only FFmpeg outputs H.265, others will output H.264, not DLNA-compliant
#    WMV:                  WMV 2 (WMV 8)   WMA 2   ASF
#
# These profiles are supported by the MEncoder, FFmpeg and VLC engines.
# Multiple profiles can be use in case the first cannot handle everything (like HLS)
# eg: HLS-MPEGTS-H264-AAC, MPEGTS-H264-AAC
# Default: MPEGPS-MPEG2-AC3
TranscodeVideo = 
For the GPU to be used it has to be enabled
Screenshot 2025-03-10 221130.png
Screenshot 2025-03-10 221130.png (6.57 KiB) Viewed 6451 times
and the right encoder selected for that card in FFmpeg transcoding settings.
Screenshot 2025-03-10 222811.png
Screenshot 2025-03-10 222811.png (5.92 KiB) Viewed 6451 times
Screenshot 2025-03-04 171257.png
Screenshot 2025-03-04 171257.png (20.3 KiB) Viewed 6451 times
The capabilities of the card will be selected automatically but can be set manually by editing UMS.conf as this is not an option in the GUI.
It is better to keep this blank so the default "auto" is used.

Code: Select all

ffmpeg_gpu_decoding_acceleration_method=
If you check the transcoding command you will be able to see if this is being used. This is from playing in the web player where you can see h264_nvenc is being used.

Code: Select all

Starting "C:\Program Files\Universal Media Server\bin\ffmpeg.exe" -y -loglevel info -ss 516 -t 6.0 -sn -i "video.mkv" -sn -dn -copyts -c:v h264_nvenc -keyint_min 25 -profile:v high -level 41 -pix_fmt yuv420p -c:a aac -ac 6 -ab 320000 -f mpegts -skip_estimate_duration_from_pts 1 -use_wallclock_as_timestamps 1 -movflags frag_keyframe \\.\pipe\ffmpeghlsvideo_11726_1741645432547
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
Heiler
Posts: 40
Joined: Sun Mar 13, 2016 1:04 pm

Re: What defines if the content will be transcoded to h264 or h265?

Post by Heiler »

Yeah there's an option to use the gpu or not, to choose which way h264 or h265 would be encoded (via software or hardware).

But in the end it's the Renderer's .conf that will decide between mpeg2/h264/h265, not the user and not the server (based on cpu/gpu capabilities), which I think it's ODD.
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: What defines if the content will be transcoded to h264 or h265?

Post by mik_s »

Its more to do with what the device is better at playing, although it would be better if there was some intelligence for UMS to pick a more suitable transcoding profile depending on circumstance. eg if the video is already using h265 then using the h265 profile is better as the video can be remuxed instead of transcoded, and if using h264 the h264 profile is more suitable.

However setting this up in the conf and confirming each profile works will multiply the work checking each one, and I don't think it is just as simple as changing the profile as there may need some custom ffmpeg settings to work. I know the Roku confs have this as I was looking at them recently.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
Heiler
Posts: 40
Joined: Sun Mar 13, 2016 1:04 pm

Re: What defines if the content will be transcoded to h264 or h265?

Post by Heiler »

If the content is in H.265 and the TV or renderer supports it, it will play directly without transcoding. That part is working fine.

The issue arises when transcoding is required for any reason. In that case, the system automatically uses the codec defined in the renderer's "TranscodeVideo" parameter, and the user has no control over which codec is chosen. The only option available is selecting between software or hardware encoding.

Personally, I have no issues with this since my system can handle H.265 4K in real-time. But just imagine trying to do that on an old laptop without a proper GPU... 😅
x265 is heavy as F
Post Reply