Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix embedding for .mkv .webm #27117

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

PeterNespesny
Copy link

@PeterNespesny PeterNespesny commented Nov 17, 2023

Related: #10000
Client doesn't treat .mkv as a video file type when user tries to upload one.
mkv_noembed
Fixing that by returning "video/mp4" in MimeTypeForFile
mkv_embed

Related: #24003
Client fools the user by displaying uploaded .webm videos as embedded for some time, but they do not get embedded server-side and turn into documents. Why not fix it with the most logical solution of supplying .webm videos with MIME type "video/mp4" and changing the filename: filename.webm to filename[webm].mp4
webm_embed

@CLAassistant
Copy link

CLAassistant commented Nov 17, 2023

CLA assistant check
All committers have signed the CLA.

@PeterNespesny PeterNespesny marked this pull request as ready for review November 17, 2023 19:40
@23rd
Copy link
Collaborator

23rd commented Nov 17, 2023

What if *.mkv file has 5 video and 10 audio tracks inside? What the client should to do?

@@ -111,6 +111,9 @@ MimeType MimeTypeForFile(const QFileInfo &file) {
return MimeType(MimeType::Known::TDesktopTheme);
} else if (path.endsWith(u".tdesktop-palette"_q, Qt::CaseInsensitive)) {
return MimeType(MimeType::Known::TDesktopPalette);
} else if (path.endsWith(u".mkv"_q, Qt::CaseInsensitive)) {
// This will ensure .mkv is detected as a video file by the client when drag-n-dropped
return MimeType(QMimeDatabase().mimeTypeForName("video/mp4"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look like a right change: if you want to allow .mkv to be videos then do exactly that, don't pretend it to be .mp4. But I guess @john-preston won't allow that. Also, most mkv videos are unlikely to be played by the official builds as they have ffmpeg built only with require codecs enabled.

Copy link
Author

Choose a reason for hiding this comment

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

if you want to allow .mkv to be videos then do exactly that, don't pretend it to be .mp4

Yes, I do believe adding .mkv to extensions in FileLoadTask::CheckForVideo would achieve the same result.

static const auto extensions = {
		u".mp4"_q,
		u".mov"_q,
		u".m4v"_q,
		u".webm"_q,
};`

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also add the mimetype. Searching by video/mp4 it's not the only place where it has to be added for full-feature support.

@@ -875,6 +875,11 @@ ChatRestriction DocumentData::requiredSendRight() const {
void DocumentData::setFileName(const QString &remoteFileName) {
_filename = remoteFileName;

// Needed in order to force the server to embed the video
if (_filename.toLower().endsWith(".webm")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This really looks like a candidate for various forks as getting through explicit server-side restrictions in an official client looks very weird.

Copy link
Author

Choose a reason for hiding this comment

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

  1. Restricting .webm embedding server-side doesn't make any sense
  2. User can achieve the same result by changing the file extension manually

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't mean official client is allowed to help the user to overcome server-side restriction

Copy link
Author

Choose a reason for hiding this comment

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

If there's such a server-side restriction, then FileLoadTask::CheckForVideo probably shouldn't return true for webms resulting in broken embedding

@Aokromes
Copy link
Collaborator

What if *.mkv file has 5 video and 10 audio tracks inside? What the client should to do?

imho, prefer defaults :)

@ilya-fedin
Copy link
Contributor

@Aokromes I guess @23rd means tdesktop doesn't handle that and the UX with mkvs is likely to be poor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants