Skip to content

arditbe/WEBM-FFMPEG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

post.php — Image & Video → reduced WEBM / WEBP converter

A small, secure PHP endpoint (post.php) that accepts uploaded images or videos and converts them to space-efficient WebP (images / animated) and WebM (video) formats using ffmpeg. Ideal for web apps that need fast delivery and low-bandwidth media for profiles, feeds, or messaging.

Features

Accepts multipart/form-data uploads (images & videos).

Produces WebP for images (static or animated) and WebM for videos.

Automatic resizing / bitrate reducing to sensible defaults.

Safe execution with validation and escapeshellarg to avoid injection.

Returns a JSON response with paths and metadata.

Requirements

PHP 7.4+ (works with PHP 8.x).

fileinfo PHP extension (usually enabled by default).

json extension (for responses).

ffmpeg installed and accessible in PATH (or you can set full binary path in config).

Write permission for the upload/output folder (e.g., storage/).

`` Install ffmpeg Ubuntu / Debian sudo apt update sudo apt install -y ffmpeg

verify

ffmpeg -version

macOS (Homebrew) brew update brew install ffmpeg ffmpeg -version

Windows (Chocolatey) or manual

With Chocolatey:

choco install -y ffmpeg

Or download a static build from https://ffmpeg.org/download.html and add the bin/ folder to your PATH.

CentOS / RHEL / other Linux

On some distributions you must enable extra repos (EPEL / RPM Fusion) or use a static build:

Try:

sudo yum install epel-release -y

then install ffmpeg from your vendor/repo or download static build

If in doubt, use the official static builds from ffmpeg.org.

Install & Setup (project)

Clone your project (or copy post.php) into your web root:

cd /var/www/html/your-project

copy post.php and create storage folder

mkdir -p storage/uploads storage/outputs chown -R www-data:www-data storage chmod -R 755 storage ``

Make sure PHP can run ffmpeg. If which ffmpeg returns a path, you're good. Otherwise set $ffmpeg = '/full/path/to/ffmpeg'; in the script.

About

Convert to Optimized File Formats for your APP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages