maddogandnoriko
maddogandnoriko

Reputation: 1002

Include command line in Sketchware?

I'm thinking of creating a nice gui for ffmpeg command line using Sketchware. Is it possible to add a ffmpeg build into a Sketchware project?

Upvotes: 0

Views: 885

Answers (3)

Gerges Shamon
Gerges Shamon

Reputation: 11

I did not understand your question well , But if you want cmd this class does it

public class CommandLine{
    private BufferedReader r;
    private Process p;
    private ProcessBuilder builder;
    private String LinesString = null;
    public String run(String command)throws Exception{
        
        builder = new ProcessBuilder(command.split(" "));
        builder.redirectErrorStream(true);
        p = builder.start();
        r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line = null;
        Object[] lines = r.lines().toArray();
        
        for (int i = 0; i < lines.length; i++) {
            if(LinesString == null){
                LinesString = lines[i].toString();
                
            }else{
                LinesString = LinesString + " "+lines[i].toString();
                
            }
            
        }
        return LinesString;
        
    }
}

Until you run this class :

try{

    String out = new CommandLine().run("echo hi");
} catch (Exception e) {
    
}

Upvotes: 0

iyxan23
iyxan23

Reputation: 703

I'd say kinda, you will need an arm-compiled ffmpeg (with it's library statically-linked i believe) for that, and if i'm not wrong, you can execute ffmpeg directly using Runtime.getRuntime().exec("path/to/ffmpeg -arguments");

So it goes on like this:

  • First, you'll need to include the arm-compiled ffmpeg into your app and extract it at launch at getFilesDir() directory,
  • Second, the ffmpeg needs to be chmod u+x ffmpeg-ed to allow the user to execute the binary.
  • Third, just use the above code, Runtime.getRuntime().exec("path/to/ffmpeg -arguments")

Though, I've heard some news that Android 11 is going to restrict binary execution like this.

Another note, I haven't really tried this myself, but if i have time, I'll probably update this answer.

I just found out a precompiled ffmpeg binary that is used on termux here. All you need to do is to manually change the library locaiton to the extracted library location.

Upvotes: 0

TheLSTV
TheLSTV

Reputation: 78

Well, because it's not even for android, it's quite impossible. If FFmpeg was for Android, in theory it would be possible. It is impossible to make a command line for FFmpeg in Android on Sketchware (that is, if you do not need to program any emulators;)) Probably the only option would be a Linux terminal emulator, but in Basic Sketchware I doubt it would work. Otherwise, in sketchware you can do practically anything (especially Sketchware PRO) using the ASD block (Add source directly) which allows you to upload your own code.

Summary; it is not possible. (Or very difficult)

Upvotes: -1

Related Questions