Notice
Recent Posts
Recent Comments
Link
투케이2K
1036. (Android/Java) [간단 소스] MediaCodecList 사용해 단말기에서 지원 되는 Video Codec 코덱 종류 및 profile 정보 확인 본문
Android
1036. (Android/Java) [간단 소스] MediaCodecList 사용해 단말기에서 지원 되는 Video Codec 코덱 종류 및 profile 정보 확인
투케이2K 2025. 10. 14. 19:07728x90
반응형
[개발 환경 설정]
개발 툴 : AndroidStudio
개발 언어 : Java / Kotlin

[소스 코드]
// --------------------------------------------------------------------------------------
[개발 및 테스트 환경]
// --------------------------------------------------------------------------------------
- 언어 : Java / Kotlin
- 개발 툴 : AndroidStudio
- 기술 구분 : MediaCodecList / Codec / Video / Profile
- 사전) 코덱 설명 정리 :
>> 코덱 이란? 음성 또는 영상의 신호 (Analog) 를 디지털 신호로 변환하는 코더와 그 반대로 변환시켜 주는 디코더의 기능을 함께 갖춘 기술 집합체 입니다
>> 코덱은 음성이나 비디오 데이터를 컴퓨터가 처리할 수 있게 디지털로 바꿔 주고, 그 데이터를 컴퓨터 사용자가 알 수 있게 모니터에 본래대로 재생시켜 줍니다
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[소스 코드]
// --------------------------------------------------------------------------------------
try {
MediaCodecList codecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
MediaCodecInfo[] codecs = codecList.getCodecInfos();
for (MediaCodecInfo codecInfo : codecs) {
if (!codecInfo.isEncoder()) {
try {
MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType("video/avc");
S_Log.d("KWON_TWOK", "Codec : " + codecInfo.getName());
if (capabilities.profileLevels != null && capabilities.profileLevels.length > 0){
for (int i=0; i<capabilities.profileLevels.length; i++){
String profileLevelId = "";
MediaCodecInfo.CodecProfileLevel profileLevel = capabilities.profileLevels[i];
// TODO [profile_idc (첫 바이트)]
int profile = profileLevel.profile;
if (profile == 1){
profileLevelId = "42"; // profile_idc (hex) : Baseline
}
else if (profile == 2){
profileLevelId = "4D"; // profile_idc (hex) : Main
}
else if (profile == 8){
profileLevelId = "64"; // profile_idc (hex) : High
}
else if (profile == 524288){ // profile_idc (hex) : Constrained Baseline : PROFILE_CONSTRAINED_BASELINE (Android에서 일부 디코더만 지원)
profileLevelId = "42"; // profile_idc (hex) : High
}
else { // 65536 : Unknown or Vendor-specific : 정의되지 않은 값 (일부 디코더에서 커스텀 프로파일로 사용됨)
profileLevelId = "Unknown";
}
// TODO [profile_iop (두 번째 바이트)]
if (profile == 1){
profileLevelId += " E0"; // profile_idc (hex) : Baseline
}
else if (profile == 2){
profileLevelId += " 00"; // profile_idc (hex) : Main
}
else if (profile == 8){
profileLevelId += " 00"; // profile_idc (hex) : High
}
else if (profile == 524288){ // profile_idc (hex) : Constrained Baseline : PROFILE_CONSTRAINED_BASELINE (Android에서 일부 디코더만 지원)
profileLevelId += " C0"; // profile_idc (hex) : High
}
else { // 65536 : Unknown or Vendor-specific : 정의되지 않은 값 (일부 디코더에서 커스텀 프로파일로 사용됨)
profileLevelId += " Unknown";
}
// TODO [level_idc (세 번째 바이트)]
int level = profileLevel.level;
if (level == 1){
profileLevelId += " 0A"; // (hex) Level 1.0
}
else if (level == 2){
profileLevelId += " 09"; // (hex) Level 1b
}
else if (level == 4){
profileLevelId += " 0B"; // (hex) Level 1.1
}
else if (level == 8){
profileLevelId += " 0C"; // (hex) Level 1.2
}
else if (level == 16){
profileLevelId += " 0D"; // (hex) Level 1.3
}
else if (level == 32){
profileLevelId += " 14"; // (hex) Level 2.0
}
else if (level == 64){
profileLevelId += " 15"; // (hex) Level 2.1
}
else if (level == 128){
profileLevelId += " 16"; // (hex) Level 2.2
}
else if (level == 256){
profileLevelId += " 1E"; // (hex) Level 3.0
}
else if (level == 512){
profileLevelId += " 1F"; // (hex) Level 3.1
}
else if (level == 1024){
profileLevelId += " 20"; // (hex) Level 3.2
}
else if (level == 65536){
profileLevelId += " 28"; // (hex) Level 4.0
}
else if (level == 131072){
profileLevelId += " 29"; // (hex) Level 4.1
}
else if (level == 196608){
profileLevelId += " 2A"; // (hex) Level 4.2
}
else if (level == 262144){
profileLevelId += " 32"; // (hex) Level 5.0
}
else if (level == 327680){
profileLevelId += " 33"; // (hex) Level 5.1
}
else if (level == 393216){
profileLevelId += " 34"; // (hex) Level 5.2
}
else {
profileLevelId += " Unknown";
}
S_Log.w("KWON_TWOK", "Profile : " + String.valueOf(profile) + " / Level : " + String.valueOf(level) + " / ProfileLevelId : " + profileLevelId);
}
}
else {
S_Log.e("KWON_TWOK", "Error : capabilities.profileLevels is null");
}
}
catch (IllegalArgumentException e) {
S_Log.e("KWON_TWOK", "IllegalArgumentException : Continue");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}
catch (Exception e){
e.printStackTrace();
}
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[참고 사이트]
// --------------------------------------------------------------------------------------
[투케이 학습] : 영상 코덱 (Video Codec) , 오디오 코덱 (Audio Codec) 학습
https://blog.naver.com/kkh0977/223185410944?trackingCode=blog_bloghome_searchlist
[Aws Kinesis Video Streams] Aws KVS WebRTC 실시간 비디오 영상 재생 관련 비디오 및 오디오 코덱 정리
https://blog.naver.com/kkh0977/223874463131?trackingCode=blog_bloghome_searchlist
[간단 소스] 자바스크립트 WebRTC RTCPeerConnection getReceivers 사용해 현재 설정 된 Codec 코덱 정보 확인
https://blog.naver.com/kkh0977/224028713113?trackingCode=blog_bloghome_searchlist
[간단 소스] 자바스크립트 WebRTC RTCPeerConnection 에서 Codec 코덱 타입 강제 설정 - setCodecPreferences
https://blog.naver.com/kkh0977/224027967755?trackingCode=blog_bloghome_searchlist
[업무 이슈] AWS WebRTC 뷰어 재생 시 sdpAnswer 정보로 내려온 것과 다른 peerConnection Codec 코덱 정보 표시 이슈
https://blog.naver.com/kkh0977/224027971052?trackingCode=blog_bloghome_searchlist
// --------------------------------------------------------------------------------------
728x90
반응형
'Android' 카테고리의 다른 글
Comments
