[FFmpeg Web Video] videostream unnecesary transcoding?

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
Wolfgan
Posts: 370
Joined: Fri Feb 08, 2013 12:33 am

[FFmpeg Web Video] videostream unnecesary transcoding?

Post by Wolfgan »

I prepared an internal livestream via VLC that I want to distribute/be discovered via UMS. The VLC command includes:

Code: Select all

:sout=#http{mux=ts,dst=:8082/} :sout-all :ttl=3 :sout-keep
And UMS.conf includes the line:

Code: Select all

videostream.Web,IPTVh8082=LiveHttp 8082,http://192.168.1.84:8082/
My Kalemsoft renderer supports that stream in the conf file, and that's reflected in the logs:

Code: Select all

Matched support line f:mpegps|mpegts|mpg   m:video/mpeg
Problem is, that when ffmpeg is launched to treat that stream, it launches a full transcoding as per:

Code: Select all

Starting D:\Program Files\Universal Media Server\win32\ffmpeg64.exe -y -loglevel info -i http://192.168.1.84:8082/ -c:a ac3 -c:v mpeg2video -f vob -g 5 -q:v 1 -qmin 2 -qmax 3 -q:a 3 \\.\pipe\ffmpegwebvideo_68_1452711823793
Is there any way to control ffmpeg behavior in Web Video mode and avoid transcoding, or if remuxing is needed, at most force video / audio streams to be copied as is and let the renderer handle them natively?

Ichecked https://github.com/UniversalMediaServer ... webfilters and https://github.com/UniversalMediaServer ... Video.java but couldn't find any tip in how/if additional configuration is needed.

Thx for any help, Wolf.
Attachments
ums_dbg-httpstream.zip
(66.04 KiB) Downloaded 743 times
-- UMS serving PS3, WDTV, Samsung H6400 + J5500 and Kalemsoft renderers! (no video transcoding but remuxing accepted :D )
Nadahar
Posts: 1990
Joined: Tue Jun 09, 2015 5:57 pm

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by Nadahar »

I don't know anything about web streaming in UMS, but it doesn't seem like it even tries to match the "supported" lines. This line could be a hint:

Code: Select all

TRACE 2016-01-13 15:43:10.025 [main] Could not match any format to ".84:8082/"
I don't think UMS manages to find any information about the media, and thus it's not possible to check if it's supported or not. I'd give the "old mediaparser" a try and see if it does a better job with web streams. To enable that, set

Code: Select all

MediaInfo = false
in the renderer profile. I'm sure you know this, but that means the "supported" lines won't be read, and the old "TranscodeExtensions" and "StreamExtensions" come into play instead. But, there's no extension for a stream, so I don't know what it will do. It will probably transcode as well.
Wolfgan
Posts: 370
Joined: Fri Feb 08, 2013 12:33 am

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by Wolfgan »

Thanks Nadahar for the catch, I didn't noticed the line:

Code: Select all

TRACE 2016-01-13 15:43:10.025 [main] Could not match any format to ".84:8082/"
That's weird as ".84:8082/" is the trail part of the URL declared in Web.conf
Will do a quick test with MediaInfo = false and see what happens then...
Thanks!
-- UMS serving PS3, WDTV, Samsung H6400 + J5500 and Kalemsoft renderers! (no video transcoding but remuxing accepted :D )
infidel
Developer
Posts: 571
Joined: Thu Jul 12, 2012 5:37 am

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by infidel »

Wolfgan wrote:if remuxing is needed, at most force video / audio streams to be copied as is and let the renderer handle them natively?
...Ichecked ...ffmpeg.webfilters ... but couldn't find any tip in how/if additional configuration is needed.
For ffmpeg.webfilters, you could try to copy streams by adding a rule in the OPTIONS section like so:

Code: Select all

192.168.1.84:8082 | -c copy
which should add the '-c' option to the end of the ffmpeg command (no guarantees on whether this would make sense to ffmpeg or not :)). Also note that technically as a regex the dots in the address should be escaped, i.e. '192\.168\.1\.84:8082', but since '.' is itself a regex wildcard, it should work in unescaped form too.
Wolfgan
Posts: 370
Joined: Fri Feb 08, 2013 12:33 am

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by Wolfgan »

That worked (at least in light testing), thanks Infidel & Nadahar! The logs reflect ffmpeg mapping the streams in copy mode, no transcode involved.

What puzzles me now is that the live stream stops around 5 seconds after the start in all the renderers I tested. The metadata received reflects a (fake) file size of 8589934592.00 GB but just 04.08 seconds in time length.
Is there any other config option to touch and assign a longer fake 24hs length or so?
Thx, Wolf
Attachments
ums_dbg-httpstream2.zip
(81.82 KiB) Downloaded 722 times
-- UMS serving PS3, WDTV, Samsung H6400 + J5500 and Kalemsoft renderers! (no video transcoding but remuxing accepted :D )
infidel
Developer
Posts: 571
Joined: Thu Jul 12, 2012 5:37 am

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by infidel »

