我正在开发一个小型电视应用,它使用m3u8格式的许多电视流。 如果我使用原生VideoView,所有流工作正常。但我想使用Vitamio来更好地支持不同的协议和视频编解码器。我将Vitamio添加到我的项目而不是原生VideoView。这很容易,但我对所有流都有错误:“无法播放视频。抱歉,此视频无法播放。” 在logcat中:“ E / Vitamio [Player]:错误(1,-1094995529)” 我读了很多类似的文章,如何添加Vitamio,找不到我做错了什么。
在清单中,互联网访问是必需的,设备可以访问互联网。
也:
<activity android:name="io.vov.vitamio.activity.InitActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden"
android:launchMode="singleTop"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="stateAlwaysHidden"/>
在module.app
中 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'me.neavo:vitamio:4.2.2'
}
这是我用于测试的代码:
import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
public class MainActivity extends AppCompatActivity {
VideoView vidView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vidView = (VideoView)findViewById(R.id.myVideo);
getSupportActionBar().hide();
if (!LibsChecker.checkVitamioLibs(this))
return;
vidView.setMediaController(new MediaController(this));
vidView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
vidView.setVideoPath("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
vidView.requestFocus();
}
答案 0 :(得分:1)
来自ffmpeg的错误代码(来自avutil的error.h): http://ffmpeg.org/doxygen/trunk/error_8h_source.html
事实证明你指定的值是:
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A')
-1094995529变为-0x41444E49,当您查看这些字母时,在ACSII中,0x41 =&#39; A&#39;,0x44 =&#39; D&#39;,0x4E =&#39; N,和0x49 =&#39;我&#39;。由于宏/等事情是相反的,因此ADNI变为INDA,您可以从#define片段中看到,是AVERROR_INVALIDDATA定义的FFERRTAG(&#39; I&#39;,&#39; N&#39;,& #39; d&#39;&#39; A&#39)
。其余的错误代码都在该文件中,我已将其粘贴到此处:
#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
#define AVERROR_INPUT_CHANGED (-0x636e6701) ///< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
#define AVERROR_OUTPUT_CHANGED (-0x636e6702) ///< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
#define AVERROR_HTTP_BAD_REQUEST FFERRTAG(0xF8,'4','0','0')
#define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1')
#define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3')
#define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4')
#define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X')
#define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X')
您的视频路径指定了需要其他文件的文件。也就是说,它在内部引用gear4 \ prog_index.m3u8,所以你可能还要加载它?
因为vitamio返回了一个ffmpeg错误代码,我怀疑它在某种程度上依赖于ffmpeg使用VideoView句柄,但直接使用它不会。