Skip to content

[RFC] Video-lite#1463

Merged
dirkhh merged 2 commits intosubsurface:masterfrom
bstoeger:video5
Jul 8, 2018
Merged

[RFC] Video-lite#1463
dirkhh merged 2 commits intosubsurface:masterfrom
bstoeger:video5

Conversation

@bstoeger
Copy link
Copy Markdown
Collaborator

@bstoeger bstoeger commented Jul 5, 2018

Describe the pull request:

  • Bug fix
  • Functional change
  • New feature
  • Code cleanup
  • Build system change
  • Documentation change
  • Language translation

Pull request long description:

Because video-playback in #1456 was received with reservations, here is the lite-version: Import videos, but only show a dummy icon. On clicking the icon, the video is shown in the system viewer.

I hope we agree that nowadays this is a must-have feature.

Changes made:

  1. Import dummy video icon.
  2. Add list of video extensions and recognize video files.
  3. Save to thumbnail file with an appropriate flag signaling "video".

Import a video icon from the KDE breeze theme, which is licensed
under the LGPL. This icon will be used as a dummy-placeholder
for video files.

Source: https://github.com/KDE/breeze-icons

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
@neolit123
Copy link
Copy Markdown
Member

@bstoeger

BTW, we can only include icons and media that comes with a certain license or permissive origin that won't cause legal troubles. @dirkhh can elaborate.

one clean options is that we draw it our selfs.

@bstoeger
Copy link
Copy Markdown
Collaborator Author

bstoeger commented Jul 5, 2018

BTW, we can only include icons and media that comes with a certain license or permissive origin that won't cause legal troubles. @dirkhh can elaborate.

Sure, that's why I took an icon of the LPGLed Breeze KDE theme. We already use them for mobile.

one clean options is that we draw it our selfs.

Definitely not an option if I am supposed to draw it.

@dirkhh
Copy link
Copy Markdown
Collaborator

dirkhh commented Jul 5, 2018

Definitely a good start. I haven't stared at the code long enough, but conceptionally I like this much better. For the record, I'm not saying NO to video playback, I am voicing concerns. I am still open to being convinced that this is manageable from a packaging perspective.

Comment thread core/qthelper.cpp
// codecs? Do we have to query them by hand using QMediaPlayer::hasSupport()?
const QStringList videoExtensionsList = {
".avi", ".mp4", ".mpeg", ".mpg", ".wmv"
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the list of extensions looks fine to me, as is.

re: "dodging the bullet"
the point is that we shouldn't care about codecs.

obsolete member to list the MIMEs:
http://doc.qt.io/qt-5/qmediaplayer-obsolete.html
support is only an estimate:
http://doc.qt.io/qt-5/qmultimedia.html#SupportEstimate-enum

Comment thread core/imagedownloader.cpp Outdated
return res;

// Thumbnails of videos currently not supported - replace by dummy
// TODO: Correctly extract thumbnails
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we really keep this TODO?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe tone it down to
// TODO: Possibly extract thumbnail
?

Comment thread core/imagedownloader.cpp
if (!fi.exists() && !fi.isFile())
return false;
metadata md;
return get_metadata(qPrintable(filename), &md) == MEDIATYPE_VIDEO;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this would work for all containers out there.
might as well just assume by extension and throw the file to the external player.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at https://github.com/Subsurface-divelog/subsurface/blob/master/core/metadata.cpp#L208 we try to parse the MP4 container - so this seems like a reasonable thing to do for us? This at least doesn't blindly accept any extension.
(Of course I worry about the security implications here... reading that code it should be fairly easy to fool us and to at least crash Subsurface if not worse)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neolit123 is in principle right - it will parse MP4s, but not AVI. So if that fails, we can still go after extension.

But: even if we fail to identify a video as such, it will simply show a broken icon (we could refine to a format unknown icon). Clicking on it will still open the system video player.

Of course I worry about the security implications here... reading that code it should be fairly easy to fool us and to at least crash Subsurface if not worse)

I tried to make it at most a denial-of-service, which you can do in various ways anyway. If you think this is unsafe, I'll give it a second look in the next few days.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I didn't see anything that glaringly unsafe. This was more an idle comment...

Comment thread core/imagedownloader.cpp Outdated
{
QImage thumb;
bool stillLoading = false;
mediatype_t type = MEDIATYPE_UNKNOWN;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we set type here to UNKNOWN and a few lines later we test if it is != STILL LOADING. What am I missing?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind. std::tie confused me

Copy link
Copy Markdown
Collaborator Author

@bstoeger bstoeger Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in a previous PR:
We can replace std::pair<QImage, mediatype_t> by

struct SomeSensibleClassName {
	QImage thumbnail;
	mediatype_t type;
};

Then the tie will become:

	SomeSensibleClassName some_sensible_variable_name = fetchImage(localFilename, filename, tryDownload);

So far I was simply too lazy.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would have more matched my experience.
I keep thinking this is just a sign that I'm not really a C++ developer. But realistically, the struct way of doing this does allow you to call a function like this from C as well (assuming it's linked with C bindings)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But realistically, the struct way of doing this does allow you to call a function like this from C as well (assuming it's linked with C bindings)

Except that C will not be happy about the QImage... :(

If you prefer the struct-version, that's fine by me. The hardest part will be coming up with a sensible name. Perhaps simply struct Thumbnail?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here's the struct version.

@dirkhh
Copy link
Copy Markdown
Collaborator

dirkhh commented Jul 5, 2018

It is so embarrassing how much this is already pushing my comfort zone reading code.
I agree with @neolit123 's comment about the TODO - other than this I couldn't find anything wrong, but given that this is clearly not easy to read for me, I'm also not super comfortable with my ability to successfully review this. So I didn't actually approve the PR :-/

When generating thumbnails, test for video files. If it is, use
a dummy-thumbnail. Write only the type (video), but no image to
the thumbnail cache, for forward-compatibility.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
@dirkhh dirkhh merged commit b28dba6 into subsurface:master Jul 8, 2018
@sfuchs79
Copy link
Copy Markdown
Contributor

sfuchs79 commented Jul 8, 2018

@bstoeger
Great that we have the video support in master now! I'll try to continue testing this during the next days.

May I make a few suggestion (again) for fine tuning of the UI:

  • Now that we support pictures and video let's rename every occurrence of "pictures" e.g. the tab name, the context menu string,... to s.th. else. I once already proposed "media" but I'm open to any other idea.
  • For the file open dialog for the file filter I think it could be nice to have minimum three options: All pictures plus video files, picture files only, video files only.

I can submit a PR for this in a few days or maybe you like to do it but let's first discuss how we want to change it.

BTW: I also would not give up video playback in the profile immediately. I want to try once to recompile my Qt/MXE with the "-wmf-backend" option to see if this leads to s.th.

@bstoeger
Copy link
Copy Markdown
Collaborator Author

bstoeger commented Jul 9, 2018

I can submit a PR for this in a few days or maybe you like to do it but let's first discuss how we want to change it.

As you wish. I think the discussion would be ideally conducted at the mailing list, not in a closed PR. My personal opinion: "Media" is fine.

BTW: I also would not give up video playback in the profile immediately. I want to try once to recompile my Qt/MXE with the "-wmf-backend" option to see if this leads to s.th.

I opened a new PR with the video-playback. Perhaps this helps you with these experiments.

@bstoeger bstoeger deleted the video5 branch April 7, 2020 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants