user1812668
user1812668

Reputation: 83

Escape character "|" error (Linux command)

I'm trying to run a Linux command in Java.

This is the command:

"ffmpeg -i rtmp://192.168.1.112/garage/stream26g -f mpegts -acodec libmp3lame -ar 48000 -ab 64000 -s 480x320 -r 30 -vcodec libx264 -b 544k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 2 -refs 0 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 544k -bufsize 544k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 30 -qdiff 4 -level 30 -aspect 480:320 -g 30 -async 2 - | vod - 10 stream/stream26g/sample stream/stream26g/stream.m3u8 http://www.tshizerbia.com//video/ 5";

But it gives me an error:

Unable to find a suitable output format for |

And I don't know what is the problem

I used this to run the command

Process p = Runtime.getRuntime().exec(command);

If I put \\| in the string the message error is:

Unable to find a suitable output format for \|

How can I escape this character? Any ideas?

Upvotes: 2

Views: 1565

Answers (4)

Steinar
Steinar

Reputation: 5950

The pipe "|" is shell specific. Try executing it through a shell instead, something like

String[] bashCommand = {"/bin/bash", "-c", command};

and execute this bashCommand instead.

Upvotes: 1

rgettman
rgettman

Reputation: 178263

Try quoting the pipe character. I don't think it needs to be Java-escaped; I think it needs to be shell-quoted. Of course then you'll have to Java-escape the double-quote characters:

...-async 2 - \"|\" vod - 10 ...

Upvotes: 1

fcm
fcm

Reputation: 6463

Try escaping it with \\|. Works for Java, but I'm not sure specifically for linux command as you're asking.

Upvotes: 0

1218985
1218985

Reputation: 8012

Process p = Runtime.getRuntime().exec("ffmpeg -i rtmp://192.168.1.112/garage/stream26g -f mpegts -acodec libmp3lame -ar 48000 -ab 64000 -s 480x320 -r 30 -vcodec libx264 -b 544k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 2 -refs 0 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 544k -bufsize 544k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 30 -qdiff 4 -level 30 -aspect 480:320 -g 30 -async 2 - \\| vod - 10 stream/stream26g/sample stream/stream26g/stream.m3u8 http://www.tshizerbia.com//video/ 5");

Upvotes: 0

Related Questions