Skip to content

Error is no such file or directory with android ffmpeg java #115

Description

@mayursancheti

i am using below code, which loads ffmpeg successfully, only command not executing, error is no such file or directory. how can i remove this error.

`package com.example.project;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

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 java.io.File;

public class MainActivity extends AppCompatActivity {

FFmpeg ffmpeg;
String TAG;
EditText editTextEmail;
String outputpath;
String[] command;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    editTextEmail = findViewById(R.id.editTextEmail1);

    loadFFMpegBinary();

   outputpath = Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator + Environment.DIRECTORY_MOVIES + "/" + "outputvideo.mp4";


   //String outputpath = "/storage/emulated/0/Pictures/outputvideo.mp4";


   Log.d(TAG,"hhhhh "+outputpath);

    command = new String[]{"-i", '"' + editTextEmail.getText().toString() + '"', "-vf", "drawtext=text='Author':fontfile=/storage/emulated/0/Movies/Avenir-Medium.ttf:fontcolor=white:fontsize=32:x=10:y=H-th-10", "-preset", "ultrafast", '"' + outputpath + '"'};

    //"-y -i "+editTextEmail.getText()+" -vf drawtext=fontsize=50:fontfile=cute.ttf:text='TEST MAYUR':x=w-tw-10:y=h-th-10 -c:v libx264 -preset ultrafast "+outputpath

    Button loginButtonSignup = findViewById(R.id.buttonSignup);
    loginButtonSignup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            execFFmpegBinary(command);
        }
    });

}
private void loadFFMpegBinary() {
    if(ffmpeg==null)
    {
        ffmpeg = FFmpeg.getInstance(getApplicationContext());
        try {
            ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

                @Override
                public void onStart() {}

                @Override
                public void onFailure() {
                    Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onSuccess() {
                    Toast.makeText(getApplicationContext(), "Success "+command, Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onFinish() {}
            });
        } catch (FFmpegNotSupportedException e) {
            e.printStackTrace();
        }
    }
}

private void execFFmpegBinary(final String[] command1) {
    try {
        ffmpeg.execute(command1, new ExecuteBinaryResponseHandler() {
            @Override public void onFailure(String s) {
                Log.d(TAG, "FAILED with output : " + s);
                Toast.makeText(getApplicationContext(), "failed output "+s, Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onSuccess(String s) {
                Log.d(TAG, "SUCCESS with output : " + s); //Perform action on success
                Toast.makeText(getApplicationContext(), "succcess output "+s, Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onProgress(String s) {
                Log.d(TAG, "progress : " + s);

            }
            @Override public void onStart() {
                Log.d(TAG, "Started command : ffmpeg " + command1);
                Toast.makeText(getApplicationContext(), "Started command "+command1, Toast.LENGTH_SHORT).show();

            }
            @Override public void onFinish() {
                Log.d(TAG, "Finished command : ffmpeg " + command1);
                //Toast.makeText(MainActivity.this, "Finished commeda", Toast.LENGTH_SHORT).show();
            }
        });
    }

    catch (FFmpegCommandAlreadyRunningException e) {
        Toast.makeText(this, ""+e, Toast.LENGTH_SHORT).show();
    }

}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions