phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

部分手机压缩视频报错

Open liyanglyw opened this issue 5 years ago • 3 comments

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

liyanglyw avatar Feb 22 '19 09:02 liyanglyw

同样错误+1

byc4426 avatar Feb 20 '20 06:02 byc4426

一样的问题

Yange820 avatar Mar 26 '20 05:03 Yange820

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);
    }
}

}`

FreeManKim avatar Jan 06 '21 05:01 FreeManKim