use rich code blocks in readmes
This commit is contained in:
parent
198ab7a18d
commit
1203a3218c
@ -71,7 +71,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
`ffmpeg-kit-<package name>` pattern. Use one of the `FFmpegKit` package names given in the
|
`ffmpeg-kit-<package name>` pattern. Use one of the `FFmpegKit` package names given in the
|
||||||
project [README](https://github.com/tanersener/ffmpeg-kit).
|
project [README](https://github.com/tanersener/ffmpeg-kit).
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
@ -83,9 +83,8 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
2. Execute synchronous `FFmpeg` commands.
|
2. Execute synchronous `FFmpeg` commands.
|
||||||
|
|
||||||
```
|
```java
|
||||||
import com.arthenica.ffmpegkit.FFmpegKit;
|
import com.arthenica.ffmpegkit.FFmpegKit;
|
||||||
import com.arthenica.ffmpegkit.ReturnCode;
|
|
||||||
|
|
||||||
FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
|
FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
|
||||||
if (ReturnCode.isSuccess(session.getReturnCode())) {
|
if (ReturnCode.isSuccess(session.getReturnCode())) {
|
||||||
@ -107,7 +106,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
3. Each `execute` call (sync or async) creates a new session. Access every detail about your execution from the
|
3. Each `execute` call (sync or async) creates a new session. Access every detail about your execution from the
|
||||||
session created.
|
session created.
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
|
FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
|
||||||
|
|
||||||
// Unique session id created for this execution
|
// Unique session id created for this execution
|
||||||
@ -144,7 +143,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
4. Execute asynchronous `FFmpeg` commands by providing session specific `execute`/`log`/`session` callbacks.
|
4. Execute asynchronous `FFmpeg` commands by providing session specific `execute`/`log`/`session` callbacks.
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegKit.executeAsync("-i file1.mp4 -c:v mpeg4 file2.mp4", new ExecuteCallback() {
|
FFmpegKit.executeAsync("-i file1.mp4 -c:v mpeg4 file2.mp4", new ExecuteCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -179,7 +178,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
- Synchronous
|
- Synchronous
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFprobeSession session = FFprobeKit.execute(ffprobeCommand);
|
FFprobeSession session = FFprobeKit.execute(ffprobeCommand);
|
||||||
|
|
||||||
if (!ReturnCode.isSuccess(session.getReturnCode())) {
|
if (!ReturnCode.isSuccess(session.getReturnCode())) {
|
||||||
@ -189,7 +188,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
- Asynchronous
|
- Asynchronous
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFprobeKit.executeAsync(ffprobeCommand, new ExecuteCallback() {
|
FFprobeKit.executeAsync(ffprobeCommand, new ExecuteCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -203,7 +202,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
6. Get media information for a file.
|
6. Get media information for a file.
|
||||||
|
|
||||||
```
|
```java
|
||||||
MediaInformationSession mediaInformation = FFprobeKit.getMediaInformation("<file path or uri>");
|
MediaInformationSession mediaInformation = FFprobeKit.getMediaInformation("<file path or uri>");
|
||||||
mediaInformation.getMediaInformation();
|
mediaInformation.getMediaInformation();
|
||||||
```
|
```
|
||||||
@ -211,18 +210,18 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
7. Stop ongoing `FFmpeg` operations.
|
7. Stop ongoing `FFmpeg` operations.
|
||||||
|
|
||||||
- Stop all executions
|
- Stop all executions
|
||||||
```
|
```java
|
||||||
FFmpegKit.cancel();
|
FFmpegKit.cancel();
|
||||||
```
|
```
|
||||||
- Stop a specific session
|
- Stop a specific session
|
||||||
```
|
```java
|
||||||
FFmpegKit.cancel(sessionId);
|
FFmpegKit.cancel(sessionId);
|
||||||
```
|
```
|
||||||
|
|
||||||
8. Convert Storage Access Framework (SAF) Uris into paths that can be read or written by `FFmpegKit`.
|
8. Convert Storage Access Framework (SAF) Uris into paths that can be read or written by `FFmpegKit`.
|
||||||
- Reading a file:
|
- Reading a file:
|
||||||
|
|
||||||
```
|
```java
|
||||||
Uri safUri = intent.getData();
|
Uri safUri = intent.getData();
|
||||||
String inputVideoPath = FFmpegKitConfig.getSafParameterForRead(requireContext(), safUri);
|
String inputVideoPath = FFmpegKitConfig.getSafParameterForRead(requireContext(), safUri);
|
||||||
FFmpegKit.execute("-i " + inputVideoPath + " -c:v mpeg4 file2.mp4");
|
FFmpegKit.execute("-i " + inputVideoPath + " -c:v mpeg4 file2.mp4");
|
||||||
@ -230,7 +229,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
- Writing to a file:
|
- Writing to a file:
|
||||||
|
|
||||||
```
|
```java
|
||||||
Uri safUri = intent.getData();
|
Uri safUri = intent.getData();
|
||||||
String outputVideoPath = FFmpegKitConfig.getSafParameterForWrite(requireContext(), safUri);
|
String outputVideoPath = FFmpegKitConfig.getSafParameterForWrite(requireContext(), safUri);
|
||||||
FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 " + outputVideoPath);
|
FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 " + outputVideoPath);
|
||||||
@ -238,7 +237,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
9. Get previous `FFmpeg` and `FFprobe` sessions from session history.
|
9. Get previous `FFmpeg` and `FFprobe` sessions from session history.
|
||||||
|
|
||||||
```
|
```java
|
||||||
List<Session> sessions = FFmpegKitConfig.getSessions();
|
List<Session> sessions = FFmpegKitConfig.getSessions();
|
||||||
for (int i = 0; i < sessions.size(); i++) {
|
for (int i = 0; i < sessions.size(); i++) {
|
||||||
Session session = sessions.get(i);
|
Session session = sessions.get(i);
|
||||||
@ -256,7 +255,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
- Execute Callback, called when an async execution is ended
|
- Execute Callback, called when an async execution is ended
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegKitConfig.enableExecuteCallback(new ExecuteCallback() {
|
FFmpegKitConfig.enableExecuteCallback(new ExecuteCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -268,7 +267,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
- Log Callback, called when a session generates logs
|
- Log Callback, called when a session generates logs
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegKitConfig.enableLogCallback(new LogCallback() {
|
FFmpegKitConfig.enableLogCallback(new LogCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -280,7 +279,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
- Statistics Callback, called when a session generates statistics
|
- Statistics Callback, called when a session generates statistics
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegKitConfig.enableStatisticsCallback(new StatisticsCallback() {
|
FFmpegKitConfig.enableStatisticsCallback(new StatisticsCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -292,13 +291,13 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
|
|||||||
|
|
||||||
11. Ignore the handling of a signal. Required by `Mono` and frameworks that use `Mono`, e.g. `Unity` and `Xamarin`.
|
11. Ignore the handling of a signal. Required by `Mono` and frameworks that use `Mono`, e.g. `Unity` and `Xamarin`.
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegKitConfig.ignoreSignal(Signal.SIGXCPU);
|
FFmpegKitConfig.ignoreSignal(Signal.SIGXCPU);
|
||||||
```
|
```
|
||||||
|
|
||||||
12. Register system fonts and custom font directories.
|
12. Register system fonts and custom font directories.
|
||||||
|
|
||||||
```
|
```java
|
||||||
FFmpegKitConfig.setFontDirectoryList(context, Arrays.asList("/system/fonts", "<folder with fonts>"), Collections.EMPTY_MAP);
|
FFmpegKitConfig.setFontDirectoryList(context, Arrays.asList("/system/fonts", "<folder with fonts>"), Collections.EMPTY_MAP);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -113,23 +113,23 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
`FFmpegKit` package names given in the project [README](https://github.com/tanersener/ffmpeg-kit).
|
`FFmpegKit` package names given in the project [README](https://github.com/tanersener/ffmpeg-kit).
|
||||||
|
|
||||||
- iOS
|
- iOS
|
||||||
```
|
```yaml
|
||||||
pod 'ffmpeg-kit-ios-full', '~> 4.5'
|
pod 'ffmpeg-kit-ios-full', '~> 4.5'
|
||||||
```
|
```
|
||||||
|
|
||||||
- macOS
|
- macOS
|
||||||
```
|
```yaml
|
||||||
pod 'ffmpeg-kit-macos-full', '~> 4.5'
|
pod 'ffmpeg-kit-macos-full', '~> 4.5'
|
||||||
```
|
```
|
||||||
|
|
||||||
- tvOS
|
- tvOS
|
||||||
```
|
```yaml
|
||||||
pod 'ffmpeg-kit-tvos-full', '~> 4.5'
|
pod 'ffmpeg-kit-tvos-full', '~> 4.5'
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Execute synchronous `FFmpeg` commands.
|
2. Execute synchronous `FFmpeg` commands.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
#include <ffmpegkit/FFmpegKit.h>
|
#include <ffmpegkit/FFmpegKit.h>
|
||||||
|
|
||||||
FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v mpeg4 file2.mp4"];
|
FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v mpeg4 file2.mp4"];
|
||||||
@ -153,7 +153,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
3. Each `execute` call (sync or async) creates a new session. Access every detail about your execution from the
|
3. Each `execute` call (sync or async) creates a new session. Access every detail about your execution from the
|
||||||
session created.
|
session created.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v mpeg4 file2.mp4"];
|
FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v mpeg4 file2.mp4"];
|
||||||
|
|
||||||
// Unique session id created for this execution
|
// Unique session id created for this execution
|
||||||
@ -190,7 +190,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
4. Execute asynchronous `FFmpeg` commands by providing session specific `execute`/`log`/`session` callbacks.
|
4. Execute asynchronous `FFmpeg` commands by providing session specific `execute`/`log`/`session` callbacks.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
id<Session> session = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v mpeg4 file2.mp4" withExecuteCallback:^(id<Session> session){
|
id<Session> session = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v mpeg4 file2.mp4" withExecuteCallback:^(id<Session> session){
|
||||||
SessionState state = [session getState];
|
SessionState state = [session getState];
|
||||||
ReturnCode *returnCode = [session getReturnCode];
|
ReturnCode *returnCode = [session getReturnCode];
|
||||||
@ -214,7 +214,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
- Synchronous
|
- Synchronous
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
FFprobeSession *session = [FFprobeKit execute:ffprobeCommand];
|
FFprobeSession *session = [FFprobeKit execute:ffprobeCommand];
|
||||||
|
|
||||||
if ([ReturnCode isSuccess:[session getReturnCode]]) {
|
if ([ReturnCode isSuccess:[session getReturnCode]]) {
|
||||||
@ -224,7 +224,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
- Asynchronous
|
- Asynchronous
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
[FFprobeKit executeAsync:ffmpegCommand withExecuteCallback:^(id<Session> session) {
|
[FFprobeKit executeAsync:ffmpegCommand withExecuteCallback:^(id<Session> session) {
|
||||||
|
|
||||||
CALLED WHEN SESSION IS EXECUTED
|
CALLED WHEN SESSION IS EXECUTED
|
||||||
@ -234,7 +234,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
6. Get media information for a file.
|
6. Get media information for a file.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
MediaInformationSession *mediaInformation = [FFprobeKit getMediaInformation:"<file path or uri>"];
|
MediaInformationSession *mediaInformation = [FFprobeKit getMediaInformation:"<file path or uri>"];
|
||||||
MediaInformation *mediaInformation =[mediaInformation getMediaInformation];
|
MediaInformation *mediaInformation =[mediaInformation getMediaInformation];
|
||||||
```
|
```
|
||||||
@ -242,17 +242,17 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
7. Stop ongoing `FFmpeg` operations.
|
7. Stop ongoing `FFmpeg` operations.
|
||||||
|
|
||||||
- Stop all executions
|
- Stop all executions
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKit cancel];
|
[FFmpegKit cancel];
|
||||||
```
|
```
|
||||||
- Stop a specific session
|
- Stop a specific session
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKit cancel:sessionId];
|
[FFmpegKit cancel:sessionId];
|
||||||
```
|
```
|
||||||
|
|
||||||
8. Get previous `FFmpeg` and `FFprobe` sessions from session history.
|
8. Get previous `FFmpeg` and `FFprobe` sessions from session history.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
NSArray* sessions = [FFmpegKitConfig getSessions];
|
NSArray* sessions = [FFmpegKitConfig getSessions];
|
||||||
for (int i = 0; i < [sessions count]; i++) {
|
for (int i = 0; i < [sessions count]; i++) {
|
||||||
id<Session> session = [sessions objectAtIndex:i];
|
id<Session> session = [sessions objectAtIndex:i];
|
||||||
@ -270,7 +270,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
- Execute Callback, called when an async execution is ended
|
- Execute Callback, called when an async execution is ended
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKitConfig enableExecuteCallback:^(id<Session> session) {
|
[FFmpegKitConfig enableExecuteCallback:^(id<Session> session) {
|
||||||
...
|
...
|
||||||
}];
|
}];
|
||||||
@ -278,7 +278,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
- Log Callback, called when a session generates logs
|
- Log Callback, called when a session generates logs
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKitConfig enableLogCallback:^(Log *log) {
|
[FFmpegKitConfig enableLogCallback:^(Log *log) {
|
||||||
...
|
...
|
||||||
}];
|
}];
|
||||||
@ -286,7 +286,7 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
- Statistics Callback, called when a session generates statistics
|
- Statistics Callback, called when a session generates statistics
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKitConfig enableStatisticsCallback:^(Statistics *statistics) {
|
[FFmpegKitConfig enableStatisticsCallback:^(Statistics *statistics) {
|
||||||
...
|
...
|
||||||
}];
|
}];
|
||||||
@ -294,13 +294,13 @@ All libraries created can be found under the `prebuilt` directory.
|
|||||||
|
|
||||||
10. Ignore the handling of a signal. Required by `Mono` and frameworks that use `Mono`, e.g. `Unity` and `Xamarin`.
|
10. Ignore the handling of a signal. Required by `Mono` and frameworks that use `Mono`, e.g. `Unity` and `Xamarin`.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKitConfig ignoreSignal:SIGXCPU];
|
[FFmpegKitConfig ignoreSignal:SIGXCPU];
|
||||||
```
|
```
|
||||||
|
|
||||||
11. Register system fonts and custom font directories.
|
11. Register system fonts and custom font directories.
|
||||||
|
|
||||||
```
|
```objectivec
|
||||||
[FFmpegKitConfig setFontDirectoryList:[NSArray arrayWithObjects:@"/System/Library/Fonts", @"<folder with fonts>", nil] with:nil];
|
[FFmpegKitConfig setFontDirectoryList:[NSArray arrayWithObjects:@"/System/Library/Fonts", @"<folder with fonts>", nil] with:nil];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user