doc/QUESTION_EN.md
Click to see the Chinese version
Online analysis: https://gpac.github.io/mp4box.js/test/filereader.html
Third-party summary of ijkplayer issues https://juejin.im/entry/5bc7e7d6e51d450e4f392088
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
> If you can't find the dependency and there are missing packages, you can see: https://github.com/CarGuo/GSYVideoPlayer/issues/4144
There is a dependencies.gradle in the outermost part of the project, and all project dependencies are in it. Then refer to the build.gradle in the root directory of the project. There is apply from: 'dependencies.gradle' at the top, so that gsyVideoPlayer can find the corresponding dependencies. For gradle convenience, you can refer to Collection of difficult and miscellaneous diseases of Android squatting (and Gradle) II
Secondly, because so has five platforms, the remote dependency library is relatively large. When relying, if conditions permit, you can turn on the vpn and use the L2TP protocol, and the dependency download will be faster.
Make sure that your unpacking Application configuration is normal. If obfuscation is enabled, make sure that obfuscation has been added.
And sometimes what you need is to clear it.
-keep class tv.danmaku.ijk.** { *; }
-dontwarn tv.danmaku.ijk.**
-keep class com.shuyu.gsyvideoplayer.** { *; }
-dontwarn com.shuyu.gsyvideoplayer.**
You can configure ndk abiFilters to ensure that there are corresponding so files in the so folder used. Use Analyze Apk to check whether so should be packaged into each folder.
Refer to #issue23
Refer to #issue24
Refer to ndk filter selection introduction
Have you added the following code to gradle
android {
···
defaultConfig {
···
ndk {
//APP's build.gradle sets the supported SO library architecture
abiFilters 'armeabi', 'armeabi-v7a', 'x86'
}
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
Did you monitor the list sliding and update the list in the monitoring.
If the recorded video cannot be played, you can try to use the system recording project: VideoRecord Or use the JAVACV recording project: FFmpegRecorder, to test whether the video can be played.
Black screen related issues: https://github.com/Bilibili/ijkplayer/issues/2541 https://github.com/Bilibili/ijkplayer/pull/1875
Cache does not support m3u8\HLS, to play m3u8\HLS format, you need cacheWithPlay to be false
setUp(String url, boolean cacheWithPlay····)
You can try the following settings
VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "enable-accurate-seek", 1);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
GSYVideoManager.instance().setOptionModelList(list);
<activity
android:name=".PlayActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:screenOrientation="portrait" />
If the network environment is not good, you can try to turn off the cache to play, because the proxy method of playing while caching has high requirements on the network.
When setUp, set the method with the Map<String, String> mapHeadData parameter, which is actually converted to the setOption method inside Ijk. You can refer to ijkPlayer's issues-1150
issue64 issue490 Fragmented playback data
2. Sometimes, TextureView needs to enable hardware acceleration such as android:hardwareAccelerated="true" in the application tag
The simulator does not accept it!
Is the hard decoding turned off!
Is the config of the Activity configured!
What is the resolution and frame rate of the video, and does the machine support it?
Step 3 can be tried by reducing the multiple:
VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 50);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
GSYVideoManager.instance().setOptionModelList(list);
For urls such as http://xxxxxxx.Chinese.mp4, if a http 400 error occurs, please convert the Chinese url to url encoding yourself; For example, http://tool.oschina.net/encode?type=4 is converted here.
https://github.com/CarGuo/GSYVideoPlayer/issues/232
https://github.com/CarGuo/GSYVideoPlayer/issues/207
https://github.com/Bilibili/ijkplayer/issues/2874
https://github.com/CarGuo/GSYVideoPlayer/issues/252
VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist", "crypto,file,http,https,tcp,tls,udp");
VideoOptionModel videoOptionModel2 =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_extensions", "ALL");
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
list.add(videoOptionModel2);
GSYVideoManager.instance().setOptionModelList(list);
VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOphtionModel);
GSYVideoManager.instance().setOptionModelList(list);
More optimization (one setOption corresponds to VideoOptionModel in gsy)
//Hard decoding: 1, on, 0, off
//mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1);
//Soft decoding: 1, on, 0, off
//mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "videotoolbox", 0);
//rtsp settings https://ffmpeg.org/ffmpeg-protocols.html#rtsp
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_flags", "prefer_tcp");
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_media_types", "video"); //Configure according to media type
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 20000);
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "buffer_size", 1316);
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "infbuf", 1); // Infinite read
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzemaxduration", 100L);
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 10240L);
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1L);
// Turn off player buffering, this must be turned off, otherwise it will get stuck after playing for a period of time, and the console will print FFP_MSG_BUFFERING_START
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0L);
mMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 1L);
corresponding
List<VideoOptionModel> list = new ArrayList<>();
VideoOptionModel videoOptionMode01 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fast", 1);//No extra optimization
list.add(videoOptionMode01);
VideoOptionModel videoOptionMode02 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 200);//10240
list.add(videoOptionMode02);
VideoOptionModel videoOptionMode03 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1);
list.add(videoOptionMode03);
//pause output until enough packets have been read after stalling
VideoOptionModel videoOptionMode04 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0);//Whether to enable buffering
list.add(videoOptionMode04);
//drop frames when cpu is too slow:0-120
VideoOptionModel videoOptionMode05 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 1);//Frame dropping, if it is too stuck, you can try to drop frames
list.add(videoOptionMode05);
//automatically start playing on prepared
VideoOptionModel videoOptionMode06 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1);
list.add(videoOptionMode06);
VideoOptionModel videoOptionMode07 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);//Default value 48
list.add(videoOptionMode07);
//max buffer size should be pre-read:Default is 15*1024*1024
VideoOptionModel videoOptionMode11 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 0);//Maximum cache number
list.add(videoOptionMode11);
VideoOptionModel videoOptionMode12 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 2);//Default minimum frame number 2
list.add(videoOptionMode12);
VideoOptionModel videoOptionMode13 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max_cached_duration", 30);//Maximum cache duration
list.add(videoOptionMode13);
//input buffer:don't limit the input buffer size (useful with realtime streams)
VideoOptionModel videoOptionMode14 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1);//Whether to limit the input cache number
list.add(videoOptionMode14);
VideoOptionModel videoOptionMode15 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer");
list.add(videoOptionMode15);
VideoOptionModel videoOptionMode16 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");//tcp data transmission
list.add(videoOptionMode16);
VideoOptionModel videoOptionMode17 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzedmaxduration", 100);//Analysis stream duration: default 1024*1000
list.add(videoOptionMode17);
GSYVideoManager.instance().setOptionModelList(list);
VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
VideoOptionModel videoOptionModel2 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_timeout", -1);
list.add(videoOptionModel2);
GSYVideoManager.instance().setOptionModelList(list);
There are some custom operations that need to be synchronized between full screen and non-full screen switching. The specific operation is to overload the following two methods to implement your own custom operations. For details, please refer to the demo.
To get the current player externally, it is recommended to use play.getCurPlay().xxxxxx
/**
* When in full screen, assign the corresponding processing parameter logic to the full screen player
*
* @param context
* @param actionBar
* @param statusBar
* @return
*/
@Override
public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) {
SmartPickVideo sampleVideo = (SmartPickVideo) super.startWindowFullscreen(context, actionBar, statusBar);
sampleVideo.mSourcePosition = mSourcePosition;
sampleVideo.mType = mType;
sampleVideo.mUrlList = mUrlList;
sampleVideo.mTypeText = mTypeText;
sampleVideo.mSwitchSize.setText(mTypeText);
return sampleVideo;
}
/**
* When exiting full screen, return the corresponding processing parameter logic to the non-player
*
* @param oldF
* @param vp
* @param gsyVideoPlayer
*/
@Override
protected void resolveNormalVideoShow(View oldF, ViewGroup vp, GSYVideoPlayer gsyVideoPlayer) {
super.resolveNormalVideoShow(oldF, vp, gsyVideoPlayer);
if (gsyVideoPlayer != null) {
SmartPickVideo sampleVideo = (SmartPickVideo) gsyVideoPlayer;
mSourcePosition = sampleVideo.mSourcePosition;
mType = sampleVideo.mType;
mTypeText = sampleVideo.mTypeText;
mSwitchSize.setText(mTypeText);
setUp(mUrlList, mCache, mCachePath, mTitle);
}
}
Note that this is a global setting. After setting, you need to clear this item if you don't need it.
VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "seek-at-start", startPosition);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
GSYVideoManager.instance().setOptionModelList(list);
https://stackoverflow.com/questions/6445052/android-context-memory-leak-listview-due-to-audiomanager
VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER,"reconnect",5);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
GSYVideoManager.instance().setOptionModelList(list);
In addition to selecting a track, you can also configure
VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "subtitle", 1);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel);
GSYVideoManager.instance().setOptionModelList(list);
https://github.com/CarGuo/GSYVideoPlayer/issues/3941#issuecomment-1972409662
https://github.com/CarGuo/GSYVideoPlayer/issues/2997#issuecomment-711480841
invalid dts/pts combination 740157300
VideoOptionModel videoOptionModel2 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "http_proxy", "http://192.168.0.116:8888 ");
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel2);
GSYVideoManager.instance().setOptionModelList(list);
VideoOptionModel videoOptionModel2 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 25);
List<VideoOptionModel> list = new ArrayList<>();
list.add(videoOptionModel2);
GSYVideoManager.instance().setOptionModelList(list);
binding.change.setOnClickListener(new View.OnClickListener() {
int index = 0;
@Override
public void onClick(View view) {
IjkMediaPlayer player = ((IjkMediaPlayer)((IjkPlayerManager)binding.detailPlayer.getGSYVideoManager().getPlayer() ).getMediaPlayer());
player.selectTrack(1);
}
});
For more configurations, please refer to the links and pictures below