Skip to content

avcodec_open2() error -542398533: Could not open video codec. #2373

@zhangyu007

Description

@zhangyu007

MainActivity.java

Hello, I have a question to ask. MainActivity.java is implemented based on the JavaCV library, with version number 1.5.12.

The Gradle code is as follows:

The OpenCV FrameGrabber method calls the camera of an Android phone and captures frame data, which is then passed to the FFmpeg FrameRecorder method and streamed via rtmp. However, an error occurs during runtime: avcodec_open2() error -542398533: Could not open video codec.

The specific log content is as follows:

---------------------------- PROCESS STARTED (14009) for package com.example.demo ----------------------------
2026-01-08 15:32:50.105 14009-14034 ActivityThread com.example.demo I Init compatible state: true
2026-01-08 15:32:50.113 14009-14034 HwFramewor...rtsFactory com.example.demo D HwFrameworkSecurityPartsFactory in.
2026-01-08 15:32:50.114 14009-14034 HwFramewor...rtsFactory com.example.demo I add HwFrameworkSecurityPartsFactory to memory.
2026-01-08 15:32:50.114 14009-14034 BehaviorCollectManager com.example.demo D hook process for AI virus second
2026-01-08 15:32:50.117 14009-14009 ApplicationLoaders com.example.demo D createClassLoader zip: /data/app/com.example.demo-FzXbHmfk9qiWqJlarGwg4A==/base.apk librarySearchPath: /data/app/com.example.demo-FzXbHmfk9qiWqJlarGwg4A==/lib/arm64:/data/app/com.example.demo-FzXbHmfk9qiWqJlarGwg4A==/base.apk!/lib/arm64-v8a libraryPermittedPath: /data/user/0/com.example.demo parent: java.lang.BootClassLoader@376e716 targetSdkVersion: 36 isBundled: false classLoaderName: null sharedLibraries: null
2026-01-08 15:32:50.117 14009-14034 BehaviorCollectManager com.example.demo I bindAnalyzerService: huawei.android.security.IAppBehaviorDataAnalyzer$Stub$Proxy@99cfd6a pid:14009
2026-01-08 15:32:50.118 14009-14038 RtgSchedEvent com.example.demo I mRtgVideoEnable:false
2026-01-08 15:32:50.208 14009-14034 HwApiCacheMangerEx com.example.demo I apicache path=/storage/emulated/0 state=mounted key=com.example.demo#10175#256
2026-01-08 15:32:50.208 14009-14034 HwApiCacheMangerEx com.example.demo I need clear apicache,because volumes changed,oldCnt=0 newCnt=1
2026-01-08 15:32:50.223 14009-14009 HwTypeface com.example.demo I updateFont: scale=1.0
2026-01-08 15:32:50.224 14009-14009 SystemFonts com.example.demo D areFontsVariable: script=Hans
2026-01-08 15:32:50.224 14009-14009 ActivityThread com.example.demo I finishPreloaded preloadStatus 0
2026-01-08 15:32:50.224 14009-14009 RmeSchedManager com.example.demo I init Rme, version is: v1.0
2026-01-08 15:32:50.224 14009-14034 HwApiCacheMangerEx com.example.demo I apicache path=/storage/emulated/0 state=mounted key=com.example.demo#10175#0
2026-01-08 15:32:50.224 14009-14009 RmeSchedManager com.example.demo I init Rme, version is: v1.0
2026-01-08 15:32:50.224 14009-14034 HwApiCacheMangerEx com.example.demo I need clear apicache,because volumes changed,oldCnt=1 newCnt=1
2026-01-08 15:32:50.228 14009-14009 OpenGLRenderer com.example.demo D disableOutlineDraw is true
2026-01-08 15:32:50.233 14009-14034 AwareBitmapCacher com.example.demo I init processName:com.example.demo pid=14009 uid=10175
2026-01-08 15:32:50.238 14009-14058 OpenGLRenderer com.example.demo I RenderThread: progress name = [com.example.demo], viewCornerType = 0
2026-01-08 15:32:50.239 14009-14063 iGraphics com.example.demo I [0020080c] pn: com.example.demo, p: 14009
2026-01-08 15:32:50.239 14009-14063 iGraphics com.example.demo I [0030080c] no spt app: com.example.demo
2026-01-08 15:32:50.247 14009-14061 AwareLog com.example.demo E AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@8a7951a
2026-01-08 15:32:50.265 14009-14009 AppCompatDelegate com.example.demo D Checking for metadata for AppLocalesMetadataHolderService : Service not found
2026-01-08 15:32:50.274 14009-14009 ActivityThread com.example.demo V callActivityOnCreate
2026-01-08 15:32:50.322 14009-14009 DecorView[] com.example.demo I pkgName:com.example.demo old windowMode:0 new windoMode:1, isFixedSize:false
2026-01-08 15:32:50.337 14009-14009 om.example.dem com.example.demo W Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2026-01-08 15:32:50.338 14009-14009 om.example.dem com.example.demo W Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2026-01-08 15:32:50.402 14009-14009 System.err com.example.demo W Warning: Version of org.bytedeco:ffmpeg could not be found.
2026-01-08 15:32:50.461 14009-14009 System.err com.example.demo W Warning: Version of org.bytedeco:openblas could not be found.
2026-01-08 15:32:50.464 14009-14009 System.err com.example.demo W Warning: Version of org.bytedeco:opencv could not be found.
2026-01-08 15:32:50.870 14009-14009 ActivityThread com.example.demo D add activity client record, r= ActivityRecord{3df919f token=android.os.BinderProxy@b089ea4 {com.example.demo/com.example.demo.MainActivity}} token= android.os.BinderProxy@b089ea4
2026-01-08 15:32:50.875 14009-14009 HwPartMagi...dowFactory com.example.demo I add android.common.HwPartMagicWindowFactoryImpl to memory.
2026-01-08 15:32:50.880 14009-14009 MouseWheelSynthesizer com.example.demo D mMoveStepInDp: 64, mMoveStepInPixel: 163, mUpTimeDelayed: 100
2026-01-08 15:32:50.880 14009-14009 ViewRootImpl com.example.demo D ViewRootImpl mIsInProductivePCDisplay: false
2026-01-08 15:32:50.881 14009-14009 HwPartPowe...iceFactory com.example.demo I add HwPartPowerOfficeFactoryImpl to memory.
2026-01-08 15:32:50.886 14009-14009 InputEventReceiver com.example.demo D dispatchInputInterval 1000000
2026-01-08 15:32:50.888 14009-14009 RmeSchedManager com.example.demo I init Rme, version is: v1.0
2026-01-08 15:32:50.888 14009-14009 Choreographer com.example.demo I Skipped 39 frames! The application may be doing too much work on its main thread.
2026-01-08 15:32:50.888 2581-3104 DollieAdapterService com.huawei.systemserver E notifyActivityState pkg:com.example.demo/com.example.demo.MainActivity state:2 fg:true mUid:10175
2026-01-08 15:32:50.904 14009-14094 HiTouch_Pr...reDetector com.example.demo D onAttached, package=com.example.demo, windowType=1, mIsHiTouchRestricted=false
2026-01-08 15:32:50.916 14009-14058 mali_winsys com.example.demo D EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
2026-01-08 15:32:50.919 14009-14058 Gralloc3 com.example.demo W mapper 3.x is not supported
2026-01-08 15:32:50.920 14009-14093 libc com.example.demo E Access denied finding property "ro.kirin.product.platform"
2026-01-08 15:32:50.920 14009-14093 HwExtendedCodec com.example.demo W The mime is not in hisi extended mime.
2026-01-08 15:32:50.939 14009-14117 OMXClient com.example.demo I IOmx service obtained
2026-01-08 15:32:50.946 14009-14009 HwViewRootImpl com.example.demo I removeInvalidNode jank list is null
2026-01-08 15:32:50.947 14009-14117 ACodec com.example.demo I In onAllocateComponent create compenent, codec name: OMX.hisi.video.encoder.avc
2026-01-08 15:32:50.948 14009-14058 OpenGLRenderer com.example.demo D disableOutlineDraw is true
2026-01-08 15:32:50.948 14009-14009 DecorView com.example.demo D showOrHideHighlightView: hasFocus=true; winMode=1; isMrgNull=true
2026-01-08 15:32:50.948 14009-14093 System.err com.example.demo W Info: [h264_mediacodec @ 0x733af06c80] Use 30 as the default MediaFormat frame-rate
2026-01-08 15:32:50.952 14009-14117 OMXUtils com.example.demo W do not know color format 0x7f000789 = 2130708361
2026-01-08 15:32:50.954 14009-14009 InputMethodManager com.example.demo W startInputReason = 1
2026-01-08 15:32:50.954 14009-14117 ACodec com.example.demo E [OMX.hisi.video.encoder.avc] configureCodec returning error -38
2026-01-08 15:32:50.954 14009-14117 ACodec com.example.demo E signalError(omxError 0x80001001, internalError -2147483648)
2026-01-08 15:32:50.954 14009-14114 MediaCodec com.example.demo E Codec reported err 0x80001001, actionCode 0, while in state 3
2026-01-08 15:32:50.954 14009-14009 HwRemoteIn...hodManager com.example.demo W isCasting false because IHwDistributedWindowManager is invalid.
2026-01-08 15:32:50.955 14009-14093 MediaCodec com.example.demo E configure failed with err 0x80001001, resetting...
2026-01-08 15:32:50.962 14009-14117 OMXClient com.example.demo I IOmx service obtained
2026-01-08 15:32:50.964 14009-14009 InputMethodManager com.example.demo W startInputReason = 5
2026-01-08 15:32:50.969 14009-14117 ACodec com.example.demo I In onAllocateComponent create compenent, codec name: OMX.hisi.video.encoder.avc
2026-01-08 15:32:50.970 14009-14093 System.err com.example.demo W Error: [amediacodec @ 0x733af22c00] android.media.MediaCodec$CodecException: Error 0x80001001
2026-01-08 15:32:50.970 14009-14093 System.err com.example.demo W Error: [h264_mediacodec @ 0x733af06c80] MediaCodec configure failed, Generic error in an external library
2026-01-08 15:32:50.971 14009-14114 MediaCodec com.example.demo I start process kWhatStopCompleted
2026-01-08 15:32:50.978 8072-8072 sug_info com.baidu.input_huawei E checkMatch:com.example.demo_0_0_null
2026-01-08 15:32:50.984 14009-14093 MainActivity com.example.demo E JavaCV fail
org.bytedeco.javacv.FFmpegFrameRecorder$Exception: avcodec_open2() error -542398533: Could not open video codec. (For more details, make sure FFmpegLogCallback.set() has been called.)
at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:800)
at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:444)
at com.example.demo.MainActivity.lambda$initCamera$2$com-example-demo-MainActivity(MainActivity.java:122)
at com.example.demo.MainActivity$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:932)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions