sucese / phoenix

The one-stop solution for taking pictures / videos, picture / video selection, editing and compression on the Android platform.
Apache License 2.0
1.62k stars 288 forks source link

部分手机压缩视频报错 #88

Open liyanglyw opened 5 years ago

liyanglyw commented 5 years ago

com.guoxiaoxing.phoenix.compress.video.engine.InvalidOutputFormatException: Non-baseline AVC video profile is not supported by Android OS, actual profile_idc: 100

byc4426 commented 4 years ago

同样错误+1

Yange820 commented 4 years ago

一样的问题

FreeManKim commented 3 years ago

MediaTranscoderEngine 148行 注释 // MediaFormatValidator.validateVideoOutputFormat(mVideoTrackTranscoder.getDeterminedFormat()); // MediaFormatValidator.validateAudioOutputFormat(mAudioTrackTranscoder.getDeterminedFormat()); 具体如下,没有深究这两行代码是什么作用 QueuedMuxer queuedMuxer = new QueuedMuxer(mMuxer, new QueuedMuxer.Listener() { @Override public void onDetermineOutputFormat() { // MediaFormatValidator.validateVideoOutputFormat(mVideoTrackTranscoder.getDeterminedFormat()); // MediaFormatValidator.validateAudioOutputFormat(mAudioTrackTranscoder.getDeterminedFormat()); } });

`class MediaFormatValidator { // Refer: http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles private static final byte PROFILE_IDC_BASELINE = 66;

public static void validateVideoOutputFormat(MediaFormat format) {
    String mime = format.getString(MediaFormat.KEY_MIME);
    // Refer: http://developer.android.com/guide/appendix/media-formats.html#core
    // Refer: http://en.wikipedia.org/wiki/MPEG-4_Part_14#Data_streams
    if (!MediaFormatExtraConstants.MIMETYPE_VIDEO_AVC.equals(mime)) {
        throw new InvalidOutputFormatException("Video codecs other than AVC is not supported, actual mime type: " + mime);
    }
    ByteBuffer spsBuffer = AvcCsdUtils.getSpsBuffer(format);
    byte profileIdc = AvcSpsUtils.getProfileIdc(spsBuffer);
    if (profileIdc != PROFILE_IDC_BASELINE) {
        throw new InvalidOutputFormatException("Non-baseline AVC video profile is not supported by Android OS, actual profile_idc: " + profileIdc);
    }
}

public static void validateAudioOutputFormat(MediaFormat format) {
    String mime = format.getString(MediaFormat.KEY_MIME);
    if (!MediaFormatExtraConstants.MIMETYPE_AUDIO_AAC.equals(mime)) {
        throw new InvalidOutputFormatException("Audio codecs other than AAC is not supported, actual mime type: " + mime);
    }
}

}`