Video plays upside down when recorded from Front Camera in Android -
i doing android video camera application. should have capability of recording , front camera. done camera , fine. when record front camera, video plays upside down. have play videos recorded in application itself. using videoview, how set orientation or make play correctly?. video when played in default media player playing upside down. tried sending video iphone , checked still plays upside down. have setorientationhint mediarecorder no solution.
all code similar agargenta's video capture demo in have done customization.
issues seems strange , struck.
this.mediarecorder = new mediarecorder(); this.mediarecorder.setcamera(this.mcamera); this.mediarecorder.setaudiosource(mediarecorder.audiosource.camcorder); this.mediarecorder.setvideosource(mediarecorder.videosource.camera); if (build.version.sdk_int <= 10) { camcorderprofile camcorderprofile = camcorderprofile .get(camcorderprofile.quality_high); camcorderprofile.videoframewidth = 320; camcorderprofile.videoframeheight = 480; // camcorderprofile.videoframerate = 15; camcorderprofile.videocodec = mediarecorder.videoencoder.h264; // camcorderprofile.audiocodec = mediarecorder.audioencoder.default; camcorderprofile.fileformat = mediarecorder.outputformat.mpeg_4; this.mediarecorder.setprofile(camcorderprofile); mediarecorder.setorientationhint(90); } else { if (tgbswitchcamera.ischecked()) { mediarecorder .setoutputformat(mediarecorder.outputformat.mpeg_4); // mediarecorder.setvideosize(320, 480); mediarecorder.setaudioencoder(mediarecorder.audioencoder.aac); mediarecorder.setvideoencoder(mediarecorder.videoencoder.h264); camerainfo camerainfo = new camerainfo(); camera.getcamerainfo(camerainfo.camera_facing_front, camerainfo); rotation = (camerainfo.orientation - 180 + 360) % 360; mediarecorder.setorientationhint(rotation); } else { camcorderprofile camcorderprofile = camcorderprofile .get(camcorderprofile.quality_low); camcorderprofile.videoframewidth = 640; camcorderprofile.videoframeheight = 480; camcorderprofile.videocodec = mediarecorder.videoencoder.h264; // camcorderprofile.audiocodec = // mediarecorder.audioencoder.default; camcorderprofile.fileformat = mediarecorder.outputformat.mpeg_4; this.mediarecorder.setprofile(camcorderprofile); mediarecorder.setorientationhint(90); } } this.mediarecorder.setoutputfile(this.initfile().getabsolutepath()); this.mediarecorder.setpreviewdisplay(mpreview.getholder().getsurface()); try { this.mediarecorder.prepare(); // start actual recording // throws illegalstateexception if not prepared handler h = new handler(); h.postdelayed(new runnable() { @override public void run() { this.mediarecorder.start(); pgv.setstart(true); pgv.invalidate(); countdowntimer cdt = new countdowntimer(5000, 1000) { @override public void ontick(long millisuntilfinished) { } @override public void onfinish() { if (isrecording) { handler.removemessages(stop); stoprecording(); } } }; cdt.start(); } }, 1000); // enable stop button indicating recording } catch (exception e) { toast.maketext(this, "cannot record", toast.length_short).show(); e.printstacktrace(); this.releasemediarecorder(); }
this line rotate video 180 degrees:
rotation = (camerainfo.orientation - 180 + 360) % 360;
unless have reason doing i'm not seeing, that's why video upside-down.
Comments
Post a Comment