gpt4 book ai didi

android - 使用 setDataSource() 时无法实例化 mediaextractor

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:11 26 4
gpt4 key购买 nike

我正在尝试使用 MediaExtract 提取 avi 文件的轨道 0(视频轨道)并使用 MediaCodec 编码为 h264 格式。这是我配置 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;

}

我面临的问题是在这部分。

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?为什么打不开?

下面是我调用函数的方式:

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

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)

完整代码在这里:http://pastebin.com/WiCp4SPq编码器包.java
http://pastebin.com/JjyR9pdH Main_Activity.java

最佳答案

这是我自己问的(我有太多信息无法在此处添加为评论)MediaExtractor.setDataSource throws IOException "failed to instantiate extractor"我想我现在已经回答了我自己的问题。

看起来,如果不是要求它从文件中提取,而是我自己打开文件,获取输入流,从输入流中获取 FileDescriptor,然后要求它从文件描述符中提取,它每次都有效。

关于android - 使用 setDataSource() 时无法实例化 mediaextractor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17398111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com