a-ok Posted October 17, 2017 Share Posted October 17, 2017 Just a quick question. I'm guessing there's no way to get a file dimension (height/width) (specifically video files (.mp4/.webm)) from a file upload field like we can for images? I realise that height/width won't be retrievable for ALL file types but what about video files? Does anyone know if the dimensions are stored in the meta data of the file like they are for images? Link to comment Share on other sites More sharing options...
abdus Posted October 17, 2017 Share Posted October 17, 2017 Check out Video Fieldtype Keep in mind that it requires ffmpeg installed on your server, so that might not be ideal. 1 Link to comment Share on other sites More sharing options...
a-ok Posted October 17, 2017 Author Share Posted October 17, 2017 1 hour ago, abdus said: Check out Video Fieldtype Keep in mind that it requires ffmpeg installed on your server, so that might not be ideal. Thanks but it doesn't allow multiple file formats or allow me to return height/width. Link to comment Share on other sites More sharing options...
adrian Posted October 17, 2017 Share Posted October 17, 2017 3 minutes ago, oma said: Thanks but it doesn't allow multiple file formats or allow me to return height/width. It is currently designed as a video only fieldtype, but if you want to allow other files as well, it shouldn't be hard to implement that option. As for returning width and height - it determines them and uses them when using ->play() but yes it doesn't make them available via ->width() / ->height(). It would also be a pretty easy addition. 1 Link to comment Share on other sites More sharing options...
a-ok Posted October 17, 2017 Author Share Posted October 17, 2017 7 minutes ago, adrian said: It is currently designed as a video only fieldtype, but if you want to allow other files as well, it shouldn't be hard to implement that option. As for returning width and height - it determines them and uses them when using ->play() but yes it doesn't make them available via ->width() / ->height(). It would also be a pretty easy addition. I wonder if we could use FFmpeg to determine the height/width? I'm thinking I could write a hook to do this on a File fieldtype instead and return the values somehow. Link to comment Share on other sites More sharing options...
adrian Posted October 17, 2017 Share Posted October 17, 2017 6 minutes ago, oma said: I wonder if we could use FFmpeg to determine the height/width? I'm thinking I could write a hook to do this on a File fieldtype instead and return the values somehow. Absolutely, although you need to consider if there are any resource issues with calling ffmpeg-php's getDimensions() at runtime - are you just processing one video at a time on the frontend? I worry that if you are processing many at a time that this might be an issue. Ideally it would be good to store width/height on upload, but there is no easy place to store these in the PW db structure. In the Video fieldtype module I actually rely on the dimensions of the created thumbnail so it's not an issue. Link to comment Share on other sites More sharing options...
a-ok Posted October 17, 2017 Author Share Posted October 17, 2017 8 minutes ago, adrian said: Absolutely, although you need to consider if there are any resource issues with calling ffmpeg-php's getDimensions() at runtime - are you just processing one video at a time on the frontend? I worry that if you are processing many at a time that this might be an issue. Ideally it would be good to store width/height on upload, but there is no easy place to store these in the PW db structure. In the Video fieldtype module I actually rely on the dimensions of the created thumbnail so it's not an issue. Ah yes good point! I wonder if we could use the file description field... would be a bit hacky for sure. It would probably be many at a time (video wise) so yes I would look to store this on upload so it's stored in the DB. Hmmm. Your idea of generating a poster from the video is smart (presumably this poster is the same height/width as the video itself?) and could definitely be the answer. Link to comment Share on other sites More sharing options...
a-ok Posted October 17, 2017 Author Share Posted October 17, 2017 @adrian Is mp4 supported by all modern browsers? Is that why you're leading with that? I've had a google... seems to be... https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats Link to comment Share on other sites More sharing options...
adrian Posted October 17, 2017 Share Posted October 17, 2017 1 minute ago, oma said: @adrian Is mp4 supported by all modern browsers? Is that why you're leading with that? I've had a google... seems to be... https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats http://caniuse.com/#search=mp4 But I am also using http://www.mediaelementjs.com/ as the default player in that module - it has a flash fallback for any browsers that don't support mp4 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now