ffmpeg program doesn't running on shell script

2019-08-22 02:11发布

I code java Application and running Linux shell-script when java App running on Linux server. The linux shell-script is running. But, i need runnning ffmpeg program by shell.

  1. the ffmpeg is running with shell-script command by ./shellName.sh

  2. ffmpeg is not running with java App run by .

    • only ffmpeg command in shell.
    • working mkdir command
    • working pwd command
#!/bin/bash
echo -n "ffmpeg cmd :"
    /home/popsline/ffmpeg -i /home/popsline/sub02_chocolat.mp4 -r 0.14 -ss 00:00:20 -t 10:00:00 -vframes 10 -f image2 -y /home/popsline/img/iamges%d.png
mkdir /home/username/test
pwd

Java code.

HomeController.java refer sh.java as Object. so codes is follows:

HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 */
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! The client locale is {}.", locale);

    Sh sh = new Sh();
    sh.shRun();

    return "home";
}

sh.java

private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

public void shRun(){

    Runtime rt = Runtime.getRuntime();
    Process proc = null;
    InputStream is = null;
    BufferedReader bf = null;

    try {
        String[] cmd = {
                "/bin/sh"
                , "-c"
                , "/usr/local/bin/creaThum.sh"
        };

        proc = rt.exec(cmd);
        proc.getInputStream();
        is = proc.getInputStream();
        bf = new BufferedReader(new InputStreamReader(is));

        while (true) {
            String info = bf.readLine();
            if(info == null || info.equals("")){
                break;
            }
            logger.info("info haeyoon:: " + info);
        }
    } catch (Exception e) {
        logger.info(e.getMessage());
    }
}

0条回答
登录 后发表回答