Quantcast
Viewing all articles
Browse latest Browse all 2052

Running ffprobe from java ProcessBuilder is failing

Sorry in advance as I'm new to linux. OS "Ubuntu 12-04-AutogenByAWSMP"

From my servlet I wish to launch ffprobe to learn info about a movie file.

From the command line this works fine. From within java this always fails with: (from error stream)

/usr/bin/ffprobe: /opt/bitnami/common/lib/libstdc++.so.6: version GLIBCXX_3.4.11' not found (required by /usr/lib/x86_64-linux-gnu/libjack.so.0) /usr/bin/ffprobe: /opt/bitnami/common/lib/libstdc++.so.6: versionGLIBCXX_3.4.9' not found (required by /usr/lib/x86_64-linux-gnu/libjack.so.0) /usr/bin/ffprobe: /opt/bitnami/common/lib/libstdc++.so.6: version GLIBCXX_3.4.15' not found (required by /usr/lib/x86_64-linux-gnu/libjack.so.0) /usr/bin/ffprobe: /opt/bitnami/common/lib/libstdc++.so.6: versionGLIBCXX_3.4.9' not found (required by /usr/lib/libopencv_core.so.2.3)

My java code is:

private static String PATH_FOR_ENV = "=/opt/bitnami/sqlite/bin:/opt/bitnami/java/bin:/opt/bitnami/php/bin:/opt/bitnami/mysql/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games";

.....

     final ProcessBuilder builder = new ProcessBuilder();

            builder.redirectErrorStream(true);
            List<String> params = createCommand("ffprobe");
            this.addFFProbeArgs(params);
            params.add(src.getAbsolutePath());
            ProcessBuilder command = builder.command(params);
            if(isLinux())
                 command.environment().put("LIBPATH", PATH_FOR_ENV);
            Process p= command.start();

            InputStream input = p.getInputStream();
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte[] bytes = new byte[1024];
            int read;
            while ((read = input.read(bytes)) != -1)
            {
                bos.write(bytes, 0, read);
            }
            input.close();
            p.waitFor();
            String info = new String(bos.toByteArray());
            System.out.println(info);

Additional helpers

private void addFFProbeArgs(List<String> pParams)
    {
        pParams.add("-v");
        pParams.add("quiet");
        pParams.add("-show_streams");
        pParams.add("-show_format");
        pParams.add("json");
    }
private List<String> createCommand(String pCommand)
    {
        List<String> commandParams = new ArrayList<String>();
        if(isLinux())
        {
            //commandParams.add("/bin/bash");
            //commandParams.add("-c");
        }
        commandParams.add(ROOT_DIR+ pCommand);
        return commandParams;
    }

private static String       ROOT_DIR = "/usr/bin/";

I know the codes not pretty (been limping along while I try and figure out the problem). I have doing lots of googling and lots of reading (including many on this site). You can see things I tried that I commented out, eg putting /bin/bash -c in front of ffprobe. Also I'm currently setting the LIBPATH to be the same as the PATH that works when I'm at the prompt (grasping @ straws).

Any thoughts? Thanks in advance.


Viewing all articles
Browse latest Browse all 2052

Trending Articles