java - FFMPEG Create internal pipeline for adding raw frames to AVI file (no input file) -


i have application reads in raw video file, image processing each frame, feeds resulting bgra-format byte[] frames ffmpeg container create avi file. since process works differently other ffmpeg example i've seen in not have existing input file, i'm wondering if knows how this.

i initialize ffmpeg container:

processbuilder pbuilder = new processbuilder(raid.getlocation()                 + "\\ffmpeg\\bin\\ffmpeg.exe", "-r", "30", "-vcodec",                 "rawvideo", "-f", "rawvideo", "-pix_fmt", "bgra", "-s",                 size, "-i", "pipe:0", "-r", "30", "-y", "-c:v", "libx264",                 "c:\export\2015-02-03\1500\export6.avi");   try  {      process = pbuilder.start();  }  catch (ioexception e)  {      e.printstacktrace();  }    ffmpeginput = process.getoutputstream(); 

for each incoming byte[] array frame, add frame container ("src" bufferedimage i'm converting byte array):

try {      bytearrayoutputstream baos = new bytearrayoutputstream();      imageio.write(src, ".png", baos);      ffmpeginput.write(baos.tobytearray()); } catch (ioexception e) {      e.printstacktrace(); } 

and once video finished loading frames, close container:

try {      ffmpeginput.flush();      ffmpeginput.close(); } catch (ioexception e) {      e.printstacktrace(); } 

the avi file created displays error when opening. ffmpeg logger displays error:

ffmpeg version n-71102-g1f5d1ee copyright (c) 2000-2015 ffmpeg developers built gcc 4.9.2 (gcc)   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib   libavutil      54. 20.101 / 54. 20.101   libavcodec     56. 30.100 / 56. 30.100   libavformat    56. 26.101 / 56. 26.101   libavdevice    56.  4.100 / 56.  4.100   libavfilter     5. 13.101 /  5. 13.101   libswscale      3.  1.101 /  3.  1.101   libswresample   1.  1.100 /  1.  1.100   libpostproc    53.  3.100 / 53.  3.100 input #0, rawvideo, 'pipe:0':   duration: n/a, bitrate: 294912 kb/s     stream #0:0: video: rawvideo (bgra / 0x41524742), bgra, 640x480, 294912 kb/s, 30 tbr, 30 tbn, 30 tbc no pixel format specified, yuv444p h.264 encoding chosen. use -pix_fmt yuv420p compatibility outdated media players. [libx264 @ 00000000003bcbe0] using cpu capabilities: mmx2 sse2fast ssse3 sse4.2 [libx264 @ 00000000003bcbe0] profile high 4:4:4 predictive, level 3.0, 4:4:4 8-bit output #0, avi, 'c:\export\2015-02-03\1500\export6.avi':   metadata:     isft            : lavf56.26.101     stream #0:0: video: h264 (libx264) (h264 / 0x34363248), yuv444p, 640x480, q=-1--1, 30 fps, 30 tbn, 30 tbc     metadata:       encoder         : lavc56.30.100 libx264 stream mapping:   stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) frame=    0 fps=0.0 q=0.0 lsize=       6kb time=00:00:00.00 bitrate=n/a     video:0kb audio:0kb subtitle:0kb other streams:0kb global headers:0kb muxing overhead: unknown output file empty, nothing encoded (check -ss / -t / -frames parameters if used) 

any insight or ideas appreciated!

replace processbuilder content this:

new processbuilder(pathofyourffmpeg, "-r", "30", "-s", sizeofyourframe, "-vcodec", "rawvideo", "-f", "rawvideo", "-pix_fmt", "bgra", "-i", "pipe:0", "-r", "30", pathandfileextention); 

basically, saying input frames coming in @ 30 fps, codec , format rawvideo , pixel format "bgra" (spelling important here. misspelled , took me work day figure out). input pipe:0. (e.g. 0 stdin, 1 stdout, 2 stderr). confusing part on java side, have "outputstream" process , pass frame data (byte []) stdin ffmpeg. confused uh?

finally, redefined -r , "30" again. not mistake. things before -i input , things defined after -i output! in here i'm saying output video 30 fps well. hope helps!!!

ps: tried pass byte[] queue , array list cache. reasons, java caches 1 copy on , over. time figure out, half day has passed. check frame data before passing ffmpeg.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -