title: Use ffmpeg in android for playing video
body: <p>I am trying use ffmpeg in android. Here is the code so far. I took reference from <a href="https://github.com/WritingMinds/ffmpeg-android-java" rel="nofollow noreferrer">this</a> project. It just lets me convert video file. But I want to play a video file using ffmpeg. Is it possible? If yes then how we can do that?</p>
  
  <pre><code>    package com.ffmpeg;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.ImageView;
  
  import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler;
  import com.github.hiteshsondhi88.libffmpeg.FFmpeg;
  import com.github.hiteshsondhi88.libffmpeg.LoadBinaryResponseHandler;
  import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
  import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;
  
  import org.apache.commons.io.FileUtils;
  
  import java.io.File;
  import java.io.IOException;
  
  public class MainActivity extends AppCompatActivity {
  
  
      Boolean loadedFlag = false;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          if (!loadedFlag) {
              FFmpegInitLoader();
          }
          decodeVideo();
      }
  
      public void FFmpegInitLoader() {
          FFmpeg ffmpeg = FFmpeg.getInstance(this);
          try {
              ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
                  @Override
                  public void onStart() {
                  }
  
                  @Override
                  public void onFailure() {
                  }
  
                  @Override
                  public void onSuccess() {
                      System.out.println("Successfully loaded FFmpeg!!!");
                      loadedFlag = true;
                  }
  
                  @Override
                  public void onFinish() {
                  }
              });
          } catch (FFmpegNotSupportedException e) {
              System.out.println("Whatever....this thing is not supported :::::::::::::::::::: ");
          }
      }
  
      public void decodeVideo() {
          FFmpeg ffmpeg = FFmpeg.getInstance(this);
          try {
              ffmpeg.execute(new String[]{"-y", "-i", "/storage/sdcard0/AVSEQ02.mp4", "-c:v", "libx264", "/storage/sdcard0/conv.mp4"}, new ExecuteBinaryResponseHandler() {
                  @Override
                  public void onStart() {
                      System.out.println("FFmpeg started for decoding");
                  }
  
                  @Override
                  public void onProgress(String message) {
                      System.out.println("progress message:::: " + message);
                  }
  
                  @Override
                  public void onFailure(String message) {
                      System.out.println("failure message:::: " + message);
                  }
  
                  @Override
                  public void onSuccess(String message) {
                      System.out.println("success message:::: " + message);
                  }
  
                  @Override
                  public void onFinish() {
                  }
              });
          } catch (FFmpegCommandAlreadyRunningException e) {
              System.out.println("already running::::::");
          }
      }
  }
  </code></pre>