Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Solved Smart Playlists don't support 4k+ or custom resolutions
#1
I recently got a 4k monitor, but don't have much 4k content so I created a 4k smart playlist.

Here's the XML definition:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="movies">
<name>4k</name>
<match>all</match>
<rule field="videoresolution" operator="greaterthan">
<value>2159</value>
</rule>
<order direction="ascending">sorttitle</order>
</smartplaylist>

To my surprise, this returned 0 results.

I went and verified that I most definitely had 4k content in Kodi and that it was showing as such.

And this point I didn't know if it was a db issue, a smart playlist issue, or a general Kodi issue, so I turned on debug logging and ran the play list. Result:

08:27:59 T:13900 DEBUG: CGUIMediaWindow::GetDirectory (special://profile/playlists/video/4K.xsp)
08:27:59 T:13900 DEBUG: ParentPath = [special://videoplaylists/]
08:27:59 T:13900 DEBUG: CVideoDatabase::RunQuery took 1 ms for 0 items query: select * from movie_view WHERE ((movie_view.idFile IN (SELECT DISTINCT idFile FROM streamdetails WHERE iVideoWidth > 2147483647)))

Well that would be why I get no results. A quick Google search for 2147483647 shows this is the max value of a 32bit int. Ok. At least I know it's just not some random number.

Now I'm wondering if maybe filtering on video resolution is just completely broken, so I change the filter value from 2159 to 1079. And low and behold, I get results back.Here's the query in the log for that:

10:58:13 T:12864 DEBUG: CVideoDatabase::RunQuery took 56 ms for 1742 items query: select * from movie_view WHERE ((movie_view.idFile IN (SELECT DISTINCT idFile FROM streamdetails WHERE iVideoWidth > 1280)

1280? Why is it using the vertical resolution for 720p contentHuh

Time to look up the source code. I searched for iVideoWidth in the repro and found the smartplaylist code at https://github.com/xbmc/xbmc/blob/5c2002...ayList.cpp

Here's the bit we're interested in:

Code:
std::string CSmartPlaylistRule::GetVideoResolutionQuery(const std::string &parameter) const
{
  std::string retVal(" IN (SELECT DISTINCT idFile FROM streamdetails WHERE iVideoWidth ");
  int iRes = (int)std::strtol(parameter.c_str(), NULL, 10);

  int min, max;
  if (iRes >= 1080)     { min = 1281; max = INT_MAX; }
  else if (iRes >= 720) { min =  961; max = 1280; }
  else if (iRes >= 540) { min =  721; max =  960; }
  else                  { min =    0; max =  720; }

  switch (m_operator)
  {
    case OPERATOR_EQUALS:
      retVal += StringUtils::Format(">= %i AND iVideoWidth <= %i", min, max);
      break;
    case OPERATOR_DOES_NOT_EQUAL:
      retVal += StringUtils::Format("< %i OR iVideoWidth > %i", min, max);
      break;
    case OPERATOR_LESS_THAN:
      retVal += StringUtils::Format("< %i", min);
      break;
    case OPERATOR_GREATER_THAN:
      retVal += StringUtils::Format("> %i", max);
      break;
    default:
      break;
  }

  retVal += ")";
  return retVal;
}

What's the point of letting you put any number you want into the filter if you're just going to throw it into 1 of 4 buckets anyway? Especially if it's not future proof at all.

Here's my "fix" below:

Code:
std::string CSmartPlaylistRule::GetVideoResolutionQuery(const std::string &parameter) const
{
  std::string retVal(" IN (SELECT DISTINCT idFile FROM streamdetails WHERE iVideoWidth ");
  int iRes = (int)std::strtol(parameter.c_str(), NULL, 10);

  switch (m_operator)
  {
    case OPERATOR_EQUALS:
      retVal += StringUtils::Format("= %i", iRes);
      break;
    case OPERATOR_DOES_NOT_EQUAL:
      retVal += StringUtils::Format("!= %i", iRes);
      break;
    case OPERATOR_LESS_THAN:
      retVal += StringUtils::Format("< %i", iRes);
      break;
    case OPERATOR_GREATER_THAN:
      retVal += StringUtils::Format("> %i", iRes);
      break;
    default:
      break;
  }

  retVal += ")";
  return retVal;
}

This brings it back to what I think should be the expected functionality. Can anyone see why this might not work well before I go make a trac bug and pull request?

If this isn't a good idea, I think the second best option would be to add new "buckets" for 4k and 8k content.
Reply
#2
I guess those buckets are there to make it easier for skinners to add mediaflags since they have to add an image for each possible resolution. Adding new buckets might be the better option I think.
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#3
Why no one fixed this yet ?

I just spent 1h pulling my hair trying to find a way to filter 4k movies and every post says just do a smart playlist and no one is commenting that it is not working.

Unfortunately I am using LibreElec and can't modify code on every device that I use when ever upgrade is performed.
Reply
#4
Can I second this?

I tried creating a smart playlist as well and I couldn't fliter 4k content.
It would be a pity to have to put in separate folders.
Reply
#5
Agree, I've spent also some time trying to get a 4K Playlist without any success, is should be fixed somehow
Reply
#6
With 4K content slowly rising would be nice to have proper resolution filters in smart playlists, is there no bug report for this already?
Reply
#7
(2017-11-04, 19:52)RickDB Wrote: With 4K content slowly rising would be nice to have proper resolution filters in smart playlists, is there no bug report for this already?
Don't you mean a "Feature Request"?
Reply
#8
Technically it's a bug because user expects the existing feature (resolution filtering) to work with resolutions but it's hard coded to a certain limit, @RedsGT already mentioned a few possible fixes which could be discussed / implemented Smile
Could also call it a feature enhancement but judging from the code snippet it looks more like an oversight.
Reply
#9
Sorry all, I sort of lost interest in this and moved on to other things last year.  I just got another new 4k panel so am taking another look.

I've create a bug for this:  https://trac.kodi.tv/ticket/17666#ticket

And will be creating a pull request for the next in the week or so.
Reply
#10
https://github.com/xbmc/xbmc/pull/13086
Reply
#11
Nice it works for movies but not for TV Series ... why? Can somebody fix it? Smile
Reply
#12
(2019-09-08, 22:32)locki Wrote: Nice it works for movies but not for TV Series ... why? Can somebody fix it? Smile

I don't think this is related, but can you open a new thread on this with repro steps and any other details you have and tag me on it?  I'll take a look in the next week or two.

EDIT:  Anyone else think it's hilarious I'm a 10 year member on here with code check ins in Kodi source and a Rep of "1"...
Reply
#13
If a mod sees this, can they update this thread tag to say "Fixed" or the equivalent as I fixed this awhile back?  Or let me know how to do as the thread starter if that's an option?  I looked round in the help but didn't see anything either for that or on how to summon a mod specifically.
Reply
#14
@RedsGT,

If you do a Full Edit on your first post, you can change the labels on the thread.

But I will mark this solved for you anyway.
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#15
Thread marked solved.
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply

Logout Mark Read Team Forum Stats Members Help
Smart Playlists don't support 4k+ or custom resolutions0