damienhaynes / moving-pictures

Moving Pictures is a movies plug-in for the MediaPortal media center application. The goal of the plug-in is to create a very focused and refined experience that requires minimal user interaction. The plug-in emphasizes usability and ease of use in managing a movie collection consisting of ripped DVDs, and movies reencoded in common video formats supported by MediaPortal.
12 stars 6 forks source link

Fixed MP1.23 issues with mediainfo #1162

Closed doskabouter closed 4 years ago

andrewjswan commented 4 years ago

For Codec logos best use: this.VideoCodec = mInfoWrapper.BestVideoStream.Codec.ToCodecString() ?? String.Empty; and this.AudioCodec = mInfoWrapper.BestAudioStream.Codec.ToCodecString() ?? String.Empty; Look: https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/Util/CodecExtenstions.cs And for Log use code like (log in MP.log): var milog = GlobalServiceProvider.Get<MediaInfo.ILogger>(); return new MediaInfoWrapper(mainFeatureFile, milog); Or other (custom) MediaInfo.ILogger object ...

doskabouter commented 4 years ago

Are the public video and audio related properties handled the same with this change? e.g.

    public string VideoCodec
    {
        get
        {
            string tempCodec = String.Empty;
            if (_isDIVX)
                tempCodec = "DIVX";
            else if (_isXVID)
                tempCodec = "XVID";
            else if (_isH264)
                tempCodec = "H264";
            else if (_isHEVC)
                tempCodec = "HEVC";
            else if (_isMP1V)
                tempCodec = "MP1V";
            else if (_isMP2V)
                tempCodec = "MP2V";
            else if (_isWMV)
                tempCodec = "WMV";
            else
                tempCodec = _videoCodec;

            return tempCodec;
        }
    }

It's important that the same strings are returned such that skin logos are still shown.

To be honest, I don't know if the same strings are passed back to MP. Have to dive into the mediainfo.wrapper code to find out about that

andrewjswan commented 4 years ago

In https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/Util/CodecExtenstions.cs for Video:

private static readonly Dictionary<MediaInfo.Model.VideoCodec, string> _videoCodecs = new Dictionary<MediaInfo.Model.VideoCodec, string>()
    {
      { MediaInfo.Model.VideoCodec.Undefined, string.Empty },
      { MediaInfo.Model.VideoCodec.Uncompressed, "RAW" },
      { MediaInfo.Model.VideoCodec.Dirac, "DIRAC" },
      { MediaInfo.Model.VideoCodec.Mpeg4, "MPEG4" },
      { MediaInfo.Model.VideoCodec.Mpeg4Is0Sp, "MPEG4" },
      { MediaInfo.Model.VideoCodec.Mpeg4Is0Asp, "MPEG4VIDEO" },
      { MediaInfo.Model.VideoCodec.Mpeg4Is0Ap, "MPEG4VIDEO" },
      { MediaInfo.Model.VideoCodec.Mpeg4Is0Avc, "AVC" },
      { MediaInfo.Model.VideoCodec.Mpeg4IsoSp, "MPEG4" },
      { MediaInfo.Model.VideoCodec.Mpeg4IsoAsp, "MPEG4VIDEO" },
      { MediaInfo.Model.VideoCodec.Mpeg4IsoAp, "MPEG4VIDEO" },
      { MediaInfo.Model.VideoCodec.Mpeg4IsoAvc, "AVC" },
      { MediaInfo.Model.VideoCodec.MpeghIsoHevc, "HEVC" },
      { MediaInfo.Model.VideoCodec.Mpeg4MsV1, "MSMPEG4V1" },
      { MediaInfo.Model.VideoCodec.Mpeg4MsV2, "MSMPEG4V2" },
      { MediaInfo.Model.VideoCodec.Mpeg4MsV3, "MSMPEG4V3" },
      { MediaInfo.Model.VideoCodec.Vc1, "VC-1" },
      { MediaInfo.Model.VideoCodec.Mpeg1, "MPEG1VIDEO" },
      { MediaInfo.Model.VideoCodec.Mpeg2, "MPEG2VIDEO" },
      { MediaInfo.Model.VideoCodec.ProRes, "PRORES" },
      { MediaInfo.Model.VideoCodec.RealRv10, "REAL" },
      { MediaInfo.Model.VideoCodec.RealRv20, "REAL" },
      { MediaInfo.Model.VideoCodec.RealRv30, "RV30" },
      { MediaInfo.Model.VideoCodec.RealRv40, "RV40" },
      { MediaInfo.Model.VideoCodec.Theora, "THEORA" },
      { MediaInfo.Model.VideoCodec.Vp6, "VP6F" },
      { MediaInfo.Model.VideoCodec.Vp8, "VP8" },
      { MediaInfo.Model.VideoCodec.Vp9, "VP9" },
      { MediaInfo.Model.VideoCodec.Divx1, "DIVX" },
      { MediaInfo.Model.VideoCodec.Divx2, "DIV2" },
      { MediaInfo.Model.VideoCodec.Divx3, "DIV3" },
      { MediaInfo.Model.VideoCodec.Divx4, "DIVX 4" },
      { MediaInfo.Model.VideoCodec.Divx50, "DX50" },
      { MediaInfo.Model.VideoCodec.Xvid, "XVID" },
      { MediaInfo.Model.VideoCodec.Svq1, "SVQ1" },
      { MediaInfo.Model.VideoCodec.Svq2, "SVQ2" },
      { MediaInfo.Model.VideoCodec.Svq3, "SVQ3" },
      { MediaInfo.Model.VideoCodec.Sprk, "FLASH" },
      { MediaInfo.Model.VideoCodec.H260, "H260" },
      { MediaInfo.Model.VideoCodec.H261, "H261" },
      { MediaInfo.Model.VideoCodec.H263, "H263" },
      { MediaInfo.Model.VideoCodec.Avdv, "AVDV" },
      { MediaInfo.Model.VideoCodec.Avd1, "AVD1" },
      { MediaInfo.Model.VideoCodec.Ffv1, "FFV1" },
      { MediaInfo.Model.VideoCodec.Ffv2, "FFV2" },
      { MediaInfo.Model.VideoCodec.Iv21, "IV21" },
      { MediaInfo.Model.VideoCodec.Iv30, "IV30" },
      { MediaInfo.Model.VideoCodec.Iv40, "IV40" },
      { MediaInfo.Model.VideoCodec.Iv50, "IV50" },
      { MediaInfo.Model.VideoCodec.Ffds, "MPEG4" },
      { MediaInfo.Model.VideoCodec.Fraps, "MPEG4" },
      { MediaInfo.Model.VideoCodec.Ffvh, "MPEG4" },
      { MediaInfo.Model.VideoCodec.Mjpg, "MJPG" },
      { MediaInfo.Model.VideoCodec.Dv, "DV" },
      { MediaInfo.Model.VideoCodec.Hdv, "HDV" },
      { MediaInfo.Model.VideoCodec.DvcPro50, "DVCPRO50" },
      { MediaInfo.Model.VideoCodec.DvcProHd, "DVCPROHD" },
      { MediaInfo.Model.VideoCodec.Wmv1, "WMV" },
      { MediaInfo.Model.VideoCodec.Wmv2, "WMV2" },
      { MediaInfo.Model.VideoCodec.Wmv3, "WMV3" },
      { MediaInfo.Model.VideoCodec.Q8Bps, "Q8BPS" },
      { MediaInfo.Model.VideoCodec.BinkVideo, "BINKVIDEO" },
      { MediaInfo.Model.VideoCodec.Av1, "AV1" },
      { MediaInfo.Model.VideoCodec.HuffYUV, "HUFFYUV" },
    };
