当前位置:网站首页>Live broadcast software | IPTV live broadcast software | TV live broadcast | tvplayer IPTV easyplayer | youwo live broadcast | customized development of super live broadcast software
Live broadcast software | IPTV live broadcast software | TV live broadcast | tvplayer IPTV easyplayer | youwo live broadcast | customized development of super live broadcast software
2022-04-23 01:03:00 【Yu Nianyu Hui】
Article content
- Function introduction
- Core code
- Second on Optimization
- Introduction to channel change
- Article summary
- Demo Address
In other words, this is a bottom layer based on ffmpeg Player , Be commonly called EasyPlayer、Ijkplayer、ExoPlayer、JiaoZiVideoPlayer wait , Support MMS, RTSP, RTMP, HLS(m3u8) And other common streaming media protocols ; Support MKV,FLV,MP4,MOV,TS,RMVB And other common video formats ;
Function introduction
We're not big guys , Let's put it simply , In other words, the basic elements of a live broadcast software 、、、 Alas , Pick a simple way to say 、、、、、、 Say what say , It's just to realize a player that supports various streaming media protocols and various video formats at the same time ;
I don't understand ? Don't panic , We have references , For the TV terminal, it's like friends' nest live broadcast 、 Super live 、 Live TV and so on IPTV Live Software ; So for mobile live broadcast, the article only introduces the streaming end , Familiar name playing end , How to implement a complete set of mobile live broadcasting system ? Don't panic , Contact me , I am the simplest [ Yu Nianyu Hui ](https://blog.csdn.net/qq_35350654);

