Video compatibility issue: android recorded video not played in iphone

情到浓时终转凉″ 提交于 2021-02-07 03:01:51

问题


I am recording a video in android like this

List<Camera.Size> list =  myCamera.getParameters().getSupportedPictureSizes();
            Parameters parameters = myCamera.getParameters();
            parameters.setColorEffect(coloreffects.get(index_color_effect));
            myCamera.setParameters(parameters);
            mediaRecorder = new MediaRecorder();
            myCamera.unlock();
            mediaRecorder.setCamera(myCamera);
                mediaRecorder.setOrientationHint(90);
            mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
            mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            mediaRecorder.setAudioEncoder(AudioEncoder.HE_AAC);
            mediaRecorder.setVideoEncoder(VideoEncoder.H264);
            mediaRecorder.setOutputFile(Constants.videourl);
            mediaRecorder.setMaxDuration(30000); // Set max duration 60 sec.
            mediaRecorder.setVideoFrameRate(24);
             mediaRecorder.setVideoFrameRate(30);
             mediaRecorder.setVideoSize(720, 480);
            mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface());

this recored video and able to play in android well but unable to play on iphone.

if if use this code for recording

         // work two
         {
         mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
         mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

         mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
         mediaRecorder.setOutputFile(videourl);
         mediaRecorder.setMaxDuration(30000); // Set max duration 60 sec.
         }

THis records video compatible.with iphone well. but this records 30 seconds video about 47 mbs on samsung note2.

Any help?


回答1:


The iPhone supports video in MPEG-4 video format, and at a resolution not larger than 640x480

try this mediaRecorder.setVideoSize(640, 480);

MORE INFO: to play video on iphone

Video Format: MP4, MOV, M4V

Video Size: up to 640x480

Video Framerate: up to 30fps

Video Bitrate: up to 1.5Mbps for H.264, or 2.5Mbps for MPEG-4

Audio: AAC up to 160Kbps, 48kHz



来源:https://stackoverflow.com/questions/16038750/video-compatibility-issue-android-recorded-video-not-played-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!