Page MenuHomePhabricator

Tool to cut videos in Commons
Closed, ResolvedPublic

Description

Problem: Downloading a video and Editing to cut videos in Wikimedia Commons locally to finally upload it again to commons is quite time consuming and data consuming.

Who would benefit: Volunteers who cut videos in Commons to improve (Ex: We are uploading entire movie articles into commons and we need to cut them into several small videos to make use of them in different Wikipedia pages.)

Proposed solution: To create a tool like CropTool for videos to cut them and upload separately without downloading, editing locally and uploading again. The tool should run on Toolforge: https://wikitech.wikimedia.org/wiki/Help:Toolforge

Thie idea proposed and accepted in https://meta.wikimedia.org/wiki/Community_Wishlist_Survey_2019/Multimedia_and_Commons#Tool_to_cut_videos_in_Commons

Mentors: @Hassan.m.amin, @Rogueassasin123, @Doc_James, @maskaravivek.

Event Timeline

Excited to see this being worked on. A critical functionality for our movement.

@maskaravivek @Rogueassasin123 @Doc_James Hello mentors! Could you update the task to include some microtasks for potential candidates? @Jenniline is interested in applying to the project through GSoC and reached out to me asking for some next steps to get involved in the project.

@Gopavasanth has taken on this project as part of GSoC.

@Doc_James Oops! Sorry, I should have checked on this earlier. Though this is not encouraged that we pre-assign a candidate to work on a project, in this case, it is okay as @Gopavasanth proposed to work on this if I've got this right. If so, then it would make sense for us not to showcase this project here https://www.mediawiki.org/wiki/Google_Summer_of_Code/2019 and on Phabricator as a featured project. If you all (cc @maskaravivek @Rogueassasin123) have proposed this project, then it would make sense to open it up to all potential candidates.

@Gopavasanth reach out to Pratik and I about working on this project. We have had a teleconference about the work a few days ago.

Note that the GSoC 2019 student application period has not even started. Hence terms like "first week reports" make not sense to me at this stage.

@Aklapper, @srishakatux : Sorry for the confusion and miscommunication . This project is open for all candidates.
Hassan (@Videowiki123) will be breaking this task into micro-tasks by the end of this week.

Hello Mentors! I am a GSoC19 aspirant. I wanted to ask if this project available for GSoC candidates. If yes I would definitely like to proceed into the details.
Thanks :)
@Rogueassasin123 @Videowiki123 @Doc_James @maskaravivek

Hello,
Here's a broken down version of the task with few user stories and the possible/required architecture for the backend. please let me know if you have any questions regarding that.

/*
= As an unregistered user i should be able to:
1- Register/login using OAuth with my mediawiki account
1.1  Once logged in, check if the user is already registered in the database by quering the database using their mediawiki id ( returned from the OAuth login ). if he's already an existing user, just update the token. Otherwise, save the user's info in a new record ( his username, mediawiki id, token, token secret ).
1.2-Either store the user data in the session or generate  a JWT token and return to the user with his user info in JSON format. something similar to 
{
	"username": "hassan.m.amin",
	"token": "SomeJwtToken"
}

= As a registered user i should be able to:

1- Cut out ( Trim ) a part of the video ( for example, trim the first 2 minutes out of a 1 hour video ). 
2- Crop the video to my desired aspect ratio. e.g. 1:1, 4:3, 4:5, 16:9, 18:9, 21:9, custom ( specified by a drag and drop layer on the video )

The UI and basic functionality should be similar to this tool ( https://online-video-cutter.com ) 

======================================================

API Routes:

=> GET /login
this route should enable the user to login via OAuth using their wikimedia account ( Commons ).

=> POST '/crop'
- Ensure user is authenticated.
- The route receives parameters:
	1.1 params to be used in cropping and trimming for ffmpeg ( see ffmpeg docs )
	1.2 commons video title ( to be cropped/trimmed)
	1.3 new file title ( to be uploaded ) 
	1.4 file description
	1.5 file categories ( array )

-Instructions to be performed on this route:
1- verify video exists on commons
2- verify the provided new file title is not duplicate on commons.
3- create a new record in the database having the info of the video
4- return to the frontend the video record info ( so we can use the video id to track the progress )
5- start a new thread and execute the cropping command while updating the progress in the database. tracking progress for ffmpeg can be done by listening to the stdout for the process which gives how much out of the video's initial length have been processed 

6- inside the thread
	6.1 download the video from commons to the server for processing 
	6.2 start the cropping operation using ffmpeg
	6.3 once is done, upload the cropped video to commons with the given data ( title, description, categories ) and using the logged in user's token ( to be uploaded under his account ).

=> GET '/videos/:id'

Should return the video record by id to track the progress on the front end.*/

Is there any plan to track derivatives? I propose that any new derivatives either trimmed or cropped (or both) versions have links in the metadata under the video in commons under 'other versions', and the original version also has links in metadata to link to the new version(s).

Example where you can see multiple language derivatives of the same source video (look in the metadata under 'other versions'):

Yes of course Victor_Grigas that will be essential.

Like we the crop toll for still images people should have the option to upload a new version versus overright the old version. If one uploads a new version we will need the

other_versions={{Extracted from1=Name or First Video}}

And |other_versions={{Image extracted|1=}} added to the one the video was from

Thank you for a detailed description. I had read somewhere the skills required for this project involve PHP and JavaScript.
So is this tool to be made for the Common's website ?
If someone could share the link for the website's codebase in that case, where I can make contributions. I only found the Common's android app on Github.

Hi and welcome @LittleBuddhaa! Wikimedia Commons has no specific one codebase. Like all other sites it runs MediaWiki and some MediaWiki extensions. See https://www.mediawiki.org/wiki/How_to_become_a_MediaWiki_hacker .
This tool will not be part of MediaWiki or a MediaWiki extension codebase but a tool on Toolforge. See https://wikitech.wikimedia.org/wiki/Help:Toolforge

Thank You @Aklapper! From what I understand this will be an individual tool exclusively made for Commons. And the commons API will be used for the backend. Please correct me if I am wrong.
I also have a few questions :

  1. Can frameworks like Flask or Angular be used ? (for more flexibility, and I also happen to have experience in both)
  2. How should the original video be referenced in the tool ? (using the url of page of original video, the link of video can be scraped and used )

Also if any of the mentors would like to attach any specific tasks or would like to see a mini project, I'd be happy to do so!
@Hassan.m.amin @Rogueassasin123 @Doc_James @maskaravivek

@Hassan.m.amin , I had a doubt regarding point 6 from the breakdown. In 6.1 , wouldn't a huge video take a lot of time to be uploaded to the server ? And the user will have to wait for that amount to time too.
Is there a way to make this faster ?

@LittleBuddhaa :Yes indeed a huge video file can take time to be uploaded, however note that the video files won't be uploaded directly by the users in this tool, however the users give the link to that file from Wikimedia Commons and the server will handle the download.

The main purpose of the tool is to enable manipulating videos that are "already" hosted on Commons.

@Rogueassasin123 Thank you for the response. Project is quite clear in my mind, I will draft a proposal asap and share with you guys to seek feedback, and to make sure I understood the project requirements correctly.
I will also share with you, basic cropping implementation for the uploaded videos in a mini project made in Flask shortly. :)

Hello @mentors, I implemented a little part from the above description as a mini project.

It takes a URL as input and stores the video in the server, asks for cropping parameters and again stores the cropped video in the server.

This is a basic implementation, where I wanted to see how cropping can be done using ffmpeg. I haven't implemented the login/register , UI or the the posting of the cropped video.
Please do take a look, I have also posted a demo in the README file. Here

Also, if there are any suggestions, or add-on features, I will include them in my proposal!

@mentors,
Can we also provide the user to search the videos from the tool itself as a nice to have feature , using the Commons API?

The user who would be using the tool would have a specific video in mind when using the tool. It's a good add on but don't know how useful it will actually be to the end user.

We could implement it though :)

Basically people will be starting from the page for the video on Commons.
They will be at the video they wish to cut. No extra search feature needed.
Commons has a search feature.

Also cutting video and trimming video are both fairly big tasks. We need to
stay focused to succeed in just these :-)

I feel that I ought to comment - I agree with LittleBuddhaa that a 'clips pane' with a search bar for videos from commons would be useful for editing, but I also agree with Doc_James that it's important now to stay focused on the current tool wanted: trimming and cropping. Other features can be created later.

I will say that I once went to an open-source video conference sponsored by Kaltura (an open-source video outfit) and I met a vendor there who had developed a web-based video editor (closed source) that had a clips pane that also had a search function like the one you (LittleBuddhaa) describe. A user could start with am empty timeline, search for a topic, and any video that is marked as cc-by or other appropriate license from YouTube or Vimeo (and I believe Commons too) would show up as available to import to the clips pane. This is a feature that would be nice down the road, but I don't believe that it should be a current goal because 1.) resources are strained 2.) going slowly allows for kinks to get worked out.

Hello everyone! I have created an initial draft of the proposal here. I'm open for all your valuable feedback and suggestions. :D

@LittleBuddhaa and @Gopavasanth : both of your initial drafts look in good shape. Would request you to kindly send the Final PDF proposal before the deadline.

I'm a UX designer and happy to help wireframe out a base structure for this functionality if helpful!!

If Toolforge's resource constraints impair the tool's availability and speed, I can offer https://wikitech.wikimedia.org/wiki/Nova_Resource:Video for the encoding part. This is what video2commons uses. A more updated ffmpeg with VP9 row-mt is also available there.

@ashgrigas: The development will start on May 9. So if you could make a wireframe by then - that would be great

Excited to see progress on this !

Is there anything remaining in this task from GSoC'19? If not, then please consider marking it as resolved! If yes, and would need another GSoC or volunteer help then consider creating a new task with the leftover items. Thanks!

srishakatux claimed this task.

(I'm being bold and closing this task. There can be a separate task for making further improvements to the tool)