直播在 Honeycomb 上崩溃

发布于 2024-11-17 05:54:50 字数 4761 浏览 2 评论 0原文

代码:

        path = "httplive://<host>/moviets/index.m3u8";
        // Create a new media player and set the listeners
        mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setDataSource(path);
        mMediaPlayer.setOnErrorListener(this);
        mMediaPlayer.setDisplay(holder);
        mMediaPlayer.prepare();    // Crashes here. prepareAsync() does not help either
        mMediaPlayer.setOnBufferingUpdateListener(this);
        mMediaPlayer.setOnCompletionListener(this);
        mMediaPlayer.setOnPreparedListener(this);
        mMediaPlayer.setOnVideoSizeChangedListener(this);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.start();

堆栈跟踪:

 ERROR/MediaPlayer(1349): error (100, 0)
 ERROR/MediaPlayerDemo(1349): error: Prepare failed.: status=0x64
 ERROR/MediaPlayerDemo(1349): java.io.IOException: Prepare failed.: status=0x64
 ERROR/MediaPlayerDemo(1349):     at android.media.MediaPlayer.prepare(Native Method)
 ERROR/MediaPlayerDemo(1349):     at com.example.Example.VideoPlayerActivity.playVideo(VideoPlayerActivity.java:81)
 ERROR/MediaPlayerDemo(1349):     at com.example.Example.VideoPlayerActivity.surfaceCreated(VideoPlayerActivity.java:138)
 ERROR/MediaPlayerDemo(1349):     at android.view.SurfaceView.updateWindow(SurfaceView.java:565)
 ERROR/MediaPlayerDemo(1349):     at android.view.SurfaceView.access$000(SurfaceView.java:84)
 ERROR/MediaPlayerDemo(1349):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:173)
 ERROR/MediaPlayerDemo(1349):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
 ERROR/MediaPlayerDemo(1349):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1325)
 ERROR/MediaPlayerDemo(1349):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1944)
 ERROR/MediaPlayerDemo(1349):     at android.os.Handler.dispatchMessage(Handler.java:99)
 ERROR/MediaPlayerDemo(1349):     at android.os.Looper.loop(Looper.java:126)
 ERROR/MediaPlayerDemo(1349):     at android.app.ActivityThread.main(ActivityThread.java:3997)
 ERROR/MediaPlayerDemo(1349):     at java.lang.reflect.Method.invokeNative(Native Method)
 ERROR/MediaPlayerDemo(1349):     at java.lang.reflect.Method.invoke(Method.java:491)
 ERROR/MediaPlayerDemo(1349):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
 ERROR/MediaPlayerDemo(1349):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
 ERROR/MediaPlayerDemo(1349):     at dalvik.system.NativeStart.main(Native Method)
 DEBUG/MediaPlayerDemo(1349): surfaceChanged called

Logcat:

 DEBUG/MediaPlayerDemo(1349): surfaceCreated called
 INFO/System.out(1349): the path is httplive://192.168.0.196/moviets/index.m3u8
 INFO/StagefrightPlayer(1312): setDataSource('httplive://192.168.0.196/moviets/index.m3u8')
 INFO/LiveSession(1312): onConnect 'http://192.168.0.196/moviets/index.m3u8'
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/index.m3u8 @0
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/index.m3u8 @0
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/file5.ts @0
 INFO/avc_utils(1312): found AVC codec config (320 x 240, Baseline-profile level 3.0)
 INFO/ESQueue(1312): found something resembling an AAC syncword at offset 1017
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/file6.ts @0
 INFO/ESQueue(1312): found AAC codec config (48000 Hz, 7 channels)
 INFO/ESQueue(1312): [ 06-26 17:37:17.397  1312:0x550 F/ESQueue  ]
 INFO/ESQueue(1312): frameworks/base/media/libstagefright/mpeg2ts/ESQueue.cpp:255 Should not be here.
 INFO/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 INFO/DEBUG(31): Build fingerprint: 'generic/sdk/generic:3.0/HONEYCOMB/104254:eng/test-keys'
 INFO/DEBUG(31): pid: 1312, tid: 1360  >>> /system/bin/mediaserver <<<
 INFO/DEBUG(31): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
 INFO/DEBUG(31):  r0 deadbaad  r1 0000000c  r2 00000027  r3 00000000
 INFO/DEBUG(31):  r4 00000080  r5 aff46658  r6 00000007  r7 00000000
 INFO/DEBUG(31):  r8 a2b72589  r9 00012a6c  10 00100000  fp 00000001
 INFO/DEBUG(31):  ip ffffffff  sp 4060f488  lr aff193e9  pc aff15f58  cpsr 00000030
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/file7.ts @0
 INFO/DEBUG(31):          #00  pc 00015f58  /system/lib/libc.so
 INFO/DEBUG(31):          #01  pc 00001466  /system/lib/liblog.so (__android_log_assert)
 INFO/DEBUG(31): libc base address: aff00000

