OnlyInAmerica / HWEncoderExperiments

Deprecated ( See https://github.com/Kickflip/kickflip-android-sdk for my current work). Experiments with Android 4.3's MediaCodec and MediaMuxer
122 stars 61 forks source link

Crashes on Nexus 5 (4.4.2) #2

Open vbokan opened 10 years ago

vbokan commented 10 years ago

After recording starts, app crashes after a while.

Here's a stacktrace...

02-25 18:01:24.839 23772-23772/net.openwatch.hwencoderexperiments D/dalvikvm﹕ Late-enabling CheckJNI 02-25 18:01:24.859 23772-23778/net.openwatch.hwencoderexperiments D/dalvikvm﹕ Debugger has detached; object registry had 1 entries 02-25 18:01:24.949 23772-23772/net.openwatch.hwencoderexperiments I/Adreno-EGL﹕ : EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13 02-25 18:01:24.979 23772-23772/net.openwatch.hwencoderexperiments D/OpenGLRenderer﹕ Enabling debug mode 0 02-25 18:01:27.789 23772-23832/net.openwatch.hwencoderexperiments D/CameraToMpegTest﹕ video/avc output 640x480 @1000000 02-25 18:01:27.939 23772-23832/net.openwatch.hwencoderexperiments D/CameraToMpegTest﹕ Camera preview size is 640x480 02-25 18:01:27.949 23772-23863/net.openwatch.hwencoderexperiments I/OMXClient﹕ Using client-side OMX mux. 02-25 18:01:28.019 23772-23863/net.openwatch.hwencoderexperiments E/ACodec﹕ [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -2147483648 02-25 18:01:28.029 23772-23863/net.openwatch.hwencoderexperiments I/ACodec﹕ setupVideoEncoder succeeded 02-25 18:01:28.029 23772-23832/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ mEGLDisplayContext not set properly 02-25 18:01:28.039 23772-23872/net.openwatch.hwencoderexperiments I/OMXClient﹕ Using client-side OMX mux. 02-25 18:01:28.049 23772-23872/net.openwatch.hwencoderexperiments E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one. 02-25 18:01:28.049 23772-23832/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Output file is /sdcard/HWEncodingExperiments/chunktest.640x4801.mp4 02-25 18:01:28.069 23772-23832/net.openwatch.hwencoderexperiments D/FileUtils﹕ Using sdcard 02-25 18:01:28.069 23772-23832/net.openwatch.hwencoderexperiments D/getRootStorageDirectory﹕ /storage/emulated/0/HWEncodingExperiments 02-25 18:01:28.069 23772-23832/net.openwatch.hwencoderexperiments I/FileUtils﹕ Created temp file: /storage/emulated/0/HWEncodingExperiments/hq.mp4 02-25 18:01:28.439 23772-23877/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ Muxer not started. dropping audio frames 02-25 18:01:28.439 23772-23877/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ Muxer not started. dropping audio frames 02-25 18:01:28.449 23772-23877/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ Muxer not started. dropping audio frames 02-25 18:01:28.449 23772-23877/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ Muxer not started. dropping audio frames 02-25 18:01:28.449 23772-23877/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ Muxer not started. dropping audio frames 02-25 18:01:28.459 23772-23877/net.openwatch.hwencoderexperiments E/CameraToMpegTest﹕ Muxer not started. dropping audio frames 02-25 18:01:28.469 23772-23832/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ limits: 2147483647/0 bytes/us, bit rate: -1 bps and the estimated moov size 3072 bytes 02-25 18:01:28.469 23772-23900/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ setStartTimestampUs: 311194 02-25 18:01:28.469 23772-23900/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Earliest track starting time: 311194 02-25 18:01:28.469 23772-23899/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ setStartTimestampUs: 385062 02-25 18:01:29.659 23772-23877/net.openwatch.hwencoderexperiments D/dalvikvm﹕ GC_FOR_ALLOC freed 301K, 2% free 16939K/17272K, paused 15ms, total 16ms 02-25 18:01:33.419 23772-23832/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Chunkpoint on frame 150 02-25 18:01:33.419 23772-23877/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Audio loop caught audioEosRequested / fullStopReceived true false 02-25 18:01:33.429 23772-23877/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ EOS received in sendAudioToEncoder 02-25 18:01:33.429 23772-23832/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Chunking video encoder 02-25 18:01:33.439 23772-23863/net.openwatch.hwencoderexperiments E/ACodec﹕ [OMX.qcom.video.encoder.avc] ERROR(0x80001009) 02-25 18:01:33.439 23772-23862/net.openwatch.hwencoderexperiments E/MediaCodec﹕ Codec reported an error. (omx error 0x80001009, internalError -2147483648) 02-25 18:01:33.469 23772-23832/net.openwatch.hwencoderexperiments I/advanceVideo﹕ video on muxer1 02-25 18:01:33.469 23772-23832/net.openwatch.hwencoderexperiments I/advanceVideo﹕ encoders on same muxer. swapping. 02-25 18:01:33.469 23772-23832/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ limits: 2147483647/0 bytes/us, bit rate: -1 bps and the estimated moov size 3072 bytes 02-25 18:01:33.469 23772-23931/net.openwatch.hwencoderexperiments I/OMXClient﹕ Using client-side OMX mux. 02-25 18:01:33.559 23772-23931/net.openwatch.hwencoderexperiments E/ACodec﹕ [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -2147483648 02-25 18:01:33.559 23772-23931/net.openwatch.hwencoderexperiments I/ACodec﹕ setupVideoEncoder succeeded 02-25 18:01:33.579 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Audio track 02-25 18:01:33.579 23772-23900/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Received total/0-length (150/0) buffers and encoded 150 frames. - video 02-25 18:01:33.589 23772-23899/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Received total/0-length (216/0) buffers and encoded 216 frames. - audio 02-25 18:01:33.589 23772-23899/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Audio track drift time: 0 us 02-25 18:01:33.589 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Audio track source 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Audio track stopped 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Video track 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Video track source 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Video track stopped 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Duration from tracks range is [4975817, 5025665] us 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping writer thread 02-25 18:01:33.599 23772-23898/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ 0 chunks are written in the last batch 02-25 18:01:33.599 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Writer thread stopped 02-25 18:01:33.619 23772-23877/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ The mp4 file will not be streamable. 02-25 18:01:33.619 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Audio track 02-25 18:01:33.619 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Video track 02-25 18:01:33.619 23772-23877/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Chunking audio encoder 02-25 18:01:33.619 23772-23877/net.openwatch.hwencoderexperiments I/advanceAudio﹕ audio on muxer1 02-25 18:01:33.619 23772-23877/net.openwatch.hwencoderexperiments I/advanceAudio﹕ encoders on diff muxers. restarting 02-25 18:01:33.629 23772-23929/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ setStartTimestampUs: 5437365 02-25 18:01:33.629 23772-23929/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Earliest track starting time: 5437365 02-25 18:01:33.629 23772-23941/net.openwatch.hwencoderexperiments I/OMXClient﹕ Using client-side OMX mux. 02-25 18:01:33.629 23772-23941/net.openwatch.hwencoderexperiments E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one. 02-25 18:01:33.639 23772-23928/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ setStartTimestampUs: 5558323 02-25 18:01:35.769 23772-23877/net.openwatch.hwencoderexperiments D/dalvikvm﹕ GC_FOR_ALLOC freed 512K, 4% free 16938K/17484K, paused 12ms, total 12ms 02-25 18:01:38.549 23772-23832/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Chunkpoint on frame 150 02-25 18:01:38.559 23772-23877/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Audio loop caught audioEosRequested / fullStopReceived true false 02-25 18:01:38.559 23772-23877/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ EOS received in sendAudioToEncoder 02-25 18:01:38.559 23772-23832/net.openwatch.hwencoderexperiments I/CameraToMpegTest﹕ Chunking video encoder 02-25 18:01:38.569 23772-23931/net.openwatch.hwencoderexperiments E/ACodec﹕ [OMX.qcom.video.encoder.avc] ERROR(0x80001009) 02-25 18:01:38.569 23772-23930/net.openwatch.hwencoderexperiments E/MediaCodec﹕ Codec reported an error. (omx error 0x80001009, internalError -2147483648) 02-25 18:01:38.589 23772-23832/net.openwatch.hwencoderexperiments I/advanceVideo﹕ video on muxer2 02-25 18:01:38.589 23772-23832/net.openwatch.hwencoderexperiments I/advanceVideo﹕ encoders on same muxer. swapping. 02-25 18:01:38.599 23772-23832/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ limits: 2147483647/0 bytes/us, bit rate: -1 bps and the estimated moov size 3072 bytes 02-25 18:01:38.599 23772-23953/net.openwatch.hwencoderexperiments I/OMXClient﹕ Using client-side OMX mux. 02-25 18:01:38.689 23772-23953/net.openwatch.hwencoderexperiments E/ACodec﹕ [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -2147483648 02-25 18:01:38.689 23772-23953/net.openwatch.hwencoderexperiments I/ACodec﹕ setupVideoEncoder succeeded 02-25 18:01:38.719 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Video track 02-25 18:01:38.719 23772-23929/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Received total/0-length (150/0) buffers and encoded 150 frames. - audio 02-25 18:01:38.719 23772-23929/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Audio track drift time: 0 us 02-25 18:01:38.719 23772-23928/net.openwatch.hwencoderexperiments E/MPEG4Writer﹕ There are no sync frames for video track 02-25 18:01:38.729 23772-23928/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Received total/0-length (220/0) buffers and encoded 220 frames. - video 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Video track source 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Video track stopped 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Audio track 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping Audio track source 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Audio track stopped 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Duration from tracks range is [4966119, 5025089] us 02-25 18:01:38.729 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Stopping writer thread 02-25 18:01:38.759 23772-23927/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ 1 chunks are written in the last batch 02-25 18:01:38.759 23772-23877/net.openwatch.hwencoderexperiments D/MPEG4Writer﹕ Writer thread stopped 02-25 18:01:38.759 23772-23877/net.openwatch.hwencoderexperiments W/dalvikvm﹕ threadid=15: thread exiting with uncaught exception (group=0x41cfdba8) 02-25 18:01:38.759 23772-23877/net.openwatch.hwencoderexperiments E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-679 Process: net.openwatch.hwencoderexperiments, PID: 23772 java.lang.IllegalStateException: Failed to stop the muxer at android.media.MediaMuxer.nativeStop(Native Method) at android.media.MediaMuxer.stop(MediaMuxer.java:226) at net.openwatch.hwencoderexperiments.ChunkedHWRecorder$MediaMuxerWrapper.stop(ChunkedHWRecorder.java:176) at net.openwatch.hwencoderexperiments.ChunkedHWRecorder$MediaMuxerWrapper.finishTrack(ChunkedHWRecorder.java:158) at net.openwatch.hwencoderexperiments.ChunkedHWRecorder.drainEncoder(ChunkedHWRecorder.java:845) at net.openwatch.hwencoderexperiments.ChunkedHWRecorder.access$500(ChunkedHWRecorder.java:54) at net.openwatch.hwencoderexperiments.ChunkedHWRecorder$1.run(ChunkedHWRecorder.java:369) at java.lang.Thread.run(Thread.java:841) 02-25 18:01:38.789 23772-23951/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ setStartTimestampUs: 10596458 02-25 18:01:38.789 23772-23951/net.openwatch.hwencoderexperiments I/MPEG4Writer﹕ Earliest track starting time: 10596458 '''

OnlyInAmerica commented 10 years ago

Thanks for reporting! I'm no longer developing in this experimental repository.

I'm developing a full video SDK called Kickflip. You need to create a free account at kickflip.io for API keys to use the live broadcasting features, but you're free to use all the components within the bounds of Apache2.

Within Kickflip, AVReorder.java would be a good place to start looking.

vbokan commented 10 years ago

Will do, thanks. I saw you are using ffmpeg for encoding, right? Have you found a way to use hw acceleration?

OnlyInAmerica commented 10 years ago

I'm actually only using FFmpeg for muxing. I use Android's MediaCodec (CameraEncoder.java and MicrophoneEncoder.java extend AndroidEncoder.java which leverages the hardware encoder) to produce H.264 / AAC packets that I feed into FFmpeg. FFmpeg simply packages the packets into whatever container format is appropriate. E.g .ts for HTTP Live Streaming, .flv for RTMP, or .mp4 for local storage.

You'll see in Kickflip the FFmpegMuxer and AndroidMuxer are drop-in replacements for each other, but the AndroidMuxer only supports .mp4 output.