1- FFmpeg Java
2- ===========
1+ # FFmpeg CLI Wrapper for Java
32
4- by Andrew Brampton ([ bramp.net] ( https://bramp.net ) ) (c) 2013-2014,2016
3+ by Andrew Brampton ([ bramp.net] ( https://bramp.net ) ) (c) 2013-2024
54
65[ ![ "Buy Me A Coffee"] ( https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png )] ( https://www.buymeacoffee.com/bramp )
76
8- A fluent interface to running FFmpeg from Java.
7+ A fluent interface for running FFmpeg from Java.
98
109![ Java] ( https://img.shields.io/badge/Java-8+-brightgreen.svg )
1110[ ![ 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 )
@@ -15,8 +14,7 @@ A fluent interface to running FFmpeg from Java.
1514
1615[ GitHub] ( https://github.com/bramp/ffmpeg-cli-wrapper ) | [ API docs] ( https://bramp.github.io/ffmpeg-cli-wrapper/ )
1716
18- Install
19- -------
17+ ## Install
2018
2119We currently support Java 8 and above. Use Maven to install the dependency.
2220
@@ -28,12 +26,12 @@ We currently support Java 8 and above. Use Maven to install the dependency.
2826</dependency >
2927```
3028
31- Usage
32- -----
29+ ## Usage
3330
3431### Video Encoding
3532
3633Code:
34+
3735``` java
3836FFmpeg ffmpeg = new FFmpeg (" /path/to/ffmpeg" );
3937FFprobe ffprobe = new FFprobe (" /path/to/ffprobe" );
@@ -73,64 +71,67 @@ executor.createTwoPassJob(builder).run();
7371### Get Media Information
7472
7573Code:
74+
7675``` java
7776FFprobe ffprobe = new FFprobe (" /path/to/ffprobe" );
7877FFmpegProbeResult probeResult = ffprobe. probe(" input.mp4" );
7978
8079FFmpegFormat format = probeResult. getFormat();
8180System . out. format(" %nFile: '%s' ; Format: '%s' ; Duration: %.3fs" ,
82- format. filename,
83- format. format_long_name,
84- format. duration
81+ format. filename,
82+ format. format_long_name,
83+ format. duration
8584);
8685
8786FFmpegStream stream = probeResult. getStreams(). get(0 );
8887System . out. format(" %nCodec: '%s' ; Width: %dpx ; Height: %dpx" ,
89- stream. codec_long_name,
90- stream. width,
91- stream. height
88+ stream. codec_long_name,
89+ stream. width,
90+ stream. height
9291);
9392```
9493
9594### Get progress while encoding
95+
9696``` java
9797FFmpegExecutor executor = new FFmpegExecutor (ffmpeg, ffprobe);
9898
9999FFmpegProbeResult in = ffprobe. probe(" input.flv" );
100100
101101FFmpegBuilder builder = new FFmpegBuilder ()
102- .setInput(in) // Or filename
103- .addOutput(" output.mp4" )
104- .done();
102+ .setInput(in) // Or filename
103+ .addOutput(" output.mp4" )
104+ .done();
105105
106106FFmpegJob job = executor. createJob(builder, new ProgressListener () {
107107
108- // Using the FFmpegProbeResult determine the duration of the input
109- final double duration_ns = in. getFormat(). duration * TimeUnit . SECONDS. toNanos(1 );
110-
111- @Override
112- public void progress (Progress progress ) {
113- double percentage = progress. out_time_ns / duration_ns;
114-
115- // Print out interesting information about the progress
116- System . out. println(String . format(
117- " [%.0f%%] status:%s frame:%d time:%s ms fps:%.0f speed:%.2fx" ,
118- percentage * 100 ,
119- progress. status,
120- progress. frame,
121- FFmpegUtils . toTimecode(progress. out_time_ns, TimeUnit . NANOSECONDS ),
122- progress. fps. doubleValue(),
123- progress. speed
124- ));
125- }
108+ // Using the FFmpegProbeResult determine the duration of the input
109+ final double duration_ns = in. getFormat(). duration * TimeUnit . SECONDS. toNanos(1 );
110+
111+ @Override
112+ public void progress (Progress progress ) {
113+ double percentage = progress. out_time_ns / duration_ns;
114+
115+ // Print out interesting information about the progress
116+ System . out. println(String . format(
117+ " [%.0f%%] status:%s frame:%d time:%s ms fps:%.0f speed:%.2fx" ,
118+ percentage * 100 ,
119+ progress. status,
120+ progress. frame,
121+ FFmpegUtils . toTimecode(progress. out_time_ns, TimeUnit . NANOSECONDS ),
122+ progress. fps. doubleValue(),
123+ progress. speed
124+ ));
125+ }
126126});
127127
128128job. run();
129129```
130130
131- Building & Releasing
132- --------------
131+ ## Building & Releasing
132+
133133If you wish to make changes, then building and releasing is simple:
134+
134135``` bash
135136# To build
136137mvn
@@ -148,8 +149,7 @@ git checkout ffmpeg-0.x
148149mvn clean javadoc:aggregate scm-publish:publish-scm
149150```
150151
151- Bumpings Deps
152- -----
152+ ## Bumpings Deps
153153
154154``` bash
155155# Update Maven Plugins
@@ -159,26 +159,24 @@ mvn versions:display-plugin-updates
159159mvn versions:display-dependency-updates
160160```
161161
162- Install FFmpeg on Ubuntu
163- -----------------
162+ ## Install FFmpeg on Ubuntu
164163
165164We only the support the original FFmpeg, not the libav version. Before Ubuntu 12.04, and in 15.04
166165and later the original FFmpeg is shipped. If you have to run on a version with libav, you can install
167166FFmpeg from a PPA, or using the static build. More information [ here] ( http://askubuntu.com/q/373322/34845 )
168167
169- Get involved!
170- -------------
168+ ## Get involved
171169
172170We welcome contributions. Please check the [ issue tracker] ( https://github.com/bramp/ffmpeg-cli-wrapper/issues ) .
173171If you see something you wish to work on, please either comment on the issue, or just send a pull
174172request. Want to work on something else, then just open a issue, and we can discuss! We appreciate
175173documentation improvements, code cleanup, or new features. Please be mindful that all work is done
176174on a volunteer basis, thus we can be slow to reply.
177175
178- Licence (Simplified BSD License)
179- --------------------------------
180- ```
181- Copyright (c) 2016-2022 , Andrew Brampton
176+ ## Licence (Simplified BSD License)
177+
178+ ``` plaintext
179+ Copyright (c) 2013-2024 , Andrew Brampton
182180All rights reserved.
183181
184182Redistribution and use in source and binary forms, with or without
0 commit comments