{"id":13487029,"url":"https://github.com/bramp/ffmpeg-cli-wrapper","last_synced_at":"2025-05-13T17:13:13.552Z","repository":{"id":14163598,"uuid":"16869559","full_name":"bramp/ffmpeg-cli-wrapper","owner":"bramp","description":"Java wrapper around the FFmpeg command line tool","archived":false,"fork":false,"pushed_at":"2025-02-12T12:34:52.000Z","size":3888,"stargazers_count":1788,"open_issues_count":51,"forks_count":422,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-05-08T18:44:44.309Z","etag":null,"topics":["ffmpeg","java"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bramp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"bramp","buy_me_a_coffee":"bramp"}},"created_at":"2014-02-15T19:07:50.000Z","updated_at":"2025-05-07T16:36:37.000Z","dependencies_parsed_at":"2023-02-10T06:30:58.480Z","dependency_job_id":"435e2b8d-b1a7-45d9-9d89-16e8990e2caf","html_url":"https://github.com/bramp/ffmpeg-cli-wrapper","commit_stats":{"total_commits":376,"total_committers":39,"mean_commits":9.64102564102564,"dds":0.4308510638297872,"last_synced_commit":"ead7e046f715dd418efa9f77463ede6579a150d2"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fffmpeg-cli-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fffmpeg-cli-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fffmpeg-cli-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fffmpeg-cli-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramp","download_url":"https://codeload.github.com/bramp/ffmpeg-cli-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990483,"owners_count":21995775,"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","java"],"created_at":"2024-07-31T18:00:54.548Z","updated_at":"2025-05-13T17:13:08.541Z","avatar_url":"https://github.com/bramp.png","language":"Java","readme":"# FFmpeg CLI Wrapper for Java\n\nby Andrew Brampton ([bramp.net](https://bramp.net)) (c) 2013-2024\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/bramp)\n\nA fluent interface for running FFmpeg from Java.\n\n![Java](https://img.shields.io/badge/Java-8+-brightgreen.svg)\n[![Build Status](https://github.com/bramp/ffmpeg-cli-wrapper/actions/workflows/maven.yml/badge.svg)](https://github.com/bramp/ffmpeg-cli-wrapper/actions/workflows/maven.yml)\n[![Coverage Status](https://img.shields.io/coveralls/bramp/ffmpeg-cli-wrapper.svg)](https://coveralls.io/github/bramp/ffmpeg-cli-wrapper)\n[![Maven](https://img.shields.io/maven-central/v/net.bramp.ffmpeg/ffmpeg.svg)](http://mvnrepository.com/artifact/net.bramp.ffmpeg/ffmpeg)\n[![Libraries.io](https://img.shields.io/librariesio/github/bramp/ffmpeg-cli-wrapper.svg)](https://libraries.io/github/bramp/ffmpeg-cli-wrapper)\n\n[GitHub](https://github.com/bramp/ffmpeg-cli-wrapper) | [API docs](https://bramp.github.io/ffmpeg-cli-wrapper/)\n\n## Install\n\nWe currently support Java 8 and above. Use Maven to install the dependency.\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003enet.bramp.ffmpeg\u003c/groupId\u003e\n  \u003cartifactId\u003effmpeg\u003c/artifactId\u003e\n  \u003cversion\u003e0.8.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\n### Video Encoding\n\nCode:\n\n```java\nFFmpeg ffmpeg = new FFmpeg(\"/path/to/ffmpeg\");\nFFprobe ffprobe = new FFprobe(\"/path/to/ffprobe\");\n\nFFmpegBuilder builder = new FFmpegBuilder()\n\n  .setInput(\"input.mp4\")     // Filename, or a FFmpegProbeResult\n  .done()\n  .overrideOutputFiles(true) // Override the output if it exists\n\n  .addOutput(\"output.mp4\")   // Filename for the destination\n    .setFormat(\"mp4\")        // Format is inferred from filename, or can be set\n    .setTargetSize(250_000)  // Aim for a 250KB file\n\n    .disableSubtitle()       // No subtiles\n\n    .setAudioChannels(1)         // Mono audio\n    .setAudioCodec(\"aac\")        // using the aac codec\n    .setAudioSampleRate(48_000)  // at 48KHz\n    .setAudioBitRate(32768)      // at 32 kbit/s\n\n    .setVideoCodec(\"libx264\")     // Video using x264\n    .setVideoFrameRate(24, 1)     // at 24 frames per second\n    .setVideoResolution(640, 480) // at 640x480 resolution\n\n    .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs\n  .done();\n\nFFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);\n\n// Run a one-pass encode\nexecutor.createJob(builder).run();\n\n// Or run a two-pass encode (which is better quality at the cost of being slower)\nexecutor.createTwoPassJob(builder).run();\n```\n\n### Get Media Information\n\nCode:\n\n```java\nFFprobe ffprobe = new FFprobe(\"/path/to/ffprobe\");\nFFmpegProbeResult probeResult = ffprobe.probe(\"input.mp4\");\n\nFFmpegFormat format = probeResult.getFormat();\nSystem.out.format(\"%nFile: '%s' ; Format: '%s' ; Duration: %.3fs\", \n format.filename,\n format.format_long_name,\n format.duration\n);\n\nFFmpegStream stream = probeResult.getStreams().get(0);\nSystem.out.format(\"%nCodec: '%s' ; Width: %dpx ; Height: %dpx\",\n stream.codec_long_name,\n stream.width,\n stream.height\n);\n```\n\n### Get progress while encoding\n\n```java\nFFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);\n\nFFmpegProbeResult in = ffprobe.probe(\"input.flv\");\n\nFFmpegBuilder builder = new FFmpegBuilder()\n .setInput(in) // Or filename\n .done()\n .addOutput(\"output.mp4\")\n .done();\n\nFFmpegJob job = executor.createJob(builder, new ProgressListener() {\n\n // Using the FFmpegProbeResult determine the duration of the input\n final double duration_ns = in.getFormat().duration * TimeUnit.SECONDS.toNanos(1);\n\n @Override\n public void progress(Progress progress) {\n  double percentage = progress.out_time_ns / duration_ns;\n\n  // Print out interesting information about the progress\n  System.out.println(String.format(\n   \"[%.0f%%] status:%s frame:%d time:%s ms fps:%.0f speed:%.2fx\",\n   percentage * 100,\n   progress.status,\n   progress.frame,\n   FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS),\n   progress.fps.doubleValue(),\n   progress.speed\n  ));\n }\n});\n\njob.run();\n```\n\n## Building \u0026 Releasing\n\nIf you wish to make changes, then building and releasing is simple:\n\n```bash\n# To build\nmvn\n\n# To test\nmvn test\n\n# To release (pushing jar to maven central)\n# (don't forget to set up your ~/.m2/settings.xml)\nmvn release:prepare\nmvn release:perform\n\n# To publish javadoc\ngit checkout ffmpeg-0.x\nmvn clean javadoc:aggregate scm-publish:publish-scm\n```\n\n## Bumpings Deps\n\n```bash\n# Update Maven Plugins\nmvn versions:display-plugin-updates\n\n# Library Dependencies\nmvn versions:display-dependency-updates \n```\n\n## Install FFmpeg on Ubuntu\n\nWe only the support the original FFmpeg, not the libav version. Before Ubuntu 12.04, and in 15.04\nand later the original FFmpeg is shipped. If you have to run on a version with libav, you can install\nFFmpeg from a PPA, or using the static build. More information [here](http://askubuntu.com/q/373322/34845)\n\n## Get involved\n\nWe welcome contributions. Please check the [issue tracker](https://github.com/bramp/ffmpeg-cli-wrapper/issues).\nIf you see something you wish to work on, please either comment on the issue, or just send a pull\nrequest. Want to work on something else, then just open a issue, and we can discuss! We appreciate\ndocumentation improvements, code cleanup, or new features. Please be mindful that all work is done\non a volunteer basis, thus we can be slow to reply.\n\n## Licence (Simplified BSD License)\n\n```plaintext\nCopyright (c) 2013-2024, Andrew Brampton\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n  list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```\n","funding_links":["https://github.com/sponsors/bramp","https://buymeacoffee.com/bramp","https://www.buymeacoffee.com/bramp"],"categories":["Java","HarmonyOS","Build Tools, Deployment \u0026 Utility Libraries"],"sub_categories":["Windows Manager","Command-line Utilities \u0026 Wrappers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramp%2Fffmpeg-cli-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramp%2Fffmpeg-cli-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramp%2Fffmpeg-cli-wrapper/lists"}