Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video codec not supported #2

Closed
FidanBacaj opened this issue Aug 2, 2018 · 3 comments
Closed

video codec not supported #2

FidanBacaj opened this issue Aug 2, 2018 · 3 comments
Labels
question Further information is requested

Comments

@FidanBacaj
Copy link

When I make a video with this library ( com.github.duanhong169:camera:1.0.3 ) and when i click to play this video ,video not played just voice and writes "video codec not supported"

Can you help me for this problem how to fix ?

@duanhong169
Copy link
Owner

Hi @FidanBacaj :

You can find the default video recorder config here:

private void setUpMediaRecorder(MediaRecorderConfigurator configurator) throws IOException {
if (configurator == null || configurator.useDefaultConfigs()) {
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setOutputFile(nextVideoAbsolutePath);
mediaRecorder.setVideoEncodingBitRate(10000000);
mediaRecorder.setVideoFrameRate(30);
mediaRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
}
if (configurator != null) {
configurator.configure(mediaRecorder);
}
mediaRecorder.setOrientationHint(Utils.getOrientation(sensorOrientation, currentDeviceRotation));
mediaRecorder.prepare();
}

As you can see, the default video format & codec is:

mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

So the problem is that the video player your phone provided may not support the H264 codec, so it cannot play the video for you.

There are two ways to solve the issue:

  1. Install a video player which support the H264 codec.
  2. Configure the video codec by passing in a Photographer.MediaRecorderConfigurator object when you calling Photographer.startRecording(MediaRecorderConfigurator configurator), and set another video codec which your currently using video player supported:
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263); // for example

You may find these two classes helpful:

@duanhong169 duanhong169 added the question Further information is requested label Aug 3, 2018
@FidanBacaj
Copy link
Author

Thank you @duanhong169 for quick answer !

@duanhong169
Copy link
Owner

duanhong169 commented Aug 3, 2018

@FidanBacaj Always welcome!
BTW, it will be fine if you give this project a star, then more people can reach here! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants