无法实例mediaextractor使用的setDataSource时() [英] Failed to instantiate mediaextractor when using setDataSource()
问题描述
我试图提取使用MediaExtract和连接code AVI文件的0磁道(视频轨道)使用媒体codeC H264格式。这是我如何配置媒体codeC
I am trying to extract Track 0 (video track) of an avi file using MediaExtract and encode to h264 format using MediaCodec. Here is how i configured mediaCodec
public MediaCodec configure_codec(){
Log.d("OUT","configure starts");
MediaCodec codec = MediaCodec.createEncoderByType("video/avc");
MediaFormat format = MediaFormat.createVideoFormat("video/avc", 320, 240);
format.setInteger(MediaFormat.KEY_BIT_RATE, 700000);
format.setInteger(MediaFormat.KEY_FRAME_RATE, 15);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5);
//Configure codec for encoding
codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
Log.d("OUT","codec configured");
return codec;
}
我面临的问题是在这部分。
The problem i am facing is in this part.
public MediaExtractor extract_video()
{
MediaExtractor extractor = new MediaExtractor();
//problem in this line
try{
extractor.setDataSource(file_in);
}catch(Throwable th){
Log.d("OUT", th.getMessage());
}
MediaFormat format = extractor.getTrackFormat(0);
String mime = format.getString(MediaFormat.KEY_MIME);
Log.d("OUT", String.format("MIME TYPE: %s", mime));
extractor.selectTrack(0);
return extractor;
}
下面是日志。
07-01 10:53:53.284: D/OUT(1779): Main starts
07-01 10:53:54.024: I/Choreographer(1779): Skipped 82 frames! The application may be doing too much work on its main thread.
07-01 10:53:54.373: I/Choreographer(1779): Skipped 247 frames! The application may be doing too much work on its main thread.
07-01 10:53:54.433: D/gralloc_goldfish(1779): Emulator without GPU emulation detected.
07-01 10:54:00.194: I/Choreographer(1779): Skipped 36 frames! The application may be doing too much work on its main thread.
07-01 10:54:00.336: D/OUT(1779): Button Start
07-01 10:54:00.336: D/OUT(1779): start starts
07-01 10:54:00.344: D/OUT(1779): /mnt/sdcard/test.avi
07-01 10:54:00.344: D/OUT(1779): /mnt/sdcard/result.h264
07-01 10:54:00.344: D/OUT(1779): configure starts
07-01 10:54:00.394: I/OMXClient(1779): Using client-side OMX mux.
07-01 10:54:00.504: I/SoftAVCEncoder(1779): Construct SoftAVCEncoder
07-01 10:54:00.534: I/ACodec(1779): setupVideoEncoder succeeded
07-01 10:54:00.534: E/OMXNodeInstance(1779): OMX_GetExtensionIndex failed
07-01 10:54:00.544: D/OUT(1779): codec configured
07-01 10:54:00.734: E/WVMExtractor(1779): Failed to open libwvm.so
07-01 10:54:00.734: D/OUT(1779): Failed to instantiate extractor.
07-01 10:54:00.744: D/AndroidRuntime(1779): Shutting down VM
07-01 10:54:00.755: W/dalvikvm(1779): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-01 10:54:00.924: E/AndroidRuntime(1779): FATAL EXCEPTION: main
07-01 10:54:00.924: E/AndroidRuntime(1779): java.lang.IllegalArgumentException
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.media.MediaExtractor.getTrackFormatNative(Native Method)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.media.MediaExtractor.getTrackFormat(MediaExtractor.java:195)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.app.convert_final.encoder_pack.extract_video(encoder_pack.java:46)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.app.convert_final.encoder_pack.start(encoder_pack.java:81)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.app.convert_final.MainActivity$1.onClick(MainActivity.java:27)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.view.View.performClick(View.java:4084)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.view.View$PerformClick.run(View.java:16966)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.os.Handler.handleCallback(Handler.java:615)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.os.Handler.dispatchMessage(Handler.java:92)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.os.Looper.loop(Looper.java:137)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-01 10:54:00.924: E/AndroidRuntime(1779): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 10:54:00.924: E/AndroidRuntime(1779): at java.lang.reflect.Method.invoke(Method.java:511)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-01 10:54:00.924: E/AndroidRuntime(1779): at dalvik.system.NativeStart.main(Native Method)
07-01 10:54:03.394: I/Process(1779): Sending signal. PID: 1779 SIG: 9
我应该如何解决这个问题?
libwvm.so是什么?它为什么无法打开?
How should i solve this issue? What is libwvm.so? Why does it fail to open?
下面是我怎么叫功能:
public void start()
{
this.running = true;
Log.d("OUT","start starts");
Log.d("OUT", file_in);
Log.d("OUT", file_out);
codec = configure_codec();
extractor = extract_video();
now_start();
}
test.avi
MediaInfo of "test.avi"
General
Complete name : D:\test.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 967 KiB
Duration : 2s 500ms
Overall bit rate : 3 169 Kbps
Video
ID : 0
Format : JPEG
Codec ID : MJPG
Duration : 2s 500ms
Bit rate : 2 782 Kbps
Width : 320 pixels
Height : 240 pixels
Original height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Scan type : Interlaced
Compression mode : Lossy
Bits/(Pixel*Frame) : 1.207
Stream size : 849 KiB (88%)
Audio
ID : 1
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 2s 500ms
Bit rate mode : Constant
Bit rate : 352.8 Kbps
Channel(s) : 1 channel
Sampling rate : 22.05 KHz
Bit depth : 16 bits
Stream size : 108 KiB (11%)
Alignment : Aligned on interleaves
Interleave, duration : 33 ms (1.00 video frame)
全部code在这里: http://pastebin.com/WiCp4SPq EN coder_pack。 java的结果
http://pastebin.com/JjyR9pdH Main_Activity.java
Full code here: http://pastebin.com/WiCp4SPq encoder_pack.java
http://pastebin.com/JjyR9pdH Main_Activity.java
推荐答案
我这问我自己(我有太多的信息,将其添加如下评论)的 MediaExtractor.setDataSource抛出IOException异常"未能实例提取器QUOT; ,我想我现在已经回答了我的问题。
I asked this myself (I had too much information to add it as a comment here) MediaExtractor.setDataSource throws IOException "failed to instantiate extractor" and I think I've answered my own question now.
这样看来,如果不是要求它从文件中提取,我打开文件我自己,得到一个输入流,从输入流中获得的FileDescriptor,然后要求其从文件描述符中提取,它屡试不爽。
It would appear that if, instead of asking it to extract from a file, I open the file myself, get an input stream, get the FileDescriptor from the input stream, and then ask it to extract from the file descriptor, it works every time.
这篇关于无法实例mediaextractor使用的setDataSource时()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!