Core code
xml Definition
<org.easydarwin.easyplayer.views.ProVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true" />
ProVideoView quote
private ActivityMainProBinding mBinding;
private TextView TextView;
private View mProgress;
private ProVideoView mVideoView;
private String[] url = {"http://jzvd.nathen.cn/342a5f7ef6124a4a8faf00e738b8bee4/cf6d9db0bd4d41f59d09ea0a81e918fd-5287d2089db37e62345123a1be272f8b.mp4", "rtmp://218.38.152.69:1935/da_live/72136989/mp4:ch001"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main_pro);
// init player
IjkMediaPlayer ijkMediaPlayer = new IjkMediaPlayer();
ijkMediaPlayer.loadLibrariesOnce(null);
if (BuildConfig.DEBUG) {
ijkMediaPlayer.native_setLogLevel(IjkMediaPlayer.IJK_LOG_DEBUG);
}
mVideoView = mBinding.videoView;
mProgress = findViewById(android.R.id.progress);
mVideoView.setOnInfoListener(new IMediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(IMediaPlayer iMediaPlayer, int arg1, int arg2) {
switch (arg1) {
case IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING:
//mTextView.append("\nMEDIA_INFO_VIDEO_TRACK_LAGGING");
break;
case IMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
//mTextView.append("\nMEDIA_INFO_VIDEO_RENDERING_START");
mProgress.setVisibility(View.GONE);
break;
case IMediaPlayer.MEDIA_INFO_BUFFERING_START:
//mTextView.append("\nMEDIA_INFO_BUFFERING_START");
break;
case IMediaPlayer.MEDIA_INFO_BUFFERING_END:
//mTextView.append("\nMEDIA_INFO_BUFFERING_END");
break;
case IMediaPlayer.MEDIA_INFO_NETWORK_BANDWIDTH:
//mTextView.append("\nMEDIA_INFO_NETWORK_BANDWIDTH: " + arg2);
break;
case IMediaPlayer.MEDIA_INFO_BAD_INTERLEAVING:
//mTextView.append("\nMEDIA_INFO_BAD_INTERLEAVING");
break;
case IMediaPlayer.MEDIA_INFO_NOT_SEEKABLE:
//mTextView.append("\nMEDIA_INFO_NOT_SEEKABLE");
break;
case IMediaPlayer.MEDIA_INFO_METADATA_UPDATE:
//mTextView.append("\nMEDIA_INFO_METADATA_UPDATE");
break;
case IMediaPlayer.MEDIA_INFO_UNSUPPORTED_SUBTITLE:
//mTextView.append("\nMEDIA_INFO_UNSUPPORTED_SUBTITLE");
break;
case IMediaPlayer.MEDIA_INFO_SUBTITLE_TIMED_OUT:
//mTextView.append("\nMEDIA_INFO_SUBTITLE_TIMED_OUT");
break;
case IMediaPlayer.MEDIA_INFO_VIDEO_ROTATION_CHANGED:
break;
case IMediaPlayer.MEDIA_INFO_AUDIO_RENDERING_START:
//mTextView.append("\nMEDIA_INFO_AUDIO_RENDERING_START");
break;
}
return false;
}
});
/**
* Play error
*/
mVideoView.setOnErrorListener(new IMediaPlayer.OnErrorListener() {
@Override
public boolean onError(IMediaPlayer iMediaPlayer, int i, int i1) {
mProgress.setVisibility(View.GONE);
Toast.makeText(ProVideoActivity.this, " Play error ", Toast.LENGTH_SHORT).show();
mVideoView.postDelayed(new Runnable() {
@Override
public void run() {
mVideoView.reStart();
}
}, 5000);
return true;
}
});
/**
* The playback is finished
*/
mVideoView.setOnCompletionListener(new IMediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(IMediaPlayer iMediaPlayer) {
mProgress.setVisibility(View.GONE);
Toast.makeText(ProVideoActivity.this, " The playback is finished ", Toast.LENGTH_SHORT).show();
}
});
TextView = findViewById(R.id.tv_time);
TextView.setText(" Playing :" + url[i]);
if (url[i] != null)
mVideoView.setVideoPath(url[i]);
else {
Log.e(TAG, "Null Data Source\n");
finish();
return;
}
mVideoView.start();
}
Finished 、 It's over. It's over
Second on Optimization
What the hell is seconds , Just be quick when changing channels , It doesn't matter how much , Add whatever you can , Run again after 、 contrast , Um. 、、、、、、 I can't see it at all , But you just add it ;
// Frame loss When the video frames cannot be processed, some frames are discarded to achieve the effect of synchronization
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 5);
// Set whether to turn on loop filtering : 0 Turn on , High picture quality , High decoding overhead ,48 close , Poor picture quality , Low decoding overhead
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 0);
// Solution to playback delay , Set the detection time before playing 1, Achieve the first screen second on effect
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1);
// If it is rtsp agreement , Can be used first tcp( The default is to use udp)
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");
ijkMediaPlayer.setOption(1, "analyzemaxduration", 100L);
ijkMediaPlayer.setOption(1, "flush_packets", 1L);
// Need to be ready to automatically play
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1);
// No additional optimization
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fast", 1);
// Whether to turn on pre buffering , Generally, live broadcast projects will be opened , Achieve the effect of seconds on , However, it brings the experience of playing frame dropping and blocking
ijkMediaPlayer.setOption(4, "packet-buffering", 0);
// Automatic screen rotation
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-auto-rotate", 0);
// Handle resolution changes
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-handle-resolution-change", 0);
// Maximum buffer size , Company kb
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "max-buffer-size", 0);
// The default minimum number of frames 2
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 2);
// Maximum cache duration
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max_cached_duration", 3);
// Whether to limit the number of input caches
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer");
// Detection before playback Size, The default is 1M, A little smaller will make the picture faster
ijkMediaPlayer.setOption(1, "probesize", 200);
// Playback reconnection times
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "reconnect", 5);
// Empty DNS
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1);
Introduction to channel change
This is interesting , I read a few online Ijkplayer Code for , Since the change is suicide Activity Switch , The effect of running is that every time you change the station, it's dark , And then opened a new world , I still love life , Look below ;
/**
* Change station
*/
public void player() {
TextView.setText(" Playing :" + url[i]);
mProgress.setVisibility(View.VISIBLE);
mVideoView.setVideoPath(url[i]);
mVideoView.toggleRender();
}
Article summary
Not much thought , I just want to have an article with more than 10000 clicks , Of course not necessarily this one , I don't know if it's my selfishness or my being too good , The articles written are always against everyone's appetite , But I think it's interesting to see a sentence recently , Let's end with it !
I used to expect others to help me , Then give them double the return , But they often end up disappointed , But recently I've tried to help others , I suddenly found that more and more people are helping me ;
Demo Address
Github:https://github.com/Life1412378121/TVPlayer-IPTV-EasyPlayer.git
CSDN:https://download.csdn.net/download/qq_35350654/11143538
版权声明
本文为[Yu Nianyu Hui]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230057108571.html
边栏推荐
- 移动端京东商城
- Acrel-2000型电力监控系统在兴庆坊新兴广场配电所配电回路用电的实时监控和管理
- App中使用微信公众号的模版消息来进行消息推送
- L2-007 family real estate (25 points) and search set or graph traversal
- Fault analysis | federated storage engine table causes the monitoring thread to be in the opening table state
- Configuration of imx6ull bare metal development analysis and configuration process of elcdif lighting RGB LCD
- Secret of 66% performance surge: AMD 25000 yuan 768mb 3D cache Xiaolong opened the cover for the first time
- Cross domain problem and solving cross domain problem by UMI proxy proxy
- The origin explanation and use example of image pre training model
- Common problems and solutions of crashsight access reporting
猜你喜欢