令我困惑的是“找到 AAC 编解码器配置”这一行,而视频文件包含 mp3 编码。这是正常现象还是我的 Android 客户端错误地将 mp3 检测为 aac?仅供参考,其他使用 aac 编码的视频在客户端上播放正常

有任何线索吗?

Code:

        path = "httplive://<host>/moviets/index.m3u8";
        // Create a new media player and set the listeners
        mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setDataSource(path);
        mMediaPlayer.setOnErrorListener(this);
        mMediaPlayer.setDisplay(holder);
        mMediaPlayer.prepare();    // Crashes here. prepareAsync() does not help either
        mMediaPlayer.setOnBufferingUpdateListener(this);
        mMediaPlayer.setOnCompletionListener(this);
        mMediaPlayer.setOnPreparedListener(this);
        mMediaPlayer.setOnVideoSizeChangedListener(this);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.start();

Stack trace:

 ERROR/MediaPlayer(1349): error (100, 0)
 ERROR/MediaPlayerDemo(1349): error: Prepare failed.: status=0x64
 ERROR/MediaPlayerDemo(1349): java.io.IOException: Prepare failed.: status=0x64
 ERROR/MediaPlayerDemo(1349):     at android.media.MediaPlayer.prepare(Native Method)
 ERROR/MediaPlayerDemo(1349):     at com.example.Example.VideoPlayerActivity.playVideo(VideoPlayerActivity.java:81)
 ERROR/MediaPlayerDemo(1349):     at com.example.Example.VideoPlayerActivity.surfaceCreated(VideoPlayerActivity.java:138)
 ERROR/MediaPlayerDemo(1349):     at android.view.SurfaceView.updateWindow(SurfaceView.java:565)
 ERROR/MediaPlayerDemo(1349):     at android.view.SurfaceView.access$000(SurfaceView.java:84)
 ERROR/MediaPlayerDemo(1349):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:173)
 ERROR/MediaPlayerDemo(1349):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
 ERROR/MediaPlayerDemo(1349):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1325)
 ERROR/MediaPlayerDemo(1349):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1944)
 ERROR/MediaPlayerDemo(1349):     at android.os.Handler.dispatchMessage(Handler.java:99)
 ERROR/MediaPlayerDemo(1349):     at android.os.Looper.loop(Looper.java:126)
 ERROR/MediaPlayerDemo(1349):     at android.app.ActivityThread.main(ActivityThread.java:3997)
 ERROR/MediaPlayerDemo(1349):     at java.lang.reflect.Method.invokeNative(Native Method)
 ERROR/MediaPlayerDemo(1349):     at java.lang.reflect.Method.invoke(Method.java:491)
 ERROR/MediaPlayerDemo(1349):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
 ERROR/MediaPlayerDemo(1349):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
 ERROR/MediaPlayerDemo(1349):     at dalvik.system.NativeStart.main(Native Method)
 DEBUG/MediaPlayerDemo(1349): surfaceChanged called

