instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.71k stars 2.52k forks source link

Media Playback without external services #2327

Open amg-web opened 8 months ago

amg-web commented 8 months ago

since 2022 after uploading media file we unable to add it to the page or other content and see "Media file is processing. Please try again later"

It's ok for me to have only 1 resolution on Open Source Canvas LMS, and it's ok for me to serve this media file from local Canvas files storage.

How should I allow playback of such file?

0711kps commented 8 months ago

I did some modification and the canvas-media-player work in stable-2023-03-01 version

but the bad news is, when I checked out to the latest version, the patch is not working anymore, and looks like it's getting harder and harder to use canvas-media-player in pages

my solution at stable/2023-03-01 version was

when attachment record have a "maybe" in its media_entry_id field, canvas will treat it as "media to be converted by kaltura" so the solution was to skip "kaltura" flow and use old canvas-media-player for media playback


since Canvas themselves use kaltura service for video playback they might not put a lot of effort on the code they don't need maybe they will just remove canvas-media-player one day so the long-term solution might be, to host a kaltura instance yourself

amg-web commented 8 months ago

@0711kps

since Canvas themselves use kaltura service for video playback they might not put a lot of effort on the code they don't need maybe they will just remove canvas-media-player one day so the long-term solution might be, to host a kaltura instance yourself

Thanks for sharing. I do not want to use kaltura for hosting several audio/video files. it's not open community friendly way to use external services without alternative.

jfoscue commented 4 months ago

We are also having the same type of issues and don't want to use Kaltura.

We have made some patches to media_objects_controller.rb where we comment out the following lines: before_action :check_media_permissions, except: %i[create_media_object index media_object_thumbnail update_media_object] before_action(only: %i[update_media_object]) { check_media_permissions(access_type: :update) }

This way we don't have to modify the attachments' media_entry_id in the database.

We also are using @instructure/ui-media-player 8.2

Have you had any luck at a permanent solution without having to do patches?

Thanks in advance!

amg-web commented 4 months ago

@jfoscue thanks for sharing. can not add anything for now. if you can please share your patches to a.gangan on gmail.

OpenCast has support of LTI and Canvas, but I could not itegrate it correctly. also according to some messages on forums admins usually to make extra steps for each new course.

bdruth commented 1 month ago

I did some modification and the canvas-media-player work in stable-2023-03-01 version

but the bad news is, when I checked out to the latest version, the patch is not working anymore, and looks like it's getting harder and harder to use canvas-media-player in pages

my solution at stable/2023-03-01 version was

  • update all attachments' media_entry_id to null
  • comment out self.media_entry_id ||= "maybe" if new_record? && previewable_media? in app/models/attachment.rb

when attachment record have a "maybe" in its media_entry_id field, canvas will treat it as "media to be converted by kaltura" so the solution was to skip "kaltura" flow and use old canvas-media-player for media playback

since Canvas themselves use kaltura service for video playback they might not put a lot of effort on the code they don't need maybe they will just remove canvas-media-player one day so the long-term solution might be, to host a kaltura instance yourself

@0711kps I think I followed these steps, but I'm not sure I'm using the right canvas-media-player ... I'm getting a 401 when it tries to access the video when I embed it on a Page. The URL it's getting a 401 on is /media_attachments_iframe/ and the Page just shows a lock icon where the video should be with "Access Denied" ...

Any thoughts on what I might have gotten wrong?

bdruth commented 1 month ago

Oof, I think part of the problem might be changes since 2023-03-01 ... crap. I'll have to reset back to that and see if I can get things working.

jfoscue commented 2 weeks ago

My patch involved 3 files. packages/canvas-rce/src/canvasFileBrowser/FileBrowser.jsx changed line 229 to "const isMediaPending = false" packages/canvas-rce/src/rce/plugins/instructure_record/MediaPanel/index.jsx changed line 56 to "disabled={false}" app/controllers/media_objects_controller.rb commented out lines 81 & 82

Also changed some package.json files... ./package.json, ./packages/canvas-media/package.json, & ./packages/canvas-rce/package.json changed the ui-media_player back to "^8.2.0"

You might have to tweak the yarn.lock file to support the package.json changes.

These fixes allow us to insert video into a page/module and play it back without using Kaltura or other 3rd-party plugin.

But these changes are probably not sustainable going forward so we will need to come up with another solution because Kaltura is not acceptable and/or functional.

bdruth commented 1 week ago

@jfoscue - just to be clear, the changes you made are to current HEAD, not to 2023-03-01?

jfoscue commented 5 days ago

Sorry, it was version 2024-07-17

bdruth commented 4 days ago

Thx @jfoscue - either way, a good bit more current than 2023-03-01 😉