livekit / client-sdk-android

LiveKit SDK for Android
https://docs.livekit.io
Apache License 2.0
169 stars 67 forks source link

保存本地视频黑屏,但是有声音, #453

Open shangshuaibo opened 1 month ago

shangshuaibo commented 1 month ago

保存视频操作代码如下,按照官方实例写的 room = LiveKit.create( appContext = applicationContext, overrides = LiveKitOverrides( javaAudioDeviceModuleCustomizer = { builder -> builder.setSamplesReadyCallback { samples -> videoFileRenderer?.onWebRtcAudioRecordSamplesReady(samples) } } ) )

track?.addRenderer(videoFileRenderer)

private fun disconnectRoom() { videoFileRenderer?.release() videoFileRenderer = null }

保存的时候报错如下,保存下来的视频是黑屏,有声音,文件特别小,时长好像还少了几秒

Stop() called but track is not started or stopped Muxer has been released! java.lang.IllegalStateException: Muxer has been released! at android.media.MediaMuxer.writeSampleData(MediaMuxer.java:731) at cn.jucheng.www.utils.VideoFileRenderer.drainAudio(VideoFileRenderer.java:279) at cn.jucheng.www.utils.VideoFileRenderer.lambda$onWebRtcAudioRecordSamplesReady$4$cn-jucheng-www-utils-VideoFileRenderer(VideoFileRenderer.java:322) at cn.jucheng.www.utils.VideoFileRenderer$$ExternalSyntheticLambda4.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:966) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:293) at android.os.HandlerThread.run(HandlerThread.java:110)

davidliu commented 1 month ago

Sorry, we took the code from elsewhere and it seems to be pretty old. I don't really know MediaCodec usage very well myself, so it's unlikely we'll be able to fix up the example code here for a while.

You can use the original VideoFileRenderer.java provided by libwebrtc, but be warned that this writes raw uncompressed frames and will result in very large video files.

shangshuaibo commented 1 month ago

Sorry, we took the code from elsewhere and it seems to be pretty old. I don't really know MediaCodec usage very well myself, so it's unlikely we'll be able to fix up the example code here for a while.

You can use the original VideoFileRenderer.java provided by libwebrtc, but be warned that this writes raw uncompressed frames and will result in very large video files.

您好,我直接运行的官方sample-app-record-local,只修改了url和token image

保存的视频也是黑屏 image

我想知道是手机问题吗,还是说移动端sdk和后台sdk版本必须要一致才可以

davidliu commented 1 month ago

The backend SDK won't have any relevancy here as the example code for recording the video. Your best bet would be to look up working MediaCodec examples for recording a Surface and going from there.

shangshuaibo commented 1 month ago

The backend SDK won't have any relevancy here as the example code for recording the video. Your best bet would be to look up working MediaCodec examples for recording a Surface and going from there.

通过以上日志您能看出来MediaCodec有什么问题吗

shangshuaibo commented 1 month ago

The backend SDK won't have any relevancy here as the example code for recording the video. Your best bet would be to look up working MediaCodec examples for recording a Surface and going from there.

encoder output format changed: {max-bitrate=6000000, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, mime=video/avc, width=960, bitrate=6000000, color-range=2, frame-rate=30, color-standard=2, height=540, csd-0=java.nio.HeapByteBuffer[pos=0 lim=22 cap=22]}

davidliu commented 1 month ago

通过以上日志您能看出来MediaCodec有什么问题吗

Unfortunately I didn't write the above code (the original is from https://github.com/flutter-webrtc/flutter-webrtc/blob/main/android/src/main/java/com/cloudwebrtc/webrtc/record/VideoFileRenderer.java) and I don't know much about MediaCodec to help here.

tombang commented 3 days ago

你好,我这里出现了相同的问题,请问你那边有解决吗?