{"id":16012446,"url":"https://github.com/olaferlandsen/ffmpeg-php-class","last_synced_at":"2025-07-30T10:31:12.958Z","repository":{"id":5936111,"uuid":"7156324","full_name":"olaferlandsen/ffmpeg-php-class","owner":"olaferlandsen","description":"A complete class for using FFmpeg written in PHP 5.3+","archived":false,"fork":false,"pushed_at":"2017-09-23T02:23:21.000Z","size":49,"stargazers_count":10,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-01T17:39:14.900Z","etag":null,"topics":["ffmpeg","force-format","php","video"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"netputer/wechat-php-sdk","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olaferlandsen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-13T22:13:34.000Z","updated_at":"2022-08-10T18:09:27.000Z","dependencies_parsed_at":"2022-09-21T11:11:30.490Z","dependency_job_id":null,"html_url":"https://github.com/olaferlandsen/ffmpeg-php-class","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2Fffmpeg-php-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2Fffmpeg-php-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2Fffmpeg-php-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2Fffmpeg-php-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olaferlandsen","download_url":"https://codeload.github.com/olaferlandsen/ffmpeg-php-class/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228120357,"owners_count":17872593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffmpeg","force-format","php","video"],"created_at":"2024-10-08T14:03:27.158Z","updated_at":"2024-12-04T13:35:19.661Z","avatar_url":"https://github.com/olaferlandsen.png","language":"PHP","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=8TJZSNT5JQUXL"],"categories":[],"sub_categories":[],"readme":"[![Donate](https://www.paypalobjects.com/es_XC/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=8TJZSNT5JQUXL)\n\n\n# FFmpeg Class ( Without `ffmpeg-php` )\nA complete cross-platform class for using FFmpeg written in PHP 5.3+\n\n\u003e **IMPORTANT!**\n\n\u003e This class DON'T depend/need of `ffmpeg-php` php extension.\n\n## Requirements\n\n* FFmpeg 0.5.12+\n* PHP 5.3+\n    * PCRE( Perl-Compatible )\n\n\n## Install\n\nYou can download FFmpeg class via Github [here](https://github.com/olaferlandsen/ffmpeg-php-class/archive/master.zip)\n\nOr If you want install via Composer, try with `composer require olaferlandsen/ffmpeg-php-class`\n\n\n## Examples\n\n### Example #1: Input \u0026 output.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #2: Simple frame rate.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eframeRate( '30000/1001' )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #3: Simple frame rate using method alias.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003ei( '/var/media/original.mp4' )-\u003er( '30000/1001' )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #4: Rotate video.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003etranspose( 2 )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #5: Rotate video with alias \"rotate\".\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003erotate( 2 )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #6: Force format.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eforceFormat( '3gp' )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #7: Force format quickly.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eoutput( '/var/media/new.3gp' , '3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #8: Get command\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eoutput( '/var/media/new.3gp' )-\u003ecommand;\n    ?\u003e\n```\n\n\n### Example #9: Run command.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n\n### Example #10: Gray Scale.\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003egrayScale()-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #11: Set param.\n\n```php\n    \u003c?php\n    \t$key = 'acodec';\n    \t$value = 'AAC';\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eset($key,$value)-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #12: Unset param.\n\n```php\n    \u003c?php\n    \t$key = 'acodec';\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eunset($key)-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #13: Quick methods\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003esameq()-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #14: Flip ( V or H )\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003eflip( 'v' )-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #15: hflip\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003ehflip()-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n### Example #16: vflip\n\n```php\n    \u003c?php\n    \t$FFmpeg = new FFmpeg;\n    \t$FFmpeg-\u003einput( '/var/media/original.mp4' )-\u003evflip()-\u003eoutput( '/var/media/new.3gp' )-\u003eready();\n    ?\u003e\n```\n\n\n### Example #17: Complete\n\n```php\n    \u003c?php\n\t/**\n\t*\tinclude FFmpeg class\n\t**/\n\tinclude DIRNAME(DIRNAME(__FILE__)).'/src/ffmpeg.class.php';\n\t\n\t/**\n\t*\tget options from database\n\t**/\n\t$options = array(\n\t\t'duration'\t=\u003e\t99,\n\t\t'position'\t=\u003e\t0,\n\t\t'itsoffset'\t=\u003e\t2,\n\t);\n\t/**\n\t*\tCreate command\n\t*/\n\t$FFmpeg = new FFmpeg( '/usr/local/bin/ffmpeg' );\n\t$FFmpeg-\u003einput( '/var/media/original.avi' );\n\t$FFmpeg-\u003etranspose( 0 )-\u003evflip()-\u003egrayScale()-\u003evcodec('h264')-\u003eframeRate('30000/1001');\n\t$FFmpeg-\u003eacodec( 'aac' )-\u003eaudioBitrate( '192k' );\n\tforeach( $options AS $option =\u003e $values )\n\t{\n\t\t$FFmpeg-\u003ecall( $option , $values );\n\t}\n\t$FFmpeg-\u003eoutput( '/var/media/new.mp4' , 'mp4' );\n\tprint($FFmpeg-\u003ecommand);\n\t?\u003e\n```\n\n```bash\n/usr/local/bin/ffmpeg -y -vf transpose=0,vflip -pix_fmt gray -vcodec h264 -r 30000/1001 -acodec aac -ab 192k -t 99 -ss 0 -itsoffset 2 -f mp4 /var/media/new.mp4 /dev/null 2\u003c\u00261\n```\n\n### Example #18: Clear\n\n```php\n\t\u003c?php\n\t$FFmpeg = new FFmpeg('/bin/ffmpeg','/var/media/original.mp4')-\u003evflip()-\u003eoutput( '/var/media/new.3gp' )-\u003eclear()-\u003einput( '/var/www/file.3gp' );\n\t?\u003e\n```\n\n### Example #19: Thumbs ( Experimental )\n\n```php\n\t\u003c?php\n\t$size = '100x100';\n\t$start = 1;\n\t$frames = 10;\n\t\n\t$FFmpeg = new FFmpeg;\n\t$FFmpeg-\u003einput( '/var/www/video.mp4' )-\u003ethumb( $size , $start, $frames )-\u003eready();\n\t?\u003e\n```\n\n### Example #20: Image to video\n\n```php\n\t\u003c?php\n\t$FFmpeg = new FFmpeg;\n\t$FFmpeg-\u003einput( '/var/www/images/pref%04d.png' )-\u003eframeRate( '29,97' )-\u003esize( '1920x1080' )-\u003eforce('image2');\n\t$FFmpeg-\u003eoutput( 'image2video.mp4' );\n\t$FFmpeg-\u003eready();\n\t?\u003e\n```\n\n### Example #21: Set the FFmpeg binary file on Windows\n\n```php\n\t\u003c?php\n\t$FFmpeg = new FFmpeg( \"C:\\ffmpeg\\bin\\ffmpeg.exe\" );\n\t$FFmpeg-\u003einput( 'C:\\xampp\\input.mp4' )-\u003eoutput( 'output.3gp' );\n\t$FFmpeg-\u003eready();\n\t?\u003e\n```\n\n### Example #22: Set the FFmpeg binary file on Linux \u0026 Unix\n\n```php\n\t\u003c?php\n\t$FFmpeg = new FFmpeg( \"/etc/bin/ffmpeg\" );\n\t$FFmpeg-\u003einput( '/var/www/input.mp4' )-\u003eoutput( 'output.3gp' );\n\t$FFmpeg-\u003eready();\n\t?\u003e\n```\n\n### Example #23: Log level\n\n```php\n\t\u003c?php\n\t$FFmpeg = new FFmpeg;\n\t$FFmpeg-\u003einput( '/var/www/input.mp4' )-\u003eloglevel(\"debug\")-\u003eoutput( 'output.3gp' );\n\t$FFmpeg-\u003eready();\n\t?\u003e\n```\n## Remember:\n\n* This is an open source project and free.\n* Share our repository.\n\n## Thanks to:\n* [@HankBrown](https://github.com/HankBrown)\n* [@remotemethod](https://github.com/remotemethod)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaferlandsen%2Fffmpeg-php-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folaferlandsen%2Fffmpeg-php-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaferlandsen%2Fffmpeg-php-class/lists"}