doskabouter commented 4 years ago

hm, didn't suspect that much had changed in the wrapper... I do have these in my collection: AVC High@L4 AVC High@L4.1 divx DIVX fmp4 H264 MP2V mp43 v_mpeg2 v_mpegh/iso/hevc v_vp8 WMV XVID

But quite some of the strange ones are from movies I already had for some time (at least before my upgrade to 1.23). Does it regularly rescan all movies?

damienhaynes commented 4 years ago

It never does an automatic re-scan, only manual once done a first time.

I will try check out the pull request and do a test on a clean db with latest MP on the weekend, my time is very limited at the moment due to some work pressures.

doskabouter commented 4 years ago

I can put in a couple of normalizers like: public static string NormalizeVideoCodec(string codec) { codec = codec.ToLowerInvariant(); if ((codec.IndexOf("dx50") > -1) | (codec.IndexOf("div3") > -1)) // DivX 5 and DivX 3) // mpeg4 DivX return "DIVX"; else if ((codec.IndexOf("xvid") > -1)) // mpeg4 asp return "XVID"; else if ((codec.IndexOf("avc") > -1 || codec.IndexOf("h264") > -1)) // mpeg4 avc h264/x264 return "H264"; else if ((codec.IndexOf("hevc") > -1)) // v_mpegh/iso/hevc return "HEVC"; else if ((codec.IndexOf("mpeg-1v") > -1)) // mpeg1 video (VCD) return "MP1V"; else if ((codec.IndexOf("mpeg-2v") > -1)) // mpeg2 video return "MP2V"; //else if ((codec.IndexOf("fmp4") > -1)) // add more // mpeg4 generic didn't occur in old MediaInfoWrapper.VideoCodec, so wasn't a special case else if (codec.IndexOf("wmv") > -1) // wmv3 = WMV9 // WMV 7-9 return "WMV"; else return codec; }

andrewjswan commented 4 years ago

@doskabouter best use this.VideoCodec = mInfoWrapper.BestVideoStream.Codec.ToCodecString() ?? String.Empty; This already return normal Codec name, look at my PullRequest and to https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/Util/CodecExtenstions.cs

andrewjswan commented 4 years ago

And look - https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Databases/Video/SqlLite/VideoDatabaseSqlLite.cs#L1166

andrewjswan commented 4 years ago

In my small test movie db, MovPics with my changes: https://github.com/damienhaynes/moving-pictures/pull/1161 select distinct videoresolution, videocodec, audiocodec from local_media return:

videoresolution videocodec  audiocodec
720p    H264    AC3
1080p   H264    DTS
1080p   H264    AC3
doskabouter commented 4 years ago

Hm, I can't find ToCodecString in mediainfowrapper 19.4.0.0

doskabouter commented 4 years ago

I see that in MediaInfoWrapper there are quite a lot more codecs defined than used to be in the old moving pictures wrapper. We should have a bit of a discussion on which list we are going to adhere to.

My guess would be the list that was in the old wrapper because skins are based on that. And to be absolutely sure that this is what you get from the moving pictures part and not break a lot of skins if something odd changes in the new MediaInfoWrapper we should create that list ourselves through a Helper or something.

what do you guys think of this?

doskabouter commented 4 years ago

To be fully compliant to the old values of mediainfowrapper, we need to have the AudioProfile as property too from yartat... (_mI.Get(StreamKind.Audio, i, "Format_Profile"))

andrewjswan commented 4 years ago

@doskabouter ToCodecString is Mediaportal part, MediaInfo Wrapper detect codec? Mrdiaportal return Name for codec using the methodToCodecString. I have already given links several times. And this is the most correct way. Wrapper gives a complete list of codecs, the ToCodecString method gives the correct names for the codecs, and we must use a single mechanism, as I described above. The media portal now works as I described. All plugins should work the same way, then there will be no need to produce a lot of files for codecs. MyVideo. mvCentral - work the same way and use:

this.VideoCodec = mInfoWrapper.BestVideoStream.Codec.ToCodecString() ?? String.Empty;
this.AudioCodec = mInfoWrapper.BestAudioStream.Codec.ToCodecString() ?? String.Empty;
doskabouter commented 4 years ago

sorry for being a bit slow, but if that ToCodecString is in mediaportal we can't use it in Moving Pictures, right?

andrewjswan commented 4 years ago

@doskabouter Why not? We can, and it works great. look: https://github.com/damienhaynes/moving-pictures/pull/1161/commits/90af4d5965c14daa679db9b24cae18ac99661813#diff-182f229537a859673f914e2dca948540R616

doskabouter commented 4 years ago

It works now that I added Mediaportal.Util to the usings. However, there are differences between the old moving pictures wrapper and mediaportal's wrapper. F.e. Old MovPic: div3 showed as divx, new Mepo: returns div3 Old MovPic: mpeg-1v showed as MP1V, new Mepo: MPEG1VIDEO Old MovPic: all wmv alikes showed as WMV, new Mepo: WMV, WMV2, WMV3

AudioCodec has similar issues Videoresolution also has its differences... 4K UHDTV instead of 4320p f.e.

Don't know if that is going to be a change needed for skinners?

andrewjswan commented 4 years ago

Simply rename/copy some pictures, not problem at all... Now, MyVideo, MovingPictures, mvCentral return the equals values for Video/Audio codec...

чт, 17 окт. 2019 г., 22:32 doskabouter notifications@github.com:

It works now that I added Mediaportal.Util to the usings. However, there are differences between the old moving pictures wrapper and mediaportal's wrapper. F.e. Old MovPic: div3 showed as divx, new Mepo: returns div3 Old MovPic: mpeg-1v showed as MP1V, new Mepo: MPEG1VIDEO Old MovPic: all wmv alikes showed as WMV, new Mepo: WMV, WMV2, WMV3

AudioCodec has similar issues Videoresolution also has its differences... 4K UHDTV instead of 4320p f.e.

Don't know if that is going to be a change needed for skinners?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/damienhaynes/moving-pictures/pull/1162?email_source=notifications&email_token=AA3RIPBNIFNHUR5M4JX2BZLQPC4VLA5CNFSM4JATFA7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBRIKCY#issuecomment-543327499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3RIPA7UAILWJKM66JXSEDQPC4VLANCNFSM4JATFA7A .

doskabouter commented 4 years ago

Ok, agreed. I'll finalize my pullrequest soon then

andrewjswan commented 4 years ago

Dont forget for MediaInfo Debug logging :)

damienhaynes commented 4 years ago

Just upgrading to 1.23 now, will do a clean import and see where we're at.

damienhaynes commented 4 years ago

I did a fresh scan with my movie collection and I see this:

image

Looks good, there is going to be some obvious changes here for ppl with naming e.g. AVC vs H264. In terms of skinners needing to update, it should probably only be down to them creating multiple filenames basis the same logo e.g. H264.png & AVC.png, AC3.png & AC-3.png etc. This kinda sux for ppl with big databases already with mediainfo as they are going to have a mix of details now.

The Trakt plugin also needs to be updated as that reads media for collection sync: https://github.com/trakt/Trakt-for-Mediaportal/blob/master/TraktPlugin/TraktHandlers/MovingPictures.cs#L1239

https://github.com/trakt/Trakt-for-Mediaportal/blob/master/TraktPlugin/TraktHandlers/MovingPictures.cs#L1203