Jump to content

Is it possible to automatically scale-down video files from a high-res one uploaded to a field ?


protro
 Share

Recommended Posts

I have a question about a workflow I'd like to find. A client has asked me if they could populate a ProcessWire site with 1080p video files in several page fields; one video per page. I'd like to be able to retroactively create and serve smaller versions of those video files on the front-end. I'm not sure how to achieve this in batch. The PW assets structure can be confusing, as not all the uploaded videos will appear in one directory.

I know how to batch convert in ffmpeg. I'm trying to learn if there is a way to do this with some combination of PW and TracyDebugger.

I appreciate any ideas on this matter.

Link to comment
Share on other sites

Hey there fellow Angeleno,

Let's assume you have a bunch of 'video' pages with a 'file' field where the single video gets uploaded and another field called 'file_transcoded' that contains the transcoded/sized-down version.

You could create an external script that bootstraps into ProcessWire, loops through each page where 'file_transcoded' doesn't exist (meaning it hasn't been acted upon yet), run ffmpeg on it, take the transcoded file and add it to file_transcoded ($page->file_transcoded->add($transcoded_file)), save and repeat for all the other non transcoded pages.  That external script could be run using a cronjob.  I believe you can do a background process or queue however I don't have experience with that in the context of ProcessWire yet although it's been discussed.

The approach I mentioned keeps all the files in the natural /site/assets/files/(page-id)/ directory.  I think the main point here is that where the original video files precisely exist is irrelevant as long as you use the $pages API which will take care of that for you.

  • Like 5
Link to comment
Share on other sites

@Jonathan Lahijani many greetz,

I would like to look into this bootstrapping idea, it's the first I've come across it. I'll be investigating this further. Your approach makes sense to me in the abstract. If I make progress on it I will share the code I use. Thank you for pointing me towards the PHP-ffmpeg repo as well.

  • Like 1
Link to comment
Share on other sites

Hello @protro ,

Why not using a video platform (YouTube, Vimeo...)? Serving videos has many constraints that are already solved by this platforms (disk space, bandwidth to serve a large number of simultaneous streams, encoding to several streams with different bitrates, choice of the best stream based on client downloading speed...).

To facilitate things for your customer you can put the upload form on his web site and transfer the video in the background to the video platform using its proprietary API.
Then integrate the platform embedding code to display video player.

Link to comment
Share on other sites

Thanks for this insight @da² I've thought about this. For this particular project, it's more of an interactive art experience where each page has a video embed as the background. As far as I am aware, you can't stream a video from youtube as a background video without all of the GUI elements (?) … which we would like to avoid.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...