When I execute ffmpeg command through java code then It is not executing properly
Example-:
Eu quero desenhar texto em vídeo através do código java
Meu código em java é
String cmd="ffmpeg -i 12213blob.mp4 -vf \"drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:text='Text to write':fontsize=20:fontcolor=black:x=250:y=430\" output.mp4";
System.out.println(cmd);
Process p4 = Runtime.getRuntime().exec(cmd);
p4.waitFor();
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p4.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p4.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
}
}
Quando eu executo este código, eu erro assim
Aqui está a saída padrão do comando:
Aqui está o erro padrão do comando (se houver):
ffmpeg version 2.4.git Copyright (c) 2000-2014 the FFmpeg developers
built on Sep 16 2014 18:19:21 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/home/deepak/ffmpeg_build --extra-cflags=-I/home/deepak/ffmpeg_build/include --extra-ldflags=-L/home/deepak/ffmpeg_build/lib --bindir=/home/deepak/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '12213blob.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.48.100
Duration: 00:00:09.94, start: 0.046440, bitrate: 593 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 660x500 [SAR 1:1 DAR 33:25], 493 kb/s, 42.83 fps, 42.83 tbr, 16448 tbn, 85.67 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandler
**[NULL @ 0x302bd40] Unable to find a suitable output format for 'to'
to: Invalid argument**
Mas quando eu executo este comando diretamente no terminal, ele está executando corretamente