Log in

View Full Version : LAV Filters - DirectShow Media Splitter and Decoders


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 [478] 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511

huhn
15th April 2020, 16:50
by playing a 3D file with a player that supports it.
or by checking the decoder is present in the lavfilter folder.

mzso
15th April 2020, 20:42
by playing a 3D file with a player that supports it.
or by checking the decoder is present in the lavfilter folder.

What file should I check for? Playing a file produces a plain 2d output so that doesn't help.

huhn
15th April 2020, 21:54
madVR OSD, lav video info.

3D was very limited i know iso and bd structure work not sure about mkv remuxes.

clsid
15th April 2020, 21:57
The mvc decoder file is: libmfxsw64.dll
Should be in lav folder or in system32

mzso
16th April 2020, 01:56
The mvc decoder file is: libmfxsw64.dll
Should be in lav folder or in system32

It's there in the LAV folder.
So far I couldn't get 3d output though. Potplayer even has anaglyph options for 3d. But so far I couln't get anything.

mzso
16th April 2020, 09:07
It's there in the LAV folder.
So far I couldn't get 3d output though. Potplayer even has anaglyph options for 3d. But so far I couln't get anything.

Okay. So it seems madVR was the problem. So the decoding seems to work at least.
(Whether I can get it to work with an actual 3d display remains to be seen.)

huhn
19th April 2020, 04:38
just to make that absolutely clear.

you are ware that "no" new displays support 3D for a couple years now and that 3D is discontinued on nvidia.

arrgh
23rd April 2020, 18:00
you are ware that "no" new displays support 3D for a couple years now and that 3D is discontinued on nvidia.

unfortunately, that is true, although a lot of fantasy and Sci-Fi movies are still presented in 3D...
but there are beamers...

Xaurus
28th April 2020, 23:59
Hey nev,

I've recently run into this (https://forum.doom9.org/showthread.php?p=1711988#post1711988) problem.
I have a few foreign files that have the ENG SDH subtitle as 1, and the regular ENG subtitle as 2.

The relevant part of my advanced config is this, basically when there's no ENG audio then load ENG subtitles (the last step there):
eng:eng|f eng:0ff *:eng
So what I get is subtitle 1, the SDH one. I would like the splitter to choose the regular ENG, e.g. subtitle 2.

Would it be possible, in the Lav Splitter configuration, to incorporate a button placed beneath the "Prefer Audio Streams for the Hearing/Visually impaired" called something like "Disable/Remove Audio Streams for the Hearing/Visually impaired"?
If that is possible to code, obviously. Would be great.

Or if you have other suggestions on how to solve this issue, the post I found was from 2015 and to be honest I have not read through the whole thread, it's a lot of posts.

Thanks.

nevcairiel
29th April 2020, 00:57
Since you are already using the advanced rule, there is a flag for hearing impaired subtitles, "h", so you could change yours to this:

eng:eng|f eng:off *:eng|!h

That way you'll never get SDH subtitles - if they are flagged properly. Or as an alternative also add the *:eng at the end, so that it can use the SDH subtitles if no others are available at all.
Although i'm not sure if MKV for example can flag SDH subtitles as such. I know that MPEG-TS has that for broadcast..

sneaker_ger
29th April 2020, 09:49
Although i'm not sure if MKV for example can flag SDH subtitles as such.
No such flag in mkv.

sneaker_ger
29th April 2020, 09:52
@Xaurus:
If it's mkv remember LAV Splitter can filter default/not-default flag and also filter parts of the track title (with "@" operator).

Dogway
30th April 2020, 12:05
I think there might be an issue in LAV Audio, in the Status tab it is reading (converting maybe?) input track to 32-bit float despite the source being 16 or 24-bit and having all output formats disabled except for 16 and 24-bit. I even disabled all LAV Audio processing options to skip preformatting to 32-bit float to no avail. My audio driver is set to 24-bit (max for Win7).