Logcat:

 DEBUG/MediaPlayerDemo(1349): surfaceCreated called
 INFO/System.out(1349): the path is httplive://192.168.0.196/moviets/index.m3u8
 INFO/StagefrightPlayer(1312): setDataSource('httplive://192.168.0.196/moviets/index.m3u8')
 INFO/LiveSession(1312): onConnect 'http://192.168.0.196/moviets/index.m3u8'
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/index.m3u8 @0
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/index.m3u8 @0
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/file5.ts @0
 INFO/avc_utils(1312): found AVC codec config (320 x 240, Baseline-profile level 3.0)
 INFO/ESQueue(1312): found something resembling an AAC syncword at offset 1017
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/file6.ts @0
 INFO/ESQueue(1312): found AAC codec config (48000 Hz, 7 channels)
 INFO/ESQueue(1312): [ 06-26 17:37:17.397  1312:0x550 F/ESQueue  ]
 INFO/ESQueue(1312): frameworks/base/media/libstagefright/mpeg2ts/ESQueue.cpp:255 Should not be here.
 INFO/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 INFO/DEBUG(31): Build fingerprint: 'generic/sdk/generic:3.0/HONEYCOMB/104254:eng/test-keys'
 INFO/DEBUG(31): pid: 1312, tid: 1360  >>> /system/bin/mediaserver <<<
 INFO/DEBUG(31): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
 INFO/DEBUG(31):  r0 deadbaad  r1 0000000c  r2 00000027  r3 00000000
 INFO/DEBUG(31):  r4 00000080  r5 aff46658  r6 00000007  r7 00000000
 INFO/DEBUG(31):  r8 a2b72589  r9 00012a6c  10 00100000  fp 00000001
 INFO/DEBUG(31):  ip ffffffff  sp 4060f488  lr aff193e9  pc aff15f58  cpsr 00000030
 INFO/NuHTTPDataSource(1312): connect to 192.168.0.196:80/moviets/file7.ts @0
 INFO/DEBUG(31):          #00  pc 00015f58  /system/lib/libc.so
 INFO/DEBUG(31):          #01  pc 00001466  /system/lib/liblog.so (__android_log_assert)
 INFO/DEBUG(31): libc base address: aff00000

What stumps me is the line "found AAC codec config", while the video file contains mp3 encoding. Is that normal or my Android client is wrongly detecting mp3 as aac? FYI, other videos with aac encoding are playing okay on the client

Any clue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就像说晚安 2024-11-24 05:54:50

这似乎是 Honeycomb 模拟器中的一个错误,其中 Android 错误地将 mp3 流检测为 aac。另一方面,FFmpeg 可以正确检测 mp3 流,如下所示。

ffmpeg -i file6.ts
Stream #0.1[0x101]: Audio: mp3, 48000 Hz, 2 channels, s16, 192 kb/s

不幸的是,Android 认为它是 AAC

 INFO/avc_utils(1312): found AVC codec config (320 x 240, Baseline-profile level 3.0)
 INFO/ESQueue(1312): found something resembling an AAC syncword at offset 1017
 INFO/NuHTTPDataSource(1312): connect to <ip>:<port>/moviets/file6.ts @0
 INFO/ESQueue(1312): found AAC codec config (48000 Hz, 7 channels)
 INFO/ESQueue(1312): [ 06-26 17:37:17.397  1312:0x550 F/ESQueue  ]
 INFO/ESQueue(1312): frameworks/base/media/libstagefright/mpeg2ts/ESQueue.cpp:255 \
                     Should not be here.

。解决方法是使用 AAC 编码。如果您使用 ffmpeg,请使用 -acodec libfaac 选项。这适用于我们的项目,因为我们可以自由选择源视频格式。但这可能不一定是您的情况。

This seems like a bug in Honeycomb emulator where Android wrongly detects mp3 stream as aac. FFmpeg, on the other hand, detects the mp3 stream correctly, as below

ffmpeg -i file6.ts
Stream #0.1[0x101]: Audio: mp3, 48000 Hz, 2 channels, s16, 192 kb/s

Unfortunately, Android thinks it is AAC

 INFO/avc_utils(1312): found AVC codec config (320 x 240, Baseline-profile level 3.0)
 INFO/ESQueue(1312): found something resembling an AAC syncword at offset 1017
 INFO/NuHTTPDataSource(1312): connect to <ip>:<port>/moviets/file6.ts @0
 INFO/ESQueue(1312): found AAC codec config (48000 Hz, 7 channels)
 INFO/ESQueue(1312): [ 06-26 17:37:17.397  1312:0x550 F/ESQueue  ]
 INFO/ESQueue(1312): frameworks/base/media/libstagefright/mpeg2ts/ESQueue.cpp:255 \
                     Should not be here.

The workaround is to use AAC encoding. If you are using ffmpeg, use the -acodec libfaac option. This works for our project because we have the liberty of choosing the source video formats. This might not necessarily be your case though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文