All Projects → huzongyao → Live264Streamer

huzongyao / Live264Streamer

Licence: other
A Project To Study RTSP Streamer H264 Video With Live555(H264硬编,live555服务)

Programming Languages

C++
36643 projects - #6 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Live264Streamer

live555helper
Helper for live555
Stars: ✭ 53 (+231.25%)
Mutual labels:  live555
rtsp-simple-proxy
DEPRECATED - please use https://github.com/aler9/rtsp-simple-server
Stars: ✭ 41 (+156.25%)
Mutual labels:  rtsp-server
v4l2web
V4L2 web interface
Stars: ✭ 20 (+25%)
Mutual labels:  rtsp-server
RTSPhuzz
RTSPhuzz - An RTSP Fuzzer written using the Boofuzz framework
Stars: ✭ 33 (+106.25%)
Mutual labels:  rtsp-server
EasyRTMP RTSP
基于Android手机、设备拉取远程RTSP流到本地,再转成RTMP,推送到RTMP服务器。。此Demo涉及到需要商业授权SDK。
Stars: ✭ 32 (+100%)
Mutual labels:  rtsp-server
APStreamline
Live Video Streaming Made Easy!
Stars: ✭ 98 (+512.5%)
Mutual labels:  rtsp-server
RTSP-Server
LiveNVR流媒体服务器软件,能够通过简单的摄像机通道配置、CDN配置等,将统监控行业里面的高清网络摄像机IP Camera、NVR、编码器设备接入到LiveNVR,将这些视频源的音视频数据采集到设备端,进行全平台终端直播;并且能够将视频源的直播数据对接到第三方视频平台、CDN网络,实现互联网直播分发;同时能实时云端录像、检索、回放。
Stars: ✭ 39 (+143.75%)
Mutual labels:  rtsp-server
live555ProxyServerEx
Improved version of the "LIVE555 Proxy Server"
Stars: ✭ 35 (+118.75%)
Mutual labels:  live555
rtsp-video-server
RTSP video streaming server implementation based on Live555 and FFmpeg
Stars: ✭ 36 (+125%)
Mutual labels:  live555
Easydarwin
open source、high performance、industrial rtsp streaming server,a lot of optimization on streaming relay,KeyFrame cache,RESTful,and web management,also EasyDarwin support distributed load balancing,a simple streaming media cloud platform architecture.高性能开源RTSP流媒体服务器,基于go语言研发,维护和优化:RTSP推模式转发、RTSP拉模式转发、录像、检索、回放、关键帧缓存、秒开画面、RESTful接口、WEB后台管理、分布式负载均衡,基…
Stars: ✭ 5,183 (+32293.75%)
Mutual labels:  rtsp-server
Libstreaming
A solution for streaming H.264, H.263, AMR, AAC using RTP on Android
Stars: ✭ 3,167 (+19693.75%)
Mutual labels:  rtsp-server

Live264Streamer

A Project To Study Stream H264 Video With Live555

Travis Travis Travis

Introduction

学习多媒体相关知识,相机/音视频编解码/网络直播RTSP等

实现功能

  • 使用RTSP共享设备屏幕录屏
  • 使用RTSP共享相机视频直播
  • 扫码播放RTSP直播

下载体验

Screenshot

Stream Push VLC Play VLC Play
screenshot screenshot screenshot

涉及知识点

  • 屏幕录像并将其硬编成H264:
  1. 操作屏幕录像需要Android5.0以上支持,录制之前会弹出动态权限申请弹框。
mProjectionManager = (MediaProjectionManager)getSystemService(Context.MEDIA_PROJECTION_SERVICE);
startActivityForResult(mProjectionManager.createScreenCaptureIntent(), REQUEST_CODE);
  1. 在onActivityResult返回的resultCode和resultData可用于获取MediaProjection,使用MediaProjection和硬编码器创建的surface, 就可以创建一个VirtualDisplay,且VirtualDisplay显示内容会被源源不断送到编码器编码,直到MediaProjection.stop():
mMediaCodec = MediaCodec.createEncoderByType(MIME_TYPE);
Surface surface = mMediaCodec.createInputSurface();
mMediaProjection = projectionManager.getMediaProjection(resultCode, resultData);
mVirtualDisplay = mMediaProjection.createVirtualDisplay("H264VDisplay",
                    width, height, dpi,
                    DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION,
                    surface, null, null);
  • 摄像头拍摄并硬编码H264:
  1. YUV格式帧数据:
I420(YUV420P) YV12(YUV420P) NV12(YUV420SP) NV21(YUV420SP)
YYYYYYYYUUVV YYYYYYYYVVUU YYYYYYYYUVUV YYYYYYYYVUVU

摄像头采集的NV21帧数据转换成H264硬编码器输入使用的YUV420SemiPlanar。 对于转换操作,可以引入Libyuv库来操作,也可以用java方式。实际操作就是UV互换, 把VUVU转换为UVUV。(假如想让输出的图像变成黑白,只需要把U和V都写死成-128即可)

Camera.Parameters parameters = this.mCamera.getParameters();
parameters.setPreviewFormat(ImageFormat.NV21);  //摄像头配置
...
int colorFormat = MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar;
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, colorFormat); //编码器配置
...
// 转换操作
private void swapNV21toI420SemiPlanar(byte[] source, int width, int height) {
    for (int i = width * height; i < source.length; i += 2) {
        byte temp = source[i];
        source[i] = source[i + 1];
        source[i + 1] = temp;
    }
}
  • 硬编码器使用
  1. Android4.1之后Android系统才统一了硬件编解码接口。 硬件编码的过程类似于我们过机场安检,安检机配套了若干装物品的塑料盒子,我们把需要处理的物品放进盒子。 安检过程不需要我们处理,只需要到出口轮询并从的盒子里拿走已处理完的物品即可。 Android系统硬件编码器也提供了若干这样的盒子,便是输入缓冲队列和输入缓冲队列,我们把要编码的数据放到 可用的输入缓冲去,再到输出缓冲区取处理好的数据即可。
MediaCodec codec = MediaCodec.createByCodecName(name);
codec.start();
for (;;) {
    // 写入输入缓冲区
    int inputBufferId = codec.dequeueInputBuffer(timeoutUs);
    if (inputBufferId >= 0) {
        ByteBuffer inputBuffer = codec.getInputBuffer(…);
        // fill inputBuffer with valid data
        …
        codec.queueInputBuffer(inputBufferId, …);
    }
    // 读取输出缓冲区
    int outputBufferId = codec.dequeueOutputBuffer(…);
    if (outputBufferId >= 0) {
        ByteBuffer outputBuffer = codec.getOutputBuffer(outputBufferId);
        MediaFormat bufferFormat = codec.getOutputFormat(outputBufferId); // option A
        // bufferFormat is identical to outputFormat
        // outputBuffer is ready to be processed or rendered.
        …
        codec.releaseOutputBuffer(outputBufferId, …);
    }
}
  1. Android5.0以后系统提供了异步回调模式,
MediaCodec codec = MediaCodec.createByCodecName(name);
codec.setCallback(new MediaCodec.Callback() {
    @Override
    void onInputBufferAvailable(MediaCodec mc, int inputBufferId) {
    ByteBuffer inputBuffer = codec.getInputBuffer(inputBufferId);
    // fill inputBuffer with valid data
    …
    codec.queueInputBuffer(inputBufferId, …);
    }

    @Override
    void onOutputBufferAvailable(MediaCodec mc, int outputBufferId, …) {
    ByteBuffer outputBuffer = codec.getOutputBuffer(outputBufferId);
    MediaFormat bufferFormat = codec.getOutputFormat(outputBufferId); // option A
    // bufferFormat is equivalent to mOutputFormat
    // outputBuffer is ready to be processed or rendered.
    …
    codec.releaseOutputBuffer(outputBufferId, …);
    }
});

Dependencies

Reference

About Me

Contact To Me

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].