html5 - How to merge audio and video file in android -
thanks great mp4parser lib, have few queries related audio video muxing.
we used below code in android , tried, not getting expected output, have kept working mp4 file in specific directory , trying no luck.
here merged audio , video, audio gets appended video. , appended audio not play increases width of video.
any geeks.
here code,
file sdcard = environment.getdatadirectory(); string videofilepath = environment.getexternalstoragedirectory().tostring()+"/video.mp4"; string audiofilepath = environment.getexternalstoragedirectory().tostring()+"/audio.aac"; file file=new file(videofilepath); h264trackimpl h264track = new h264trackimpl(new filedatasourceimpl(videofilepath)); aactrackimpl aactrack = new aactrackimpl(new filedatasourceimpl(audiofilepath)); movie movie = new movie(); movie.addtrack(h264track); movie.addtrack(aactrack); container mp4file = new defaultmp4builder().build(movie); filechannel fc = new fileoutputstream(new file(environment.getexternalstoragedirectory().tostring() + "/video.mp4")).getchannel(); mp4file.writecontainer(fc); fc.close();
it seems problem output file name input. try change name of output file.
filechannel fc = new fileoutputstream(new file(environment.getexternalstoragedirectory().tostring() + "/video_out.mp4")).getchannel();
Comments
Post a Comment