clsid2 / mpc-hc

Media Player Classic
GNU General Public License v3.0
11.34k stars 497 forks source link

[issue] MPC-HC sound problem with dtv and tv station names #372

Closed moonlightz closed 4 years ago

moonlightz commented 4 years ago

Hi, i'm "not so new" here and I would like to report at least 2 annoying problems that started to happen at least 2 years ago, at least the sound problem. When I start mpc-hc (after a fresh k-lite install) and i go to File -> Open Device... , it gives me an error, then i need to go to View -> Options -> Capture and change Network Provider from Microsoft Network Provider to DVB-T, apply and back to Microsoft Network Provider, then Open Device... will work fine, MPC-HC switches to Live and i can click Scan button to open Tuner Scan, i can click Start and the stations are tuned fast, i can see 2 problems: Quality and Signal bars are like 2/5 filled and the names of the stations that have accents are not displayed correctly, it seems like it cant process utf-8 in the station's names. Then i can click Save. The next problem is just that MPC-HC can't seem to determine the audio stream codec, therefore no sound whenever the tv channel i use. Here's properties page info...: Video: MPEG4 Video (H264) 1024x576 25fps [h264] Unknown [001] Unknown [002] Subtitle: DVB Subtitles [sub] Unknown [Antenna Out]

I tried to fiddle with many options as possible even only selecting the other encoding than LAV but no joy. I would like to help testing or sorting out this problem. mpc1

adipose commented 4 years ago

I recently fixed some issues with DTV, and it was a real pain, since DTV doesn't work in the US. I got my ATSC tuner working enough to debug the issue.

But if you are a dev, maybe you can take up the issue of DTV. We could use someone who has a DTV card testing these things.

clsid2 commented 4 years ago

I had a look at the very first issue, but I think just viewing the "Options > Capture" page once should be enough to automatically select the Microsoft Network Provider and tuners.

moonlightz commented 4 years ago

I do program a little but not in visual c++. The tv station names should be easy enough to fix. The names seem to be in utf-8. MPC-HC is probably using iso8859-something to display names. Regarding to Options > Capture, i have it set to Microsoft Network Provider and tuner is AverMedia Volar Green HD usb which uses AF9015 from Afatech. I will attach more screenshots in a few hours. I can remove K-lite Mega and then install some old versions and track which version works and then the problem started to appear. My understanding is that somewhat the DTV software programming got changed and doesn't enable the right pins to connect to the internal codecs.

moonlightz commented 4 years ago

mpc-hc-options

The page is ok and the tuner seems to only react to Microsoft Network Provider. Other than one, MPC-HC gives error:

mpc-hc-error-dvbt

Play menu -> Filters section has: Filters currently loaded:

Using NextPVR, I can select LAV Video for H264 and LAV Audio for ACC/HE-ACC, both icons show in system tray, LAV Video doesn't say the input but LAV Audio says aac -> pcm.

With VLC, the capture stuff needs more fiddling... but it works too... here's a screenshot of the codec information: vlc-codec

clsid2 commented 4 years ago

The MPEG-2 Demultiplexer is used for parsing the MPEG Transport Stream. That is the container format. Click on it in the filter list and look at the Pin Info tab.

adipose commented 4 years ago

To my knowledge, everything but Microsoft Network Provider is deprecated, and the rest could be removed.

clsid2 commented 4 years ago

Removing the provider option and always use Microsoft Network Provider would be fine with me.

moonlightz commented 4 years ago

https://pastebin.com/raw/4LzbTCkV I wish there was a button we could click and MPC-HC could copy all the pins and info to clipboard.

moonlightz commented 4 years ago

Like I mentioned above, if I fresh install k-lite, Microsoft Network Provider is the default provider and if I click File -> Open device, MPC-HC says it can't create filter renderer or something like that, then I need to go to View > Options > Capture , select DVB-T, click OK, Open Capture gives error, then I need to switch back to Microsoft Network Provider, Open Device will then work switching to Live.

moonlightz commented 4 years ago

I uninstalled k-lite mega and then google'd and installed mpc-hc 1.7.13 x64 and same issues are happening... the tv station names and lack of sound. But I know MPC-HC worked before with my Avermedia tuner.

moonlightz commented 4 years ago

It's not Windows 10's fault. I installed Windows 7 onto another machine and same problem happens. Will now download some older MPC-HC versions and see which one works.

adipose commented 4 years ago

Like I mentioned above, if I fresh install k-lite, Microsoft Network Provider is the default provider and if I click File -> Open device, MPC-HC says it can't create filter renderer or something like that, then I need to go to View > Options > Capture , select DVB-T, click OK, Open Capture gives error, then I need to switch back to Microsoft Network Provider, Open Device will then work switching to Live.

It does something when it switches the provider, that may not be automatically set on install with k-lite. If we make it only use one, and set that setting, probably this issue would go away.

adipose commented 4 years ago

https://github.com/clsid2/mpc-hc/pull/377

Try this build to see if the network provider issue is gone.

https://mega.nz/file/0YwVEABI#f4fA88ki8FK5t3BNnOJFh663lMQTQnhxG2CjWGnQ-NE

moonlightz commented 4 years ago

Yes, I extracted the file and ran the exe, then gone to File > Open Device and worked right away. The tv stations are still listed, I believe it some bits of old install are still remaining. The Network Provider is greyed out.

moonlightz commented 4 years ago

But... just tested with a laptop running windows 10 that never had mpc-hc or k-lite, i extracted the 7zip file and ran mpc-hc then went to File > Open Device and it gives error and it shows an error in the status bar saying Can't create video capture filter.

moonlightz commented 4 years ago

Hmm Bummer... Then I gone to MPC-HC's capture page... it was selected analog for the webcam and switched to Digital and clicked ok, gone back to Open Device and it gives error saying directx runtime is outdated.

clsid2 commented 4 years ago

Here is DirectX runtime: https://www.microsoft.com/en-us/download/details.aspx?id=35

moonlightz commented 4 years ago

After DirectX thingy, the Open Device opens fine, status bar says Playing, perhaps it should say Ready or something like that.

moonlightz commented 4 years ago

Yet to solve the audio issue. With previous versions of k-lite and mpc-hc, I was unable to get the audio working. With "only when switching different video types", I can see LAV Audio showing 3 icons and seeing it's properties page/status, it says aac_latin 48000 16bit but there is nothing outputting. I guess we can tackle this problem later. Can you sort the dtv stations names?

adipose commented 4 years ago

@moonlightz , I've been busy and unable to look at this one. There are a few other bugs I'm working on in my spare time, so I haven't really looked at this one, yet. I'm sure we could get some things working.

moonlightz commented 4 years ago

Sure. I didn't meant to rush things. I'm still fiddling to see if MPC-HC can output audio.

clsid2 commented 4 years ago

You could try disabling AAC in the settings of LAV Audio Decoder. Then it should use Microsoft DTV-DVD Audio Decoder instead. Maybe that works.

Also try if saving the stream to a file works. Then maybe we can reproduce with the recorded file. Menu > File > Save a copy

adipose commented 4 years ago

@moonlightz , what language are the non-working station names in? There is code to convert them, but maybe the codepage is missing.

adipose commented 4 years ago

It seems it can display them fine. I hard coded some data in Belarusian in the registry.

image

Probably it converted it wrong and stored it that way while scanning.

moonlightz commented 4 years ago

I reinstalled k-lite 15.4.4, leaving AAC unticked for LAV audio, still no joy.. no audio. The internal LAV filters of MPC-HC are unticked by default, I also added Microsoft DTV-DVD audio and video decoders in External Filters. Filters currently loaded:

Searching registry for a name of a channel listed, it seems MPC-HC stores things in \HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\DVBConfiguration and I can see that channel names have problems where the chars with accents are. I live in Portugal and we use iso8859-1 (obsolete i say) but more likely the channel names are using utf-8. mpc-hc dvb config.reg.txt

adipose commented 4 years ago

https://mega.nz/file/4M4z1QbZ#zlFPElHkPPhRzh8ad7RJJa7dKqUG4eeQs3fh3vQWw4k

Please download, and run this test buidl, and scan for stations. Then report back. Some info:

  1. DTV does not appear to support UTF-8 encoding. Instead there are several codepages (appear to be 48, some of which are not in use).
  2. MPC-HC currently has a default codepage (in case the codepage is not specified) of ISO/IEC 6937. This appears to be per the spec, or something. But a long time ago ~2012, the default was 8859-1. What's interesting is that mpc-be source revs start in 2015, but the imported code was still defaulting to 8859-1. Either it was from an older source, or version control didn't start until later.
  3. There are numerous threads on the internet regarding other DTV software and its failure to correctly choose the right encoding. In some cases, multiple DTV in the same country used different encodings. In some cases, the encoding was different for different stations from the same provider. It seems to be a mess, and the only way it would be right was if you had a receiver designed specifically for the region.

I suspect the change made in mpc-hc solved encoding for some areas but broke it for others. To solve this, it might be necessary to have a per-station override option. Or maybe a global override would be enough for most cases.

In the temp folder, it will log the station data into files like mpegDataBuffer001.bin. Please zip these up and attach them here, so I can see what raw data you are pulling in.

clsid2 commented 4 years ago

Regarding the audio issue, all the filters involved are from Microsoft, so that bug might be their fault.

Does NextPVR also use MPEG-2 Demultiplexer filter?

moonlightz commented 4 years ago

Sorry but I can't find mpeg.bin files. Do I have to go somewhere in mpc-hc to generate the file? C:>dir mpegDat /s /a Volume in drive C is w10x64 Volume Serial Number is 162E-C344 File Not Found

npvr well , it seems to use a separated decoder for mpeg-2 and another for h.264, and there are decoders for audio. In the picture, i have LAV for HE-AAC but it's not really needed.

clsid2 commented 4 years ago

I meant the splitter/demuxer filter, which parses the data and feeds it to the decoders. But I already found the answer after searching. I looked at the changelog of NextPVR and since version 4.0.4 it uses its own demuxer filter. There is an option called "use legacy TS reader and Microsoft demux" to make it use the demuxer from Microsoft.

Could you try with that option enabled to see if NextPVR then exhibits the same audio problem?

moonlightz commented 4 years ago

Yep.. I can confirm, ticking that box... no audio coming out from nextpvr, it even complains that there are missing decoders for aac.

moonlightz commented 4 years ago

it tells me to check the decoders page, lav audio still selected for aac but no audio if i select microsoft dtv instead of lav audio.

adipose commented 4 years ago

Sorry but I can't find mpeg.bin files. Do I have to go somewhere in mpc-hc to generate the file? C:>dir mpegDat /s /a Volume in drive C is w10x64 Volume Serial Number is 162E-C344 File Not Found

It should have put them in %temp% folder. I think it would show up there when saving the stations after a scan. Did you do a scan?

I forgot to mention I changed the default to 8859-1 in this test build.

moonlightz commented 4 years ago

Yes, a ran a scan twice and everything looked the same to me and then i ran the dir from %temp% and got nothing and then i did a search from c:\ for a wide search. The /s is for subdirectories and /a for hidden folders. mpc-hc scanning 01 mpc-hc scanning 02

This morning, I reran again (the screenshots are taken) and still no signs for those mpegdata* files. Need to check with the other laptop with no k-lite/mpc.

clsid2 commented 4 years ago

Yep.. I can confirm, ticking that box... no audio coming out from nextpvr, it even complains that there are missing decoders for aac.

That confirms the issue is in the Microsoft demuxer. I am afraid that we might not be able to fix that. Perhaps the developers of NextPVR know more about what exactly is wrong.

moonlightz commented 4 years ago

I ran mpc-hc on the test laptop that had no k-lite/mpc-hc and i can still not find those mpegdata* files. Maybe do I need to enable something in mpc-hc?

adipose commented 4 years ago

Maybe a flaw in my trace code. I assume you are using the special build, right?

moonlightz commented 4 years ago

Yes. the last one you sent me.

moonlightz commented 4 years ago

Installed Windows 7 dualboot with win10, same no audio, even unticking aac. Installed Windows 7 Ultimate which comes with Windows Media Center, and setup the tv channels list, it found 124 channels... it took ages.... and it has audio. Now what WMC has that MPC doesn't? I don't seem to find something in External filters list that i can use related to WMC.

