MyBB Community Forums

Full Version: gif to webm or mp4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to change gif to webm or mp4 when uploading in attachment.php?

I am looking for a way to reduce server image storage space.
(2018-08-24, 03:07 PM)alstn13178 Wrote: [ -> ]Is there a way to change gif to webm or mp4 when uploading in attachment.php?

I am looking for a way to reduce server image storage space.

Use an excellent outside image hosting website.

Look at Imgur
Changing the file extension on a file upon uploading may render the file useless. Remember, a file extension is theoretically just a "label". You can change the label on something but that doesn't alter the product or thing you're attempting to change.

If you want mp4 files and other various formats with smaller sizes it's probably best to force it on your users in ACP > Configuration > Attachment types. Additionally, as suggested above use an external image host.
upload.attachemnt.php

function upload_attachment($attachment, $update_attachment=false)

.
.
.

//when gif file 

$filename = "post_".$mybb->user['uid']."_".TIME_NOW."_".md5(random_str()).".attach";
$filename = preg_replace('"\.attach$"', '.mp4', $filename);	
	
	
$ffmpeg = "/usr/bin/ffmpeg";
$gifFile = $attachment['tmp_name'];
		

$output = $mybb->settings['uploadspath']."/".$month_dir."/".$filename;

$cmd = "$ffmpeg -i $gifFile -movflags faststart -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $output";	
exec($cmd);   
$attachment['name'] = $output;
.
.
.
function upload_file($file, $path, $filename="")
{
.
.
//$moved = @move_uploaded_file($file['tmp_name'], $path."/".$filename);
.
.
}


ffmpeg works.

make 7M gif file to 300KB mp4 file.

*I am using imgur, but I want to upload file directly to my server.