sneaker_ger
30th April 2020, 12:48
What is the audio codec? How do you know it "being 16 or 24-bit"?

Dogway
30th April 2020, 12:54
What is the audio codec? How do you know it "being 16 or 24-bit"?

Mediainfo

huhn
30th April 2020, 13:01
and what codec are you talking about?

Dogway
30th April 2020, 13:02
Dolby Digital. So decoding is always to 32 bit float?

huhn
30th April 2020, 13:12
for normal dolby digital 32 bit float is more correct then 16 or 24 bit int.

in general if a codec is lossy float output has a higher quality there are always exceptions.

sneaker_ger
30th April 2020, 13:25
Newer MediaInfo (rightfully) does not display bitdepth for AC3 anymore.
Version 19.09, 2019-09-10
-------------
x AC-3: AC-3 actually has no bit depth, removing the default 16 value

Xaurus
30th April 2020, 19:10
nev, sneaker

Thanks a lot for the info guys, yes it's indeed an mkv container.

So I've tried your suggestions without luck, it seems that what I need is to be able to use the ! operator in conjunction with the @ operator. And that doesn't seem to work for me.

For example, this should in theory work...
*:eng|!@SDH
... because the SDH track has the title "SDH". Apart from this title, the SDH and the regular tracks are identical, i.e. no "default" flag or no "forced" flag et cetera.

Here's the output from MediaInfo:
Text #1
ID : 3
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text
Duration : 38 min 52 s
Bit rate : 38 b/s
Count of elements : 396
Stream size : 11.0 KiB (0%)
Title : SDH
Language : English
Default : No
Forced : No

Text #2
ID : 4
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text
Duration : 38 min 52 s
Bit rate : 27 b/s
Count of elements : 241
Stream size : 7.96 KiB (0%)
Language : English
Default : No
Forced : No

nevcairiel
30th April 2020, 22:51
The ! operator unfortunately only works for the flags, not the title match, I suppose I could think about a way to indicate a "not found" title match.

galneon
4th May 2020, 07:49
I've been enjoying LAV long since its integration into MPC-HC. Thank you, nevcairiel, for all your efforts!

I have some speakers that need Equalizer APO for its parametric EQ. My ELAC UF5s are great speakers with a bit of correction (thanks to noaudiophile for the config!), but they sound like barking dogs at reference volume without some tweaks, and my ancient Pio AVR's EQ sounds anything but transparent when I try use it instead.

A few worthless special AVR options aside (none of which I use), do I give up anything by letting LAV do the decoding for everything but DTS-MA? I'm trying to determine if there are certain formats I should bitstream for the sake of spatial effects/accurate reproduction, or if it really makes no difference if I have LAV send (equalized) PCM to my AVR.

nevcairiel
4th May 2020, 09:20
LAV can decode all default audio entire losslessly and accurately - including DTS-HD MA. The only things that cannot be decoded are Dolby Atmos or DTS:X (ie. object based "3D" audio), but you would need a new-ish AVR to make use of them, and probably some additional speakers as well.
If you are having issues with the lack of EQ causing quality issues, its likely always better to ensure that you can perform that EQ rather then using bitstreaming.

pankov
5th May 2020, 00:45
Hi Nev,

I tried to search for this information but couldn't find any firm answer so I'll be glad if you know it from the top of your mind and can easily answer.
Does LAV's decoding of Dolby's formats respect the Dialog normalization levels that are encoded in the Dolby Digital stream? Sadly I'm not at home right now to test it myself but I remember a long time ago it didn't and that was the reason had to switch to bitstreaming these codecs to my AVR since many TV shows that I was watching at that time were actually using it to boost the speech (center channel) level.