clsid2 commented 4 years ago

@adipose Regarding the logging, there already is some code for that in the player. See subtitle providers code for example usage. It can be activated through Options>Advanced>EnableLogging and puts file in %appdata%.

adipose commented 4 years ago

https://mega.nz/file/sdY3XSrD#-mAcBR7C0fU9cl_Ks4jlLyuKkxzVP5V42Izf6OxPDrA

Another test build. Also turn on logging per clsid2's post above.

I added some logging code that will go into %appdata%\mpc-hc\bda.log. Please attach that one after doing a scan and saving.

I cannot understand why the binary logging isn't creating the files in the temp folder, but maybe this logging will give me an idea.

@clsid2 , these logs try to capture the binary data before it's decoded so I can hopefully run the algorithm on the raw channel data. It's a bit different than the text logging.

moonlightz commented 4 years ago

subtitles.log bda.log

adipose commented 4 years ago

Great, thank you. Here's another test build which should get the binary logs I want, I think.

https://mega.nz/file/1ABHVAZJ#wkdkDt88xCWzbJYWwc506jDKShquYfRCiCB3d4xEN4g

Here's something interesting in the log:

image

This was one that didn't encode properly, yet in the log it is fine. The log is detected as UTF-8. I wonder if there's a bug from UTF-8 to UTF-16 when it saves to the registry.

moonlightz commented 4 years ago

Here you go. bda.log

Also, a bit odd that Signal strength and quality only goes that size. I am using a router that provides coax rf tv output and my tvs say it is at full strength and quality. mpc-hc dvb scan

moonlightz commented 4 years ago

And yes, now I can see the bin files. mpegdatabin.zip

adipose commented 4 years ago

https://mega.nz/file/4JJFXIZD#VZapi_Vh6dN8MW8a8QiQuxJtoOS_jUazaK1jpxAcUiY

OK, try this build. It's not attempting to log anything, just fix the bug.

moonlightz commented 4 years ago

mpc-hc channels ok Fixed. Both channels list and scan dialog show the station names correctly. As far as I can see, they are all correct.

adipose commented 4 years ago

https://github.com/clsid2/mpc-hc/pull/399

It turns out you were right, it was UTF-8. But it wasn't enough to simply force it to use UTF-8, but correctly identify the codepage that was called out (or else other channels may not work for other users).

It's identified as 0x15, which is supposed to reference UTF-8 encoding of ISO/IEC 10646 - Basic Multilingual Plane (BMP). I've changed it to use the Microsoft codepage for UTF-8 when it sees that setting, now. It's unclear why the original developer coded that to use ISO 8859-1, but it was accompanied with ???, so it was probably just a placeholdder.

adipose commented 4 years ago

With reference to the signal, my ATSC OTA tuner gets much higher signal reports than you are getting. Perhaps it simply has a "lower" signal because it's a reliable one, as opposed to a wireless, flaky one. As long as the signal is steady, low is ok.

I'm not sure how it calculates the strength but maybe for QAM a different algorithm is needed.

moonlightz commented 4 years ago

I program as a hobbie (in TCL) and when I saw "2-byte" chars along with single chars, I imediately recall of UTF-8. Use of ISO8859-1 is just obsolete and UTF-8 is the future because it's almost everywhere. I remember reading somewhere some mpc/-hc user complaining about the bars in the past. One thing I can probably do is to allow remote access for you with Teamviewer or some other tool, to see "we" can sort out the audio issue and maybe the signal bars as well. I would need to setup a clean windows 10 installation with drivers/directx first.

adipose commented 4 years ago

Yes, I agree with UTF-8 being the preferred encoding. Although, Windows uses UTF-16, so it's not always obvious what is to be done. In any case, there are 48 possible encodings supported and UTF-8 is only one of them, so the code has to follow the encoding specified in the raw data. Luckily the encoding specified was actually a UTF-8 encoding, but I needed to see if it was an unspecified default or some other undocumented behavior. The TV providers have notoriously not used proper encodings or mixed encodings in the past, so it's good to see them using UTF-8 as it should support pretty much anything.