UMS on Ubuntu 24.10

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: UMS on Ubuntu 24.10

Post by mik_s »

I can see that the transcode command will use the GPU as it has the option h264_nvenc now

Code: Select all

Starting /usr/bin/ffmpeg -y -loglevel info -i "/media/dave/Godzilla/Short Videos/bbb_sunflower_2160p_30fps_stereo_abl.mp4" -filter_complex [0:v]scale=iw*min(3840/iw\,2160/ih):ih*min(3840/iw\,2160/ih),[0:v]pad=ceil(iw/4)*4:ceil(ih/4)*4:(ow-iw)/2:(oh-ih)/2 -bufsize 1000000k -maxrate 999000k -crf 19 -ab 448k -c:a ac3 -c:v h264_nvenc -preset llhp -pix_fmt yuv420p -f mpegts /tmp/UMS-dave/ffmpegvideo_113_1742211237728
I think the main problem is the resolution of this video as it is trying to re-scale the double height 4320 down to 2160 and it could be this part that is causing FFmpeg to fail.
For this video it would have to be streamed for the 3D to work properly assuming the TV handles this, or it might only be suitable for playing in a VR headset and there is some options in UMS to allow this.

Code: Select all

[ffmpeg-2-2] net.pms.io.OutputTextLogger [h264_nvenc @ 0x624b68908080] InitializeEncoder failed: invalid param (8): Invalid Level.
[ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:0/h264_nvenc @ 0x624b68945a80] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[ffmpeg-2-2] net.pms.io.OutputTextLogger [fc#0 @ 0x624b688fb080] Error sending frames to consumers: Invalid argument
[ffmpeg-2-2] net.pms.io.OutputTextLogger [fc#0 @ 0x624b688fb080] Task finished with error code: -22 (Invalid argument)
[ffmpeg-2-2] net.pms.io.OutputTextLogger [fc#0 @ 0x624b688fb080] Terminating thread with return code -22 (Invalid argument)
[ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:0/h264_nvenc @ 0x624b68945a80] Could not open encoder before EOF
[ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:0/h264_nvenc @ 0x624b68945a80] Task finished with error code: -22 (Invalid argument)
[ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:0/h264_nvenc @ 0x624b68945a80] Terminating thread with return code -22 (Invalid argument)
[ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:1/h264_nvenc @ 0x624b68946580] Could not open encoder before EOF
[ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:1/h264_nvenc @ 0x624b68946580] Task finished with error code: -22 (Invalid argument)
 [ffmpeg-2-2] net.pms.io.OutputTextLogger [vost#0:1/h264_nvenc @ 0x624b68946580] Terminating thread with return code -22 (Invalid argument)
[ffmpeg-2-2] net.pms.io.OutputTextLogger [out#0/mpegts @ 0x624b68943f80] Nothing was written into output file, because at least one of its streams received no packets.
[ffmpeg-2-2] net.pms.io.OutputTextLogger frame=    0 fps=0.0 q=0.0 Lq=0.0 size=       0KiB time=N/A bitrate=N/A speed=N/A    
[ffmpeg-2-2] net.pms.io.OutputTextLogger Conversion failed!
[ffmpeg-2] net.pms.io.BufferedOutputFileImpl EOF
[ffmpeg-2] net.pms.io.ProcessWrapperImpl Process /usr/bin/ffmpeg has a return code of 234! Maybe an error occurred... check the log file
(its strange the error is 234 as the error code FFmpeg gives is -22)

As this is a test for a worst case video it may be better to get something more common to work properly first before pushing it.
See if you have anything 1080p, maybe using h265 so that it will need to be transcoded according to the supported formats in this conf.
Once this is confirmed to work then we can focus on 4K and the the oddball resolutions.

You could also do logs while playing in the web player as this will transcode everything to one standard format that it can play well using HLS.
This may still use a lot of CPU, at least initially, as it has to split the video into tiny chunks to be transcoded separately and this will need more CPU to set this up.
GPU usage may actually not show much change as it will only be using a small part of the GPU and because of the start stop nature of HLS there will only be spikes of activity so the average usage will be very low.
This is what it looks like playing for me with a GTX 1650 on windows according to Task Manager and Process Explorer

Code: Select all

Starting "C:\Program Files\Universal Media Server\bin\ffmpeg.exe" -y -loglevel info -t 6.0 -sn -i C:\Users\Mik\Videos\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_67_1742047834493
Screenshot 2025-03-17 184929.png
Screenshot 2025-03-17 184929.png (58.01 KiB) Viewed 1518 times
Screenshot 2025-03-17 184758.png
Screenshot 2025-03-17 184758.png (55.99 KiB) Viewed 1518 times
Also try with setting to use the FFmpeg version installed by UMS as this has the HLS feature enabled along with some others it might need.
This should also have the Nvidia headers included in the build.
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.
aemondis
Posts: 6
Joined: Sat Mar 15, 2025 1:30 am

Re: UMS on Ubuntu 24.10

Post by aemondis »

I finally got a chance to look at this again tonight (work has been crazy busy), and here's the status update:

- I downloaded a "typical" 4K 60fps variant of the same test video.
- Playing this video the first time plays automatically with no transcoding
- Attempting to resume after a short period (e.g. 10 seconds) seems to continue playing from the existing position, without transcoding.
- Waiting longer, then resuming seems to force transcoding via ffmpeg, which fails (it perpetually gets stuck at "buffering", and ffmpeg repeatedly terminates itself).

Monitoring via nvtop - I don't see any activity by ffmpeg whatsoever on the GPU (if it was using it, the process will appear in the list). Latest debug log attached.
_ums_dbg_2025-03-20-22-39.zip
(186.35 KiB) Downloaded 95 times
I'll give the UMS-packaged ffmpeg a try and see if it behaves any different...
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: UMS on Ubuntu 24.10

Post by mik_s »

It makes sense that the GPU is not being used for that video as it is only copying the video stream (remuxing) and not transcoding it as you can see by the -c:v copy option

Code: Select all

Starting /opt/ums/ums-14.10.1/linux/ffmpeg -y -loglevel info -ss 136.0 -i "/media/dave/Godzilla/Short Videos/bbb_sunflower_2160p_60fps_normal.mp4" -map 0:V -map 0:a:0 -ab 448k -c:a ac3 -c:v copy -f mpegts /tmp/UMS-dave/ffmpegvideo_270_1742470458649
Only the audio is transcoded because it is in MP3 and this is not supported in a transcoded stream.

Code: Select all

Audio was not remuxed because audio stream type MP3 is not supported inside the container MPEGTS-H264-AC3
The only reason why it is transcoding at all is because the resume feature is turned on in UMS which creates a virtual file for the last played position for those devices that have no resume and does this by transcoding/remuxing.

Most devices these days remember the last played position themselves so is best to turn resume off in UMS to prevent this unwanted transcoding.

Try a 1080p video using h265 and that should use the GPU. Once that is working then try a 4K one.
Playing in the web player will be the best indication of what it is doing.


There are some errors which I think are coming from the renderer, possibly from the image it is sending for the icon

Code: Select all

org.eclipse.jetty.ee10.servlet.ServletChannel /ums/media/b3688e82-2c9e-3a0e-9f32-a0f2987d7139/214
java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
	at net.pms.network.mediaserver.MediaServerRequest.<init>(MediaServerRequest.java:83)
	at net.pms.network.mediaserver.servlets.MediaServerServlet.doGetHead(MediaServerServlet.java:95)
	at net.pms.network.mediaserver.servlets.MediaServerServlet.doGet(MediaServerServlet.java:88)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
	at net.pms.network.mediaserver.servlets.MediaServerHttpServlet.service(MediaServerHttpServlet.java:35)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
	at org.eclipse.jetty.ee10.servlet.ServletHolder.handle(ServletHolder.java:736)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1619)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$MappedServlet.handle(ServletHandler.java:1552)
	at org.eclipse.jetty.ee10.servlet.ServletChannel.dispatch(ServletChannel.java:819)
	at org.eclipse.jetty.ee10.servlet.ServletChannel.handle(ServletChannel.java:436)
	at org.eclipse.jetty.ee10.servlet.ServletHandler.handle(ServletHandler.java:469)
	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1060)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:151)
	at org.eclipse.jetty.server.Server.handle(Server.java:182)
	at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:662)
	at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:418)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:99)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:480)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:443)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:195)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:979)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1209)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1164)
	at java.base/java.lang.Thread.run(Unknown Source)
as this happens just before it.

Code: Select all

net.pms.image.ImagesUtil Converting byte array image source to JPEG_TN format and type DLNAThumbnail using the following parameters: PadToSize = False
net.pms.image.ImagesUtil Image conversion DLNA compliance check for JPEG_TN: The source image colors are compliant, format is compliant and resolution (320 x 180) is non-compliant.
Failures:
  JPEG_TN DLNA compliance failed with wrong resolution 320 x 180 (limits are 160 x 160)
This should not have any effect on playback.
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.
Post Reply