clsid
5th May 2020, 01:31
The FFmpeg decoder does have a dialog normalization option (http://git.videolan.org/?p=ffmpeg.git;a=commit;h=12df9b9a151026c4b382df8852fad38165b49f95), but it isn't exposed in LAV settings.

nevcairiel
5th May 2020, 07:55
First to clear up some terminology - DIALNORM does not boost speech directly as such, instead it normalizes the volume overall to a specified reference level, so that the average level, on which speech usually exists, is similar across different content. Its a flat gain over all audio, and as such mostly quality-neutral. In contrast to DRC (dynamic range compression), that actually reduces the signals dynamics and can reduce the quality.

On the surface, DIALNORM may seem useful, and if it were consistently and reliably usable, it might be. But unfortunately, the world we live in is not consistent. Dialnorm is only supported in AC3, at least in FFmpeg. And you are at the content providers mercy how they set that metadata. Playing any other codec would still have you worry about volume, and of course even an AC3 stream may have bad or missing DIALNORM metadata (different content providers may use different reference level).

Instead of codec-specific and built-in metadata like this, what I use for a normalized volume is EBU R128. Analyze the audio in a file to determine its average volume level, and adjust the file to a reference volume level, so you don't keep reaching for the remote to change the volume level. Its similar to ReplayGain which has been used for audio for almost two decades, just more advanced, standardized, and specified for multi-channel audio.

chros
5th May 2020, 10:26
I understand your point but wouldn't be better to leave the option to the user what to choose if it's already implemented?

nevcairiel
5th May 2020, 13:55
If it were "already implemented", then I wouldn't have to do anything about it, eh? :)
There is no such thing as a free lunch.

Exposing codec-specific options is a slippery-slope to option bloat, confused users - and thus more questions that want answers. Thats not to say its entirely ruled out, but alas I would likely need more convincing.

clsid
5th May 2020, 16:43
What is needed most is a so-called "night mode" where the volume of voices in center channel is increased and/or the volume of explosions and other loud stuff in the surround channels is decreased. How exactly that is done doesn't matter. Enjoying a movie without annoying the neighbors with noise.

nevcairiel
5th May 2020, 17:55
Thats typically Dynamic Range Compression, and the DRC slider is all the extend i'll ever add something like that to LAV Audio. Its not an audio processor, and not trying to be either. A seperate processing filter would be much more suitable for that.

pankov
5th May 2020, 18:39
nev, clsid,
I trust and admire the knowledge that both of you have but as a "simple" user this time I must disagree.
In my past experience some TV shows (don't remember which) ware utterly unwatchable if decoded by LAV instead of by my AVR just because the dialog level was very low. I usually use my AVR at almost the same level (day and night) and having such a discrepancy in the decoded level between different shows and other content was very inconvenient. Also having in mind that most if not all AVRs directly "obey" the Dialog Norm level encoded in the AC3 stream without even giving the users an option to avoid it I must say that this is the "normal" thing to do and this should also be the default behavior for software decoders.
And finally - this AC3 option/level was set by some real life sound engineers and who am I to argue with them if it was correct or not.

Of course LAV is your own "baby" and you can do whatever you want with it - I'm just sharing my experience and why decided to take the bitstreaming path.
:)

nevcairiel
5th May 2020, 18:57
AVRs also like to apply various degrees of Dynamic Range Compression by default, because it makes stuff sound louder and therefor "better" to a certain crowd, so an argument of "default elsewhere" is not necessarily worth much.
Its also fairly likely that its that what you are hearing. Dialog Normalization is basically a built-in volume knob, it does not affect speech alone, despite its name.

Incidentally, Dialog Normalization in AC3 will only *reduce* the volume of playback. Its not designed to increase it, because increasing can cause clipping. The default value when Dialnorm is not set is -31dBFS, which is the value at which no volume adjustment is being performed. Any value higher then that indicates that the dialog in a program is louder then that default, and to compensate for that, the decoder would reduce the volume to reach that same level again. So a DIALNORM value of -27dB (which is the most common) would mean the volume of the entire track gets reduced by 4dB to get back to the -31dB reference.

Of course you can compensate for this by simply increasing the overall volume of playback, but it my exacerbate issues with uneven volume between different formats.

Here is a good article that explains Dialog Normalization in AC3:
https://hometheaterhifi.com/volume_7_2/feature-article-dialog-normalization-6-2000.html

The jist of it is that most content will be reduced in volume when its being handled. Its primary purpose is to unify dialog volume across different programs, not to boost dialog. To avoid you having to reach for your volume control.
Boosting speech alone is more likely a function of DRC (which boosts quiter parts and reduces louder parts)

tehax1
9th May 2020, 18:18
Hello,
i am new to this forum so sorry if i ask already known things. So, i want to know how i get a second pgs subtitle selected by rule. Maybe by rule: if there are two German pgs subtitle then select the second one, for only foreign spoken language. Forced subtitle do not work and if i select a language i only get the first pgs active which shows complete German subtitle. Enclosed screenshot shows second subtitle selected.
https://i.imgur.com/xbsOJSv.png

sneaker_ger
9th May 2020, 18:48
There is no rule to make this possible with LAV Splitter.

nevcairiel
9th May 2020, 18:50
Positional rules are also a weird concept to me. There is no guarantee that any file or another file agree about any sort of positional importance. All other rules rely on metadata, flags, language, or even the title - all things you can deliberately control and have a deliberate meaning. The position is just.. potentially arbitrary?

tehax1
9th May 2020, 19:21
Understand. It was just an idea because i noted that if there are two German pgs subtitle tracks it is usually the second. Hm, maybe by pgs file size? Am i the first who have this issue with this and how make PowerDVD such things to work? Nevertheless thanks for help.

clsid
9th May 2020, 21:45
It is likely that in practice the order is always similar, defined by the behavior of the ripping tool.

You could for example allow a "2" in the rule definition. Rule is first matched same way as it is now. So initially matching the first of those two subs. Then because of "2" hint, it will check if subsequent sub has exact same metadata, and if so, selects that one instead.

More than 2 identical cases are not common, so any other numbers don't need to be supported.

You might not be interested in supporting this atypical case. But I have seen it before in the wild a couple of times.

tehax1
9th May 2020, 22:45
I think now that it is impossible to auto select the correct subtitle stream. Today i wached Midway UHD and it has three German pgs streams all with the same name. In that case stream no.3 was the right one.
Is there a way that e.g. MPC BE shows only German subtitles? Tried several things but always all tracks were shown.

sneaker_ger
10th May 2020, 10:51
It is likely that in practice the order is always similar, defined by the behavior of the ripping tool.
How would the ripping tool know what LAV doesn't? Different DVDs/Blu-Rays are authored differently - that's just the way it is. If the user wants consistent playback behavior for all his rips he needs to manually adjust (re-order tracks, name and tag them) every rip he does.

sneaker_ger
10th May 2020, 10:53
Am i the first who have this issue with this and how make PowerDVD such things to work?
PowerDVD works with the original DVD/Blu-Ray that still has the menus and their programming. Basically it's software written be the DVD authoring houses that takes care of the correct stream selection and filtering of non-forced lines. When you rip to mkv, mp4 or just stand-alone m2ts you lose that software. A different problem is that the concept of forced lines does not map into Matroska which has the concept of forced tracks.

nevcairiel
10th May 2020, 11:24
A different problem is that the concept of forced lines does not map into Matroska which has the concept of forced tracks.

That information is not lost. Which is what drives the automatic forced subtitle stream in LAV. You just need to know which stream to look in - which is the information that may be lost.

Although a much better experience is when you just split out the forced lines during ripping, which eg. MakeMKV will happily do for you. Just remember to also flag the stream as forced.

aufkrawall
10th May 2020, 12:03
May I ask if you wanted to make VP9 work with AMD's driver and their faulty D3D11VA/DXVA2 checking capabilities, would you do this in LAV Filters or ffmpeg upstream?
I don't have access to such an AMD GPU anymore, but I suppose this is still not fixed and thus they more or less expect developers to implement dirty workarounds for anything that isn't MF/browsers. :(

huhn
10th May 2020, 13:32
just for the record this is still the case even on the newest driver.

edit: and decoding is still encode.

tehax1
10th May 2020, 13:39
If i rip a movie i do it only complete and into iso format without any converting or something else and i do not want to do it. And even my Blu-Rays and UHD Blu-Rays have often two or three subtitle tracks with same name. As i understand there is no way to auto select the wished subtitle type and i have to do it always manual, ok.
Does anybody know how to fade out all subtitles beside German with LAV and MPC-BE?

tiresias
11th May 2020, 20:02
I have a question about the difference in behaviour of the LAV Splitter when a MOV/MP4 file contains AVC or HEVC video.

When LAV Splitter opens a MOV/MP4 file that has AVC video, the output pin's media type has dwSequenceHeader set to the SPS and PPS (both prefixed by a 2-byte length value). This agrees with Microsoft's description in

https://docs.microsoft.com/en-us/windows/win32/directshow/h-264-video-types

So for HEVC I was expecting the dwSequenceHeader to contain the VPS, SPS and PPS structures. But instead LAV Splitter copies the entire HEVCDecoderConfigurationRecord to dwSequenceHeader.

Is there a specification that says that for HEVC the dwSequenceHeader should contain the whole HEVCDecoderConfigurationRecord ?

If not, what is the reason for this?

Would the LAV Decoder be happy if it was provided with an input media type that contained only the VPS, SPS and PPS structures instead of the whole HEVCDecoderConfigurationRecord ?

nevcairiel
13th May 2020, 10:13
The reason it is done like this is simply that its not documented to be done anyway else, and this is what is contained in relevant containers (MP4, MKV), so its a sensible choice to just pass it on - and it contains all relevant information.

There is only two things LAV accepts:
- MEDIASUBTYPE_HEVC, with the bitstream in MP4 format and with a proper hvcC configuration record
- MEDIASUBTYPE_H265, with the bitstream in AnnexB format and the extradata containing any number of AnnexB NALUs of relevance

This matches the way H264 is setup broadly (AVC1 vs H264), except without the custom formatted extradata not found anywhere else in that form. For H264 I would break down the MP4-style extradata in the splitter and then re-assemble it in the decoder. That just seems utterly unnecessary if you get to define your own format since MS forgot about DirectShow anyway.

tiresias
14th May 2020, 12:37
Thanks, that makes good sense.

The only other place I've seen HEVC dwSequenceHeader implemented is in the MPC-BE source code which just seems to copy the VPS/SPS/PPS arrays into dwSequenceHeader

https://github.com/jeeb/mpc-be/blob/master/src/DSUtil/VideoParser.cpp

but it doesn't really matter either way.

KoD
29th May 2020, 17:29
Hi nevcariel, I have a question. I remember it was said that there is some support for passing HDR metadata to the video renderer. Do you have any tips on where can the video renderer read it from? A hint on where to look for in the lav source files for how this data is packed would help too.

amichaelt
29th May 2020, 17:53
Hi nevcariel, I have a question. I remember it was said that there is some support for passing HDR metadata to the video renderer. Do you have any tips on where can the video renderer read it from? A hint on where to look for in the lav source files for how this data is packed would help too.

Maybe this helps as a start?

https://github.com/Nevcairiel/LAVFilters/blob/df2c8905b73ad9c0cda865369d945b2f1044dcbf/developer_info/IMediaSideData.h

nevcairiel
29th May 2020, 22:21
This is correct, the IMediaSample the renderer receives implement IMediaSideData, which contains those structures. Note that if the renderer provides the allocator (it typically does for software frames), it also needs to implement this interface if it wants this data.