Cloud native Virtualization: building edge computing instances based on kubevirt

Three technical solutions of ant group were selected as "typical solutions for information technology application and innovation in 2021"

2.59 - write a C expression that generates a word consisting of the least significant byte of X and the remaining bytes of Y. For the operands x = 0x89abcdef and y = 0x76543210, 0x765432ef is obtained
![[HCTF 2018]admin](/img/08/8111f2f87796dda8dd6b0dcf72c42b.png)
[HCTF 2018]admin
![[Blue Bridge Cup real question 18] scratch addition multiple-choice question youth group scratch Blue Bridge Cup real question and answer explanation](/img/c6/88f1e1712823ec8fdefdbaedcb1b20.png)
[Blue Bridge Cup real question 18] scratch addition multiple-choice question youth group scratch Blue Bridge Cup real question and answer explanation

为企业出海“搭桥”,汇量科技靠什么出圈?

Deloitte 2022 technology trend: it self subversion, technology cross-border integration and innovation

Huawei CDN is fast everywhere

体育训练中心项目电力监控系统的研究与应用

京东一面:子线程如何获取父线程 ThreadLocal 的值?我蒙了。。。
随机推荐
Workplace PUA, five sins of managers
leetcode 396. Rotation function
光猫超级帐号密码,重置光猫获取超级帐号密码
Improvement of ref and struct in C 11
IMX6ULL裸机开发之EPIT周期性定时器分析及配置过程
The more "intelligent" the machine is, the easier it is for data taggers to be eliminated? Manfu Technology
[JS] realize the export of PDF from the specified area of the web page
Amazon Aurora's ability to read and write: shardingsphere proxy
【Android工程师与智能家居产品的第一次接触③】SmartConfig一键配网在硬件端的具体实现|ESP8266一键配网在Arduino的具体实现|玉念聿辉
This new feature of C 11, I would like to call it the strongest!
Analysis and configuration process of epit periodic timer for imx6ull bare metal development
[actf2020 freshman competition]
App中使用微信公众号的模版消息来进行消息推送
L2-002 linked list weight removal (25 points)
Get in the car, the era of intelligent database autonomy has come, and Tencent cloud database x AI has made a new breakthrough
L2-007 family real estate (25 points) and search set or graph traversal
Let's talk about ruby
Thymeleaf common public pages cannot use values related to other pages (passed in from the background) (map, model, value waiting for injection)
L2-012 judgment on heap (25 points) (string bug to be solved)
How does zhiting connect Xiaomi smart speakers?