Wolfgan wrote:What puzzles me now is that the live stream stops around 5 seconds after the start in all the renderers I tested.
I tried it myself and I don't know whether this is the critical difference in your case, but on linux it wouldn't work until I streamed from vlc using a fake extension, per (possibly outdated?) caveat #1 in vlc wiki streaming how-to in order to avoid flv output:
:sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{dst=:8080/go.mpg} :sout-keep
and

Code: Select all

videostream.Web,VLC=test,http://127.0.0.1:8080/go.mpg
Anyhow it streams ok for me using vlc 2.2.1 and Kodi as renderer.
Wolfgan
Posts: 370
Joined: Fri Feb 08, 2013 12:33 am

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by Wolfgan »

infidel wrote:
Wolfgan wrote:What puzzles me now is that the live stream stops around 5 seconds after the start in all the renderers I tested.
I tried it myself and I don't know whether this is the critical difference in your case, but on linux it wouldn't work until I streamed from vlc using a fake extension, per (possibly outdated?) caveat #1 in vlc wiki streaming how-to in order to avoid flv output:
:sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{dst=:8080/go.mpg} :sout-keep
and

Code: Select all

videostream.Web,VLC=test,http://127.0.0.1:8080/go.mpg
Anyhow it streams ok for me using vlc 2.2.1 and Kodi as renderer.
Thanks Infidel. It seems is a matter of how the renderer interprets the received stream and the assigned size (9223372034707292159 sent by ffmpeg) / length (09:59:59 sent by ffmpeg), as I guess some renderers do their own stream analysis to assign the total length and cut after what they decide is the calculated end (and that's why I was able to watch just 5"). I need more testing on different renderers to see how they react.

Do you know by any chance where those values come from? Are they fakely sent by any UMS module? (I suspect some old renderers like WDTV may get confused receiving numbers so big, or simply overflow the values)
Thx, Wolf
-- UMS serving PS3, WDTV, Samsung H6400 + J5500 and Kalemsoft renderers! (no video transcoding but remuxing accepted :D )
infidel
Developer
Posts: 571
Joined: Thu Jul 12, 2012 5:37 am

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by infidel »

Wolfgan wrote:Do you know by any chance where those values come from? Are they fakely sent by any UMS module?
Yes, ums does it when there's no media info (afaik this dates back to early PMS days and spoofing the PS3 to accept transcoding). But I somehow doubt that this is why you're getting an abrupt termination.

If fake extension had no effect for you, maybe try

Code: Select all

ChunkedTransfer=true
in the renderer conf, which will cause 'honest' Content-Length and Content-Range headers to be sent with the streamed data.
jtmaher
Posts: 10
Joined: Mon Mar 02, 2026 4:21 pm

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by jtmaher »

Sorry to necro this thread, but it's really important. I tried adding a video stream to the OPTIONS section of my ffmpeg.webfilters:

Code: Select all

# These are custom rules to fine-tune the behaviour of
# FFmpeg Web Video transcoding with respect to specific urls.  


########################## EXCLUDE ##############################
# urls to be skipped (i.e. passed along to later engines)
#    format:   <regex to match>
#################################################################

EXCLUDE

# unresolved youtube urls
#gdata\.youtube\.com|youtube_gdata

# other unresolved urls
feeds\.feedburner\.com
www\.gameswelt\.de
eurogamer\.net
gametrailers\.com
giantbomb\.com
icanhascheezburger\.com
pcgames\.de
winfuture\.de


########################## OPTIONS ##############################
# urls requiring specific FFmpeg options.
#    format:   <regex to match> | <options to add>
#################################################################

OPTIONS

trailers\.apple\.com | -user-agent QuickTime/7.6.2
# uncomment the rule below if you experience audio problems with endgadget:
#www\.viddler\.com | -target ntsc-dvd
# THIS IS THE LINE THAT I ADDED
http://127\.0\.0\.1:8080/ | -c:v copy

########################## REPLACE ##############################
# urls to be modified (using capture groups).
#    format:   <regex to match> | <replacement regex>
#    example: .*somewhere\.com.* | $0\?somevar=true
#################################################################

REPLACE

# no rules yet
It doesn't do anything. The video from this stream still gets transcoded using libx264. Does anyone know what's going on? This is on the latest version of UMS.
User avatar
mik_s
Moderator
Posts: 1766
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: [FFmpeg Web Video] videostream unnecesary transcoding?

Post by mik_s »

I did not read much of this thread, just skimmed the OP, as it is very old and probably does not apply any more.
I know nothing about the web filters, I think these days UMS handles web streams a lot better and most often these use hls.

As I understand at a quick look I think you need to set a UMS option for that rule and "-c:v copy" is for FFmpeg.
I think what you meant to use here is CustomFFmpegOptions = -c:v copy but I have no idea if it would work.
I don't know if this is right or even if these filters are used in the current version.
The important thing to get right is your renderer conf so UMS knows whether to transcode or not.

Is this for your Sony TV where you made the conf tweaks? I don't think the changes you made would work for this.

If you are wanting to play from the web browser these will always be transcoded into h264 using hls as is the standard for html5, mainly because it does not have the downsides of normal transcoding like being unable to seek and not able to change audio/sub tracks.

What specifically are you trying to do?
I might be able to give better help if I could see your logs on why it is transcoding (see the section in red above).
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