java - Merge multiple video file in a file -



java - Merge multiple video file in a file -

i have multiple video recorded same frame rate,and resolution.i want merge both video 1 video result file big video. using mp4 parser api , utilize below code -

movie countvideo = new moviecreator().build(channels.newchannel(muxexample.class.getresourceasstream("/count-video.mp4"))); film countaudiodeutsch = new moviecreator().build(channels.newchannel(muxexample.class.getresourceasstream("/count-deutsch-audio.mp4"))); film countaudioenglish = new moviecreator().build(channels.newchannel(muxexample.class.getresourceasstream("/count-english-audio.mp4")));

and using jar isoviewer-1.0-rc-35.jar. gives error in line -

movie countvideo = new moviecreator().build(channels.newchannel(muxexample.class.getresourceasstream("/count-video.mp4")));

at build method.it says the method build(string) in type moviecreator not applicable arguments (filechannel)

is there issue of jar.so jar have use. or other way this. please help me in solve point.

try :

i did 2 video files.

public static void main(string[] args) { string filenamevideo = "f:/testvidfol/video.mp4"; //video file on disk string filenameaudio = "f:/testvidfol/audio.wav"; //audio file on disk imediawriter mwriter = toolfactory.makewriter("f:/testvidfol/videowriter.flv"); //output file icontainer containervideo = icontainer.make(); icontainer containeraudio = icontainer.make(); if (containervideo.open(filenamevideo, icontainer.type.read, null) < 0) throw new illegalargumentexception("cant find " + filenamevideo); if (containeraudio.open(filenameaudio, icontainer.type.read, null) < 0) throw new illegalargumentexception("cant find " + filenameaudio); int numstreamvideo = containervideo.getnumstreams(); int numstreamaudio = containeraudio.getnumstreams(); system.out.println("number of video streams: "+numstreamvideo + "\n" + "number of sound streams: "+numstreamaudio ); int videostreamt = -1; //this video stream id int audiostreamt = -1; istreamcoder videocoder = null; for(int i=0; i<numstreamvideo; i++){ istream stream = containervideo.getstream(i); istreamcoder code = stream.getstreamcoder(); if(code.getcodectype() == icodec.type.codec_type_video) { videostreamt = i; videocoder = code; break; } } for(int i=0; i<numstreamaudio; i++){ istream stream = containeraudio.getstream(i); istreamcoder code = stream.getstreamcoder(); if(code.getcodectype() == icodec.type.codec_type_audio) { audiostreamt = i; break; } } if (videostreamt == -1) throw new runtimeexception("no video steam found"); if (audiostreamt == -1) throw new runtimeexception("no sound steam found"); if(videocoder.open()<0 ) throw new runtimeexception("cant open video coder"); ipacket packetvideo = ipacket.make(); istreamcoder audiocoder = containeraudio.getstream(audiostreamt).getstreamcoder(); if(audiocoder.open()<0 ) throw new runtimeexception("cant open sound coder"); mwriter.addaudiostream(0, 0, audiocoder.getchannels(), audiocoder.getsamplerate()); mwriter.addvideostream(1, 1, videocoder.getwidth(), videocoder.getheight()); ipacket packetaudio = ipacket.make(); while(containervideo.readnextpacket(packetvideo) >= 0 || containeraudio.readnextpacket(packetaudio) >= 0){ if(packetvideo.getstreamindex() == videostreamt){ //video packet ivideopicture image = ivideopicture.make(videocoder.getpixeltype(), videocoder.getwidth(), videocoder.getheight()); int offset = 0; while (offset < packetvideo.getsize()){ int bytesdecoded = videocoder.decodevideo(picture, packetvideo, offset); if(bytesdecoded < 0) throw new runtimeexception("bytesdecoded not working"); offset += bytesdecoded; if(picture.iscomplete()){ system.out.println(picture.getpixeltype()); mwriter.encodevideo(1, picture); } } } if(packetaudio.getstreamindex() == audiostreamt){ //audio packet iaudiosamples samples = iaudiosamples.make(512, audiocoder.getchannels(), iaudiosamples.format.fmt_s32); int offset = 0; while(offset<packetaudio.getsize()) { int bytesdecodedaudio = audiocoder.decodeaudio(samples, packetaudio, offset); if (bytesdecodedaudio < 0) throw new runtimeexception("could not observe audio"); offset += bytesdecodedaudio; if (samples.iscomplete()){ mwriter.encodeaudio(0, samples); } } } } }

hope help u.

java android video

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -