PLDroidMediaStreaming
PLDroidMediaStreaming 是七牛推出的一款适用于 Android 平台的推流 SDK,支持 RTMP 推流,h.264 和 AAC 编码,硬编、软编支持。具有丰富的数据和状态回调,方 便用户根据自己的业务定制化开发。具有直播场景下的重要功能,如:美颜、背景音乐、水印等功能。PLDroidMediaStreaming 是现在目前重点维护的版本,自带采集模块也支持用户自己做采集端。
Top Related Projects
Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
RTMP live streaming client for Android
该项目不再维护,仅供学习参考
业内为数不多致力于极致体验的超强全自研跨平台(windows/linux/android/iOS)流媒体内核,通过模块化自由组合,支持实时RTMP推流、RTSP推流、RTMP播放器、RTSP播放器、录像、多路流媒体转发、音视频导播、动态视频合成、音频混音、直播互动、内置轻量级RTSP服务等,比快更快,业界真正靠谱的超低延迟直播SDK(1秒内,低延迟模式下200~400ms)。
Quick Overview
PLDroidMediaStreaming is an Android SDK for live video streaming. It provides a comprehensive solution for capturing, processing, and broadcasting live video content from Android devices. The SDK offers features like camera preview, video encoding, and RTMP streaming.
Pros
- Easy integration with Android applications
- Supports both hardware and software encoding
- Offers various video effects and filters
- Provides real-time statistics and quality monitoring
Cons
- Limited to Android platform only
- May require additional setup for certain advanced features
- Documentation primarily in Chinese, which may be challenging for non-Chinese speakers
- Potential licensing restrictions for commercial use
Code Examples
- Initializing the streaming manager:
PLMediaStreamingManager mMediaStreamingManager = new PLMediaStreamingManager(this, mCameraPreviewView, mEncodingConfig);
mMediaStreamingManager.prepare(mCameraStreamingSetting, mMicrophoneStreamingSetting, null);
- Starting the stream:
mMediaStreamingManager.startStreaming();
- Applying a video filter:
mMediaStreamingManager.setVideoFilter(new PLBuiltinFilter(PLBuiltinFilter.FILTER_BEAUTY));
- Stopping the stream:
mMediaStreamingManager.stopStreaming();
Getting Started
- Add the SDK dependency to your
build.gradle
file:
dependencies {
implementation 'com.qiniu.pili:pldroid-media-streaming:2.3.5'
}
- Initialize the streaming manager in your activity:
PLMediaStreamingManager mMediaStreamingManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PLMediaStreamingConfiguration config = new PLMediaStreamingConfiguration();
mMediaStreamingManager = new PLMediaStreamingManager(this, findViewById(R.id.cameraPreview), config);
mMediaStreamingManager.prepare(new PLCameraStreamingSetting(), new PLMicrophoneStreamingSetting(), null);
}
- Start streaming when ready:
mMediaStreamingManager.startStreaming();
Competitor Comparisons
Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
Pros of ijkplayer
- Cross-platform support (Android, iOS, macOS, Windows)
- Based on FFmpeg, providing extensive codec and format support
- Active community and frequent updates
Cons of ijkplayer
- Steeper learning curve due to its lower-level API
- Larger binary size compared to PLDroidMediaStreaming
- May require more manual configuration for specific use cases
Code Comparison
PLDroidMediaStreaming:
StreamingManager mStreamingManager = new StreamingManager(this);
mStreamingManager.setStreamingProfile(profile);
mStreamingManager.prepare(mCameraPreviewView);
mStreamingManager.startStreaming();
ijkplayer:
IjkMediaPlayer ijkMediaPlayer = new IjkMediaPlayer();
ijkMediaPlayer.setDataSource(url);
ijkMediaPlayer.prepareAsync();
ijkMediaPlayer.start();
Key Differences
- PLDroidMediaStreaming focuses on live streaming, while ijkplayer is primarily a media player
- ijkplayer offers more flexibility and control over media playback
- PLDroidMediaStreaming provides a higher-level API for easier implementation of streaming functionality
Use Cases
- Choose PLDroidMediaStreaming for quick implementation of live streaming in Android apps
- Opt for ijkplayer when cross-platform support and advanced media playback features are required
RTMP live streaming client for Android
Pros of yasea
- Lightweight and easy to integrate
- Open-source with an active community
- Supports both RTMP streaming and local recording
Cons of yasea
- Limited documentation compared to PLDroidMediaStreaming
- Fewer advanced features and customization options
- May require more manual configuration for complex use cases
Code Comparison
PLDroidMediaStreaming:
mMediaStreamingManager = new MediaStreamingManager(this, mCameraPreviewFrameView, mEncodingConfig);
mMediaStreamingManager.prepare(mCameraStreamingSetting, mMicrophoneStreamingSetting, null, mProfile);
mMediaStreamingManager.startStreaming();
yasea:
mPublisher = new SrsPublisher(this);
mPublisher.setEncodeHandler(new SrsEncodeHandler(this));
mPublisher.setRtmpHandler(new RtmpHandler(this));
mPublisher.startCamera();
mPublisher.startPublish(rtmpUrl);
Both libraries offer straightforward initialization and streaming setup. PLDroidMediaStreaming provides a more comprehensive configuration approach, while yasea focuses on simplicity and ease of use. PLDroidMediaStreaming may be better suited for complex projects requiring fine-tuned control, whereas yasea could be ideal for quick implementations or smaller-scale applications.
该项目不再维护,仅供学习参考
Pros of SopCastComponent
- Lightweight and focused on live streaming functionality
- Easy to integrate into existing Android projects
- Open-source with an active community
Cons of SopCastComponent
- Less comprehensive feature set compared to PLDroidMediaStreaming
- May require additional libraries for advanced functionality
- Limited documentation and examples
Code Comparison
SopCastComponent:
CameraListener cameraListener = new CameraListener() {
@Override
public void onOpenSuccess() {
// Camera opened successfully
}
};
mCameraManager.setCameraOpenListener(cameraListener);
PLDroidMediaStreaming:
mMediaStreamingManager = new MediaStreamingManager(this, avsOptions, cameraStreamingSetting, microphoneStreamingSetting);
mMediaStreamingManager.setStreamingStateListener(new StreamingStateListener() {
@Override
public void onStateChanged(StreamingState state, Object extra) {
// Handle streaming state changes
}
});
SopCastComponent provides a more straightforward approach to camera management, while PLDroidMediaStreaming offers a more comprehensive streaming management system with additional options and settings.
Both libraries aim to simplify live streaming for Android developers, but PLDroidMediaStreaming generally offers more features and flexibility at the cost of increased complexity. SopCastComponent may be a better choice for simpler projects or developers looking for a lightweight solution, while PLDroidMediaStreaming is more suitable for advanced streaming applications with complex requirements.
业内为数不多致力于极致体验的超强全自研跨平台(windows/linux/android/iOS)流媒体内核,通过模块化自由组合,支持实时RTMP推流、RTSP推流、RTMP播放器、RTSP播放器、录像、多路流媒体转发、音视频导播、动态视频合成、音频混音、直播互动、内置轻量级RTSP服务等,比快更快,业界真正靠谱的超低延迟直播SDK(1秒内,低延迟模式下200~400ms)。
Pros of SmarterStreaming
- More comprehensive feature set, including both push and pull streaming capabilities
- Better support for low-latency streaming and real-time communication
- More active development and frequent updates
Cons of SmarterStreaming
- Less documentation and examples compared to PLDroidMediaStreaming
- Steeper learning curve due to more complex architecture
- Potentially higher resource usage due to advanced features
Code Comparison
SmarterStreaming:
SmartPublisherJni.SmartPublisherInit(width, height, frameRate, bitRate);
SmartPublisherJni.SmartPublisherSetVideoEncodeType(videoEncodeType);
SmartPublisherJni.SmartPublisherStartPublish(rtmpUrl);
PLDroidMediaStreaming:
mMediaStreamingManager = new MediaStreamingManager(this, mCameraPreviewView);
mMediaStreamingManager.prepare(mProfile);
mMediaStreamingManager.startStreaming();
SmarterStreaming offers more granular control over streaming parameters, while PLDroidMediaStreaming provides a simpler, more abstracted API. SmarterStreaming's approach allows for finer tuning but requires more setup code. PLDroidMediaStreaming's streamlined interface may be easier for beginners but offers less customization.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PLDroidCameraStreaming
PLDroidCameraStreaming æ¯ä¸ä¸ªéç¨äº Android ç RTMP ç´ææ¨æµ SDKï¼å¯é«åº¦å®å¶ååäºæ¬¡å¼åãç¹è²æ¯åæ¶æ¯æ H.264 软ç¼ï¼ç¡¬ç¼å AAC 软ç¼ï¼ç¡¬ç¼ãæ¯æ Android Camera ç»é¢æè·ï¼å¹¶è¿è¡ H.264 ç¼ç ï¼ä»¥åæ¯æ Android 麦å é£é³é¢éæ ·å¹¶è¿è¡ AAC ç¼ç ï¼è¿å®ç°äºä¸å¥å¯ä¾å¼åè éæ©çç¼ç åæ°éåï¼ä»¥ä¾¿çµæ´»è°èç¸åºçå辨çåç çï¼åæ¶ï¼SDK æä¾æ°æ®æºåè°æ¥å£ï¼ç¨æ·å¯è¿è¡ Filter å¤çãåå© PLDroidCameraStreaming ï¼å¼åè å¯ä»¥å¿«éæ建ä¸æ¬¾ç±»ä¼¼ Meerkat æ Periscope ç Android ç´æåºç¨ã
åè½ç¹æ§
- æ¯æ H.264 å AAC 软ç¼ï¼æ¨èï¼
- æ¯æ H.264ãH.265 å AAC 硬ç¼
- 软ç¼æ¯æ Android Min API 15ï¼Android 4.0.3ï¼åå ¶ä»¥ä¸çæ¬
- 硬ç¼æ¯æ Android Min API 18ï¼Android 4.3ï¼åå ¶ä»¥ä¸çæ¬
- æ¯ææé 带å®å ¨ææåè¯ç RTMP æ¨æµå°å
- æ¯æ RTMP å°å åæ¨æµ
- æ¯æ RTMP æ¨æµèªéåºç½ç»è´¨éå¨æåæ¢ç çæèªå®ä¹çç¥
- æ¯æå ç½®ç¾é¢ï¼ä»¥åå¯å¨æè°èç¾é¢ææ
- æ¯ææ°æ®æºåè°æ¥å£ï¼å¯èªå®ä¹ Filter (滤é) ç¹æå¤ç
- æ¯æååç½®æå头ï¼ä»¥åå¨æåæ¢
- æ¯æèªå¨å¯¹ç¦
- æ¯ææå¨å¯¹ç¦
- æ¯æ Encoding Mirror 设置
- æ¯æ Zoom æä½
- æ¯æ Mute/Unmute
- æ¯æéªå ç¯æä½
- æ¯æ纯é³é¢æ¨æµï¼ä»¥ååå°è¿è¡
- æ¯ææªå¸§åè½
- æ¯æå¨ææ´æ¹ Encoding Orientation
- æ¯æå¨æåæ¢æ¨ªç«å±
- æ¯æå¨ææ°´å°
- æ¯æå¨ææåä¸è´´å¾
- æ¯æèç麦å é£
- æ¯æåå°æ¨æµ
- æ¯æå声éç«ä½å£°
- æ¯æ QUIC æ¨æµ
- æ¯æ ARM, ARMv7a, ARM64v8a, X86 主æµè¯çä½ç³»æ¶æ
- æ¯æ SEI ä¿¡æ¯åé
- æ¯æ SRT æ¨æµ
PLDroidCameraStreaming ææ¡£
详ç»çå¼åæå请åèå®æ¹ææ¡£
设å¤ä»¥åç³»ç»è¦æ±
- 设å¤è¦æ±ï¼æè½½ Android ç³»ç»ç设å¤
- ç³»ç»è¦æ±ï¼Android 4.3(API 18) åå ¶ä»¥ä¸
çæ¬å级须ç¥
v3.1.5
- ä» v3.1.5 çæ¬å¼å§ï¼å°ä¸åæ¯æ armeabi æ¶æ
v3.1.3
- ä» v3.1.3 çæ¬å¼å§ï¼HappyDNS åºå¡å¿ åçº§å° 1.0.0 çæ¬
v3.1.2
- ä» v3.1.2 çæ¬å¼å§ï¼SDK å°ä¸å强å¶è¦æ±è·å READ_PHONE_STATE å ACCESS_FINE_LOCATION çæé
v3.1.1
- ä» v3.1.1 çæ¬å¼å§ï¼HappyDNS åºå¡å¿ åçº§å° 0.2.18 çæ¬
v3.0.2
- ä» v3.0.2 çæ¬å¼å§ï¼è¯·å¡å¿
æ·»å
android.arch.lifecycle:extensions:x.y.z
çä¾èµ - ä» v3.0.2 çæ¬å¼å§ï¼
StreamingEnv.init(Context context)
已被å¼ç¨ï¼è¯·æ´æ°å°StreamingEnv.init(Context contex, String userId)
è¿è¡ç¯å¢çåå§åï¼å ¶ä¸ï¼userId 代表ç¨æ·çå¯ä¸æ è¯ç¬¦ï¼ç¨äºåºåä¸åçç¨æ·
v3.0.1
- ä» v3.0.1 çæ¬å¼å§ï¼å¦ææ¨ä½¿ç¨äº Happy DNS åºï¼è¯·å¡å¿ åçº§å° 0.2.17 çæ¬
v3.0.0
- ä» v3.0.0 çæ¬å¼å§ï¼ä¸çç´ææ¨æµ SDK éè¦å è·åæææè½ä½¿ç¨ãææå为è¯ç¨çåæ£å¼çï¼å¯éè¿ 400-808-9176 转 2 å·çº¿èç³»ä¸çåå¡å¨è¯¢ï¼æè éè¿å·¥å èç³»ä¸ççææ¯æ¯æã
- v3.0.0 ä¹åççæ¬ä¸åå½±åï¼è¯·ç»§ç»æ¾å¿ä½¿ç¨ã
- è客æ·å级 v3.0.0 çæ¬ä¹åï¼è¯·å èç³»ä¸çè·åç¸åºææï¼ä»¥å åçé´æä¸éè¿çç°è±¡ã
- åºäº 114 dns 解æçä¸ç¡®å®æ§ï¼ä½¿ç¨è¯¥è§£æå¯è½ä¼å¯¼è´è§£æçç½ç» ip æ æ³åå°æ大çä¼åçç¥ï¼è¿èåºç°æ¨æµè´¨éä¸ä½³çç°è±¡ãå æ¤å»ºè®®ä½¿ç¨é 114 dns 解æ
v2.4.1
- ä» v2.4.1 å¼å§ï¼VideoProfile 对 H264 æ ¼å¼é ç½®çåæ°ç± annexb æ¹ä¸º avccï¼ä¹å设置为 false ç客æ·ï¼éè¦å°é ç½®æ¹ä¸º trueã
ä¾å¦ç®å设æå¦ä¸é ç½®ç客æ·ï¼
StreamingProfile.VideoProfile vProfile =
new StreamingProfile.VideoProfile(20, 1000 * 1024, 60, false);
éå°åæ°è°æ´ä¸ºï¼
StreamingProfile.VideoProfile vProfile =
new StreamingProfile.VideoProfile(20, 1000 * 1024, 60, true);
v2.3.0
- ä» v2.3.0 çæ¬å¼å§ï¼å¢å libpldroid_streaming_puic.so åº
- libpldroid_streaming_core.so ä¾èµäº libpldroid_streaming_puic.soï¼æ 论æ¯å¦å¯ç¨ QUIC æ¨æµï¼é½éè¦å å« libpldroid_streaming_puic.so åº
v2.2.0
- ä» v2.2.0 çæ¬å¼å§ï¼é¡»è¦å¨ build.gradle ä¸å é¤ QoS ä¾èµ
dependencies {
...
compile 'com.qiniu.pili:pili-android-qos:0.8.+'
...
}
v2.1.0
- 使ç¨å½å±åè½åï¼é¡»è¦å¨ AndroidManifest.xml ä¸æ³¨å SDK å ç½®ç Activityï¼
<activity
android:name="com.qiniu.pili.droid.streaming.screen.ScreenCaptureRequestActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
</activity>
-
pili-android-qos ææ°çæ¬ä¸º 0.8.13
-
æ´æ°
StreamingPreviewCallback#onPreviewFrame
StreamingPreviewCallback#onPreviewFrame(byte[] data, int width, int height)
è°æ´ä¸º
/**
* Called if the {@link StreamingPreviewCallback} registered.
*
* @param data the contents of the preview frame in fmt format
* @param width the width of the frame
* @param height the height of the frame
* @param rotation set the clockwise rotation of frame in degrees to achieve the same effect of preview display.
* @param fmt the format of the frame. See also {@link com.qiniu.pili.droid.streaming.av.common.PLFourCC}
* @param tsInNanoTime the timestamp of the frame
*
* */
boolean StreamingPreviewCallback#onPreviewFrame(byte[] data, int width, int height, int rotation, int fmt, long tsInNanoTime);
v2.0.1
ä» v2.0.1 å¼å§ï¼
- å æåºå¼ç
CameraStreamingManager
ï¼å¯ä½¿ç¨MediaStreamingManager
- é¡»å¨å®¿ä¸»é¡¹ç®ä¸ç build.gradle ä¸å å ¥å¦ä¸è¯å¥ï¼
dependencies {
...
compile 'com.qiniu:happy-dns:0.2.+'
compile 'com.qiniu.pili:pili-android-qos:0.8.+'
...
}
-
åºå¼ç
StreamingPreviewCallback#onPreviewFrame(byte[] bytes, Camera camera)
被å æï¼å¯ä½¿ç¨StreamingPreviewCallback#onPreviewFrame(byte[] bytes, int width, int height)
-
AudioSourceCallback#onAudioSourceAvailable(ByteBuffer byteBuffer, int size, boolean eof)
æ¥å£åè°ä¸å¢å æ¶é´æ³ä¿¡æ¯ï¼æ´æ¹ä¸ºAudioSourceCallback#onAudioSourceAvailable(ByteBuffer byteBuffer, int size, long tsInNanoTime, boolean eof)
v2.0.0 Beta
ä» v2.0.0 Beta å¼å§ï¼SDK ç± PLDroidCameraStreaming æ´å为 PLDroidMediaStreamingï¼å°ä¼æä¾æ´ä¸°å¯çåè½æ¥å£ãæå¦ä¸é大æ´æ°ï¼
- æ°å¢
MediaStreamingManager
ï¼åºå¼CameraStreamingManager
ä¸ä¸åè¢«ç»´æ¤ - æ°å¢ä¸äºè¾
å©ç±»å¹¶åºå¼ç¸å
³çç±»
- æ°å¢
StreamingStateChangedListener
ï¼å¹¶åºå¼CameraStreamingManager#StreamingStateListener
- æ°å¢
StreamingState
ï¼å¹¶åºå¼CameraStreamingManager#STATE
- æ°å¢
StreamingSessionListener
ï¼å¹¶åºå¼CameraStreamingManager#StreamingSessionListener
- æ°å¢
AVCodecType
ï¼å¹¶åºå¼CameraStreamingManager#EncodingType
- æ°å¢
- å
åæ´æ°ä¸º
com.qiniu.pili.droid.streaming.*;
ï¼å æ¤éè¦æ´æ°æ··æ·ç¸å ³ä»£ç
v1.6.1
ä» v1.6.1 å¼å§ï¼ä¸ºäºä¾¿äºç¨æ·æ´å¥½å°å®å¶åï¼å° TransformMatrix ä¿¡æ¯å å
¥å° SurfaceTextureCallback#onDrawFrame
ãå æ¤æ´æ°å° v1.6.1 çæ¬ä¹åï¼è¥å®ç°äº SurfaceTextureCallback
æ¥å£ï¼éè¦å°
int onDrawFrame(int texId, int texWidth, int texHeight);
æ´æ¹ä¸ºï¼
int onDrawFrame(int texId, int texWidth, int texHeight, float[] transformMatrix);
v1.6.0
ä» v1.6.0 å¼å§ï¼å¨ä½¿ç¨ SDK ä¹åï¼éè¦ä¿è¯ StreamingEnv
被æ£ç¡®åå§å ï¼å¦åå¨æé æ ¸å¿ç±» CameraStreamingManager
çé¶æ®µä¼æåºå¼å¸¸ãå
·ä½å¯åç Demoã
StreamingEnv.init(getApplicationContext());
v1.4.6
ä» v1.4.6 çæ¬å¼å§ï¼éè¦å¨å®¿ä¸»é¡¹ç®ä¸ç build.gradle ä¸å å ¥å¦ä¸è¯å¥ï¼
dependencies {
...
compile 'com.qiniu:happy-dns:0.2.7'
...
}
å¦åï¼å¨è¿è¡æ¶ä¼åçæ¾ä¸å° happydns ç¸å ³ç±»çé误ã
v1.6.0
ä» v1.6.0 å¼å§ï¼å¨ä½¿ç¨ SDK ä¹åï¼éè¦ä¿è¯ StreamingEnv
被æ£ç¡®åå§å ï¼å¦åå¨æé æ ¸å¿ç±» CameraStreamingManager
çé¶æ®µä¼æåºå¼å¸¸ãå
·ä½å¯åç Demoã
StreamingEnv.init(getApplicationContext());
v1.6.1
ä» v1.6.1 å¼å§ï¼ä¸ºäºä¾¿äºç¨æ·æ´å¥½å°å®å¶åï¼å° TransformMatrix ä¿¡æ¯å å
¥å° SurfaceTextureCallback#onDrawFrame
ãå æ¤æ´æ°å° v1.6.1 çæ¬ä¹åï¼è¥å®ç°äº SurfaceTextureCallback
æ¥å£ï¼éè¦å°
int onDrawFrame(int texId, int texWidth, int texHeight);
æ´æ¹ä¸ºï¼
int onDrawFrame(int texId, int texWidth, int texHeight, float[] transformMatrix);
åé¦åæè§
å½ä½ éå°ä»»ä½é®é¢æ¶ï¼å¯ä»¥éè¿å¨ GitHub ç repo æ交 issues æ¥åé¦é®é¢ï¼è¯·å°½å¯è½çæè¿°æ¸ æ¥éå°çé®é¢ï¼å¦ææé误信æ¯ä¹ä¸åé带ï¼å¹¶ä¸å¨ Labels ä¸ææç±»å为 bug æè å ¶ä»ã
Top Related Projects
Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
RTMP live streaming client for Android
该项目不再维护,仅供学习参考
业内为数不多致力于极致体验的超强全自研跨平台(windows/linux/android/iOS)流媒体内核,通过模块化自由组合,支持实时RTMP推流、RTSP推流、RTMP播放器、RTSP播放器、录像、多路流媒体转发、音视频导播、动态视频合成、音频混音、直播互动、内置轻量级RTSP服务等,比快更快,业界真正靠谱的超低延迟直播SDK(1秒内,低延迟模式下200~400ms)。
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot