Skip to content

Commit 117785f

Browse files
Updated README
1 parent 09ae47d commit 117785f

File tree

4 files changed

+61
-17
lines changed

4 files changed

+61
-17
lines changed

FFmpegAndroid/src/main/java/github/hiteshsondhi88/libffmpeg/FFmpeg.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import android.content.Context;
44
import android.text.TextUtils;
55

6-
import org.apache.http.NameValuePair;
7-
8-
import java.util.List;
6+
import java.util.Map;
97

108
import github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
119
import github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;
@@ -63,7 +61,7 @@ public void loadBinary(FFmpegLoadBinaryResponseHandler ffmpegLoadBinaryResponseH
6361
}
6462

6563
@Override
66-
public void execute(List<NameValuePair> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
64+
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
6765
if (ffmpegExecuteAsyncTask != null && !ffmpegExecuteAsyncTask.isProcessCompleted()) {
6866
throw new FFmpegCommandAlreadyRunningException("FFmpeg command is already running, you are only allowed to run single command at a time");
6967
}

FFmpegAndroid/src/main/java/github/hiteshsondhi88/libffmpeg/FFmpegInterface.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package github.hiteshsondhi88.libffmpeg;
22

3-
import org.apache.http.NameValuePair;
4-
5-
import java.util.List;
3+
import java.util.Map;
64

75
import github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
86
import github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;
@@ -24,7 +22,7 @@ interface FFmpegInterface {
2422
* @param ffmpegExecuteResponseHandler {@link github.hiteshsondhi88.libffmpeg.FFmpegExecuteResponseHandler}
2523
* @throws FFmpegCommandAlreadyRunningException
2624
*/
27-
public void execute(List<NameValuePair> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
25+
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
2826

2927
/**
3028
* Executes a command

FFmpegAndroid/src/main/java/github/hiteshsondhi88/libffmpeg/FileUtils.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
import android.content.Context;
44
import android.util.Log;
55

6-
import org.apache.http.NameValuePair;
7-
86
import java.io.File;
97
import java.io.FileOutputStream;
108
import java.io.IOException;
119
import java.io.InputStream;
12-
import java.util.List;
10+
import java.util.Map;
1311

1412
class FileUtils {
1513

@@ -55,11 +53,11 @@ static String getFFmpeg(Context context) {
5553
return getFilesDirectory(context).getAbsolutePath() + File.separator + FileUtils.ffmpegFileName;
5654
}
5755

58-
static String getFFmpeg(Context context, List<NameValuePair> environmentVars) {
56+
static String getFFmpeg(Context context, Map<String,String> environmentVars) {
5957
String ffmpegCommand = "";
6058
if (environmentVars != null) {
61-
for (NameValuePair var : environmentVars) {
62-
ffmpegCommand += var.getName()+"="+var.getValue()+" ";
59+
for (Map.Entry<String, String> var : environmentVars.entrySet()) {
60+
ffmpegCommand += var.getKey()+"="+var.getValue()+" ";
6361
}
6462
}
6563
ffmpegCommand += getFFmpeg(context);

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,59 @@ Supported Architecture
1010
* armv7-neon
1111
* x86
1212

13-
Instructions
14-
----
15-
* TODO
13+
## Usage
14+
15+
### Load Binary
16+
17+
```java
18+
FFmpeg ffmpeg = FFmpeg.getInstance(context);
19+
try {
20+
ffmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
21+
22+
@Override
23+
public void onStart() {}
24+
25+
@Override
26+
public void onFailure() {}
27+
28+
@Override
29+
public void onSuccess() {}
30+
31+
@Override
32+
public void onFinish() {}
33+
});
34+
} catch (FFmpegNotSupportedException e) {
35+
// Handle if FFmpeg is not supported by device
36+
}
37+
```
38+
39+
### Execute Binary
40+
41+
```java
42+
FFmpeg ffmpeg = FFmpeg.getInstance(context);
43+
try {
44+
// to execute "ffmpeg -version" command you just need to pass "-version"
45+
ffmpeg.execute(cmd, new FFmpegExecuteResponseHandler() {
46+
47+
@Override
48+
public void onStart() {}
49+
50+
@Override
51+
public void onProgress(String message) {}
52+
53+
@Override
54+
public void onFailure(String message) {}
55+
56+
@Override
57+
public void onSuccess(String message) {}
58+
59+
@Override
60+
public void onFinish() {}
61+
});
62+
} catch (FFmpegCommandAlreadyRunningException e) {
63+
// Handle if FFmpeg is already running
64+
}
65+
```
1666

1767
License
1868
----

0 commit comments

Comments
 (0)