UPnP / DLNA Media Server for MediaPortal 2 (1 Viewer)

mrj

Portal Pro
January 27, 2012
251
100
Country flag
Hi
You can replace many if/else statement testing enums with dictionaries to reduce the number of lines.
or directly "enum.tostring().tolower()"
mrj
//Edit
I just saw this.
If you apply this to the other arguments as well, the number of code lines will be significantly reduced.
morpheus_xx already mentioned it
 
Last edited:

morpheus_xx

Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,388
    6,966
    Germany Germany
    Country flag

    FreakyJ

    Development Group
  • Team MediaPortal
  • July 25, 2010
    4,023
    1,420
    Germany Germany
    Country flag
    @henso
    we just did both the same work :D But you were 3 mins faster :ROFLMAO:
    But I am still happy, so no worries^^

    At least thank you all for the suggestions!
     

    henso

    Development Group
  • Team MediaPortal
  • February 16, 2012
    2,170
    735
    Denmark Denmark
    Country flag
    But I think we agree that it would still be nice to have support for different encoders
    Agree.

    I limited the video bitrate in the default profile
    It would be better to limit the quality factor. I pushed some changes that will create smaller files.

    While ffmpeg is still transcoding you can't seek
    This is a problem with WMP AFAIK. It sends no range requests to the server. In other DLNA clients it works as expected.

    You start to transfer a file and than send another request and see if you get an answer
    I tried that. I added 5 threads that constantly download a 70 MB file in parallel while still doing the requests like before. After a few seconds the average response time is 500 ms and 100 requests/second, The file downloads average at 4-5 seconds per file. Anything more I can try? Maybe the problem is somewhere else?

    we just did both the same work
    Sorry about that. :( I thought you would look at it next week. ;)
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,388
    6,966
    Germany Germany
    Country flag
    @henso would you mind to make some more changes to classes?

    For codec settings lookup I suggest such kind of structure:
    C#:
        public class EncodingConfig
        {
          public Dictionary<EncodingProfile, string> Profiles { get; set; }
          public Dictionary<EncodingPreset, string> Presets { get; set; }
    
          public EncodingConfig()
          {
            Profiles = new Dictionary<EncodingProfile, string>();
            Presets = new Dictionary<EncodingPreset, string>();
          }
        }
    
        public class VideoEncodingConfig : Dictionary<VideoCodec, EncodingConfig> { }
    
        private readonly VideoEncodingConfig IntelCodecConfig = new VideoEncodingConfig
        {
          {
            VideoCodec.Mpeg2,
            new EncodingConfig
            {
              Profiles = new Dictionary<EncodingProfile, string>
              {
                { EncodingProfile.Simple, "-profile:v simple" },
                { EncodingProfile.Main, "-profile:v main" },
                { EncodingProfile.High, "-profile:v high" }
              },
              Presets = new Dictionary<EncodingPreset, string>
              {
                { EncodingPreset.Default, "-preset fast" },
                { EncodingPreset.Ultrafast, "-preset fast" },
                { EncodingPreset.Superfast, "-preset fast" },
                { EncodingPreset.Veryfast, "-preset fast" },
                { EncodingPreset.Faster, "-preset fast" },
                { EncodingPreset.Fast, "-preset fast" },
                { EncodingPreset.Medium, "-preset medium" },
                { EncodingPreset.Slow, "-preset slow" },
                { EncodingPreset.Slower, "-preset slow" },
                { EncodingPreset.Veryslow, "-preset slow" }
              }
            }
          },
          {
            VideoCodec.H264,
            new EncodingConfig
            {
              Profiles = new Dictionary<EncodingProfile, string>
              {
                { EncodingProfile.Baseline, "-profile:v baseline" },
                { EncodingProfile.Main, "-profile:v main" },
                { EncodingProfile.High, "-profile:v high" },
                { EncodingProfile.High422, "-profile:v high" },
                { EncodingProfile.High444, "-profile:v high" }
              },
             Presets = new Dictionary<EncodingPreset, string>
              {
                { EncodingPreset.Default, "-preset veryfast" },
                { EncodingPreset.Ultrafast, "-preset veryfast" },
                { EncodingPreset.Superfast, "-preset veryfast" },
                { EncodingPreset.Veryfast, "-preset veryfast" },
                { EncodingPreset.Faster, "-preset faster" },
                { EncodingPreset.Fast, "-preset fast" },
                { EncodingPreset.Medium, "-preset medium" },
                { EncodingPreset.Slow, "-preset slow" },
                { EncodingPreset.Slower, "-preset slower" },
                { EncodingPreset.Veryslow, "-preset veryslow" }
              }
            }
          }
        };
    // TODO: NVidia, SW
    The main difference to current situation is to have on single object for each encoder (SW, Intel, NVidia).

    This makes the later lookup even simpler, like:
    C#:
            VideoEncodingConfig selectedConfig;
            if (isIntel)
              selectedConfig = IntelCodecConfig;
            else if (isNvidia)
              selectedConfig = NVidiaCodecConfig;
            else
              selectedConfig = SWCodecConfig;
    
            EncodingConfig encodingConfig;
            if (selectedConfig.TryGetValue(video.TargetVideoCodec, out encodingConfig))
            {
              string profile;
              if (encodingConfig.Profiles.TryGetValue(video.TargetProfile, out profile) && !string.IsNullOrEmpty(profile))
                data.OutputArguments.Add(profile);
    
              string preset;
              if (encodingConfig.Presets.TryGetValue(video.TargetPreset, out preset) && !string.IsNullOrEmpty(preset))
                data.OutputArguments.Add(profile);
            }
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,388
    6,966
    Germany Germany
    Country flag
    Yesterday I tried the plugin. Unfortunately with no so good results here.

    First I tried the plugin with my existing MediaLibrary. This means, the DlnaAspect is not yet filled. Then I've started BubbleUPnP and tried to browse MP2. As result there is a huge list of:
    Code:
    [2015-10-01 20:17:43,346] [91033  ] [44       ] [ERROR] - Search failed, Key: VSS:d4b7fbb0-65eb-45f8-b4c6-c24f02dceb86, Frame: Initialise at offset 100 in file:line:column d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryResource.cs:51:7
    , Line: 51
    System.InvalidOperationException: Mediaitem 86f64363-4962-4c21-a196-46bbe5e87de4 contains no DLNA video information
       bei MediaPortal.Extensions.MediaServer.DLNA.DlnaMediaItem..ctor(MediaItem item, EndPointSettings client) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\DLNA\DlnaMediaItem.cs:Zeile 74.
       bei MediaPortal.Extensions.MediaServer.Profiles.EndPointSettings.GetDlnaItem(MediaItem item) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Profiles\ProfileObjects.cs:Zeile 431.
       bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryResource.Initialise() in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryResource.cs:Zeile 51.
       bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryVideoItem..ctor(String baseKey, MediaItem item, EndPointSettings client) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryVideoItem.cs:Zeile 97.
       bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryHelper.InstansiateMediaLibraryObject(MediaItem item, String baseKey, BasicContainer parent, String title) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryHelper.cs:Zeile 109.
       bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryHelper.InstansiateMediaLibraryObject(MediaItem item, String baseKey, BasicContainer parent) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryHelper.cs:Zeile 84.
       bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryContainer.Search(String filter, String sortCriteria) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryContainer.cs:Zeile 86.
    I think if an Item doesn't have a DlnaAspect it should be excluded before and the exceptions should be avoided. This could be achieved by adding the DlnaAspect-ID as a required MIA, then only MIs are returned that have it.

    Next try: I removed my shares and tried to let the MIs imported to fill the DlnaAspect. I've run the MP2-Server in console mode (-c as argument), not as service. My sources are network shares. During this import the log is flooded by:
    Code:
    [2015-10-01 20:24:34,953] [502639 ] [14       ] [ERROR] - MediaAnalyzer: Failed to extract media type information for resource '\\LS-WXLD09\Media\Musik\Alben\Anastacia - Anastacia\Anastacia - Anastacia - 06 - I Do (feat. Sonny of P.O.D.).mp3', Result: , ExitCode: -2147483648, Success: False
    [2015-10-01 20:24:35,480] [503167 ] [85       ] [ERROR] - MediaAnalyzer: Failed to extract media type information for resource '\\LS-WXLD09\Media\Musik\Alben\Anastacia - Anastacia\Anastacia - Anastacia - 08 - [2015-10-01 20:24:36,577] [504264 ] [95       ] [INFO ] - DlnaMediaServer: Exception reading resource '{03dd2da6-4da8-4d3e-9e55-80e3165729a3}:////LS-WXLD09/Media/Musik/Alben/Anastacia - Anastacia/Anastacia - Anastacia - 09 - Sexy Single.mp3' (Text: 'Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.')
    This looks like no process is able to access the resources on UNC share. I'm not sure if this isn't a problem of our impersonation handling? @MJGraf what do you think? I will test this build as Service as next to check if it works with System account.
     

    henso

    Development Group
  • Team MediaPortal
  • February 16, 2012
    2,170
    735
    Denmark Denmark
    Country flag
    This could be achieved by adding the DlnaAspect-ID as a required MIA, then only MIs are returned that have it.
    The problem with that approach is that I'm not only searching for one type of MIA but multiple. When I want to search for all media of type Image, Video or Audio, I can't put the DLNA MIA's as required, because Images don't have DLNA aspect for audio and so on. I will catch the exception instead and write a warning in the logs or should it be a debug message?
     

    FreakyJ

    Development Group
  • Team MediaPortal
  • July 25, 2010
    4,023
    1,420
    Germany Germany
    Country flag
    I would say warning :)
    Because there is something wrong if you don't have these aspects xD
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    morpheus_xx [Evaluate] Checking UPnP library for security vulnerabilities MediaPortal 2 7
    raffe How do I setup MP2 as an UPnP server? General 3
    morpheus_xx [Finished] Debugging dead locks in UPnP library MediaPortal 2 1
    Lehmden [WiP] [MP2-824] DLNA Server functionality MediaPortal 2 27
    RoChess Weird GPU crash -- possible cause: resizing media MediaPortal 1 Talk 8
    J Navigating media drive General 4
    J Will Media Portal meet my requirements? General Support 4
    C Imported media doesn't show up immediately? General 1
    J Show media item location Feature Requests 4
    HTPCSourcer Media Accessor is flooding logs with files from attached monitor MediaPortal 2 9
    N [fixed] [MP2-822] Folder View is not displaying individual media share elements Submit: Bug Reports 4
    A MP2.2.2, understanding movies/videos/tv and WTV recordings. General 16
    T I cannot get a basic media import-what is the best configuration? General 10
    Rob Hexenmeister [solved] Latest Media Handler - skinning buttons Fanart Handler 19
    J MediaPortal TV Server and Kodi media source issues General 9
    D media portal 2.2 have movies shown on genre not name General 6
    M How to Watch my videos from my Media Portal to My TV without TV Tuner Newcomers Forum 1
    D Media Portal wake schedule General Support 29
    R Media portal resumes with wrong screen resolution General Support 3
    Rob Hexenmeister Latest Media Handler - facade properties - itemcount General Support 3
    P WMC on Windows 7 migrating to Media Portal on Windows 10 Newcomers Forum 5
    Rob Hexenmeister [solved] Latest media handler - time reported as date Fanart Handler 18
    Rob Hexenmeister Video Buttons / Latest Media MediaPortal 1 Skins 7
    C DVB-C Empfänger Hauppauge Win TV dual wird in Media Portal nicht aktiviert TV / Streaming 1
    Patrik-See Unitymedia HD+ Fernsehen mit Media Portal legal möglich? TV / Streaming 0
    Similar threads

























    Top Bottom