Revision 9fa2835a app/src/main/java/org/witness/ssc/video/FFMPEGWrapper.java

View differences:

app/src/main/java/org/witness/ssc/video/FFMPEGWrapper.java
20 20
public class FFMPEGWrapper {
21 21

  
22 22
	Context context;
23
    FFmpeg ffmpeg;
23 24

  
24 25
	public FFMPEGWrapper(Context _context) throws FileNotFoundException, IOException {
25 26
		context = _context;
26 27

  
27
		FFmpeg ffmpeg = FFmpeg.getInstance(context);
28
		try {
28
		ffmpeg = FFmpeg.getInstance(context);
29

  
30
        try {
29 31
			ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
30 32

  
31 33
				@Override
......
54 56

  
55 57

  
56 58
	public void processVideo(
57
			ArrayList<RegionTrail> regionTrails, File inputFile, File outputFile, int frameRate, int mDuration, int mOutputLength,
59
			ArrayList<RegionTrail> regionTrails, File inputFile, File outputFile, int frameRate, float startTime, float duration,
58 60
			boolean compressVideo, int obscureVideoAmount, int obscureAudioAmount, ExecuteBinaryResponseHandler listener) throws Exception {
59 61

  
60 62
        DecimalFormat df = new DecimalFormat("####0.00");
......
65 67
        alCmds.add("-i");
66 68
        alCmds.add(inputFile.getCanonicalPath());
67 69

  
68
        if (mOutputLength > 0)
70
        if (duration > 0)
69 71
        {
72
            alCmds.add("-ss");
73
            alCmds.add(df.format(startTime));
74

  
70 75
            alCmds.add("-t");
71
            alCmds.add(mOutputLength+"");
76
            alCmds.add(df.format(duration));
72 77
        }
73 78

  
74 79
        if (frameRate > 0)
......
119 124
                if (trail.isDoTweening() && trail.getRegionCount() > 1) {
120 125
                    int timeInc = 100;
121 126

  
122
                    for (int i = 0; i < mDuration; i = i + timeInc) {
127
                    for (int i = 0; i < ((int)duration); i = i + timeInc) {
123 128
                        ObscureRegion or = trail.getCurrentRegion(i, trail.isDoTweening());
124 129
                        if (or != null) {
125 130

  
......
131 136
                            float timeStart = ((float) or.timeStamp) / 1000f;
132 137
                            float timeStop = (((float) or.timeStamp) + 100) / 1000f;
133 138

  
134
                            float timeEnd = ((float) mDuration) / 1000f;
139
                            float timeEnd = duration / 1000f;
135 140
                            timeStop = Math.max(timeStop, timeEnd);
136 141

  
137 142
                            filters.append("drawbox=x=" + x + ":y=" + y
......
184 189
        try {
185 190

  
186 191

  
187
            FFmpeg ffmpeg = FFmpeg.getInstance(context);
188 192
            // to execute "ffmpeg -version" command you just need to pass "-version"
189 193
            ffmpeg.execute(cmd,listener);
190 194
        } catch (FFmpegCommandAlreadyRunningException e) {
......
251 255

  
252 256
				
253 257
	}
254
	
258

  
259
	public FFmpeg getFFMPEG ()
260
    {
261
        return ffmpeg;
262
    }
255 263

  
256 264
}
257 265

  

Also available in: Unified diff