GithubHelp home page GithubHelp logo

chenliming777 / lmlivestreaming Goto Github PK

View Code? Open in Web Editor NEW
777.0 777.0 223.0 8.09 MB

IOS Live,H264 and AAC Hard coding,support GPUImage Beauty, rtmp and flv transmission,weak network lost frame,Dynamic switching rate

Objective-C 99.72% Ruby 0.28%

lmlivestreaming's Introduction

Build Status  License MIT  CocoaPods  Support 

platform 

LFLiveKit(https://github.com/LaiFengiOS/LFLiveKit)

LFLiveKit IOS mobile phone push code,Default format support RTMP and FLV,At the same time, the structure is very easy to extend.

Podfile To integrate LFLiveKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'LFLiveKit'

Then, run the following command:
$ pod install

Functional

Background recording
Support horizontal vertical recording
GPUImage Beauty
H264 Hard coding
AAC Hard coding
Weak network lost frame
Dynamic switching rate
Audio configuration
Video configuration
RTMP Transport
Switch camera
Audio Mute
Support Send Buffer
FLV package and send

Architecture

capture: LFAudioCapture and  LFVideoCapture
encode:  LFHardwareAudioEncoder and LFHardwareVideoEncoder
publish: LFStreamRtmpSocket LFStreamTcpSocket

Usage

- (LFLiveSession*)session{
    if(!_session){
        _session = [[LFLiveSession alloc] initWithAudioConfiguration:[LFLiveAudioConfiguration defaultConfiguration] videoConfiguration:[LFLiveVideoConfiguration defaultConfiguration] liveType:LFLiveRTMP];
        _session.running = YES;
        _session.preView = self;
        }
    return _session;
}

- (LFLiveSession*)session{
    if(!_session){
        LFLiveAudioConfiguration *audioConfiguration = [LFLiveAudioConfiguration new];
        audioConfiguration.numberOfChannels = 2;
        audioConfiguration.audioBitrate = LFLiveAudioBitRate_128Kbps;
        audioConfiguration.audioSampleRate = LFLiveAudioSampleRate_44100Hz;

        LFLiveVideoConfiguration *videoConfiguration = [LFLiveVideoConfiguration new];
        videoConfiguration.videoSize = CGSizeMake(1280, 720);
        videoConfiguration.videoBitRate = 800*1024;
        videoConfiguration.videoMaxBitRate = 1000*1024;
        videoConfiguration.videoMinBitRate = 500*1024;
        videoConfiguration.videoFrameRate = 15;
        videoConfiguration.videoMaxKeyframeInterval = 30;
        videoConfiguration.orientation = UIInterfaceOrientationLandscapeLeft;
        videoConfiguration.sessionPreset = LFCaptureSessionPreset720x1280;

        _session = [[LFLiveSession alloc] initWithAudioConfiguration:audioConfiguration 				videoConfiguration:videoConfiguration liveType:LFLiveRTMP];
        _session.running = YES;
        _session.preView = self;
    }
    return _session;
}

LFLiveStreamInfo *streamInfo = [LFLiveStreamInfo new];
streamInfo.url = @"your server rtmp url";
[self.session startLive:streamInfo];
[self.session stopLive];

CallBack:

- (void)liveSession:(nullable LFLiveSession *)session liveStateDidChange: (LFLiveState)state;
- (void)liveSession:(nullable LFLiveSession *)session debugInfo:(nullable LFLiveDebug*)debugInfo;
- (void)liveSession:(nullable LFLiveSession*)session errorCode:(LFLiveSocketErrorCode)errorCode;

License

LFLiveKit is released under the MIT license. See LICENSE for details.

################ 前引:目前直播包含采集端与播放端,播放端目前开源比较好用的是bilibili播放器,网址为https://github.com/Bilibili/ijkplayer,支持了很多的格式,其中包含了RTMP格式,非常的👍

起因:我这里处理的是音视频采集端,目前开源社区比较火的是LiveVideoCoreSDK(https://github.com/search?utf8=✓&q=LiveVideoCore&type=Repositories&ref=searchresults),其中借鉴了videoCore(https://github.com/jgh-/VideoCore),这个外国人写的,但无奈都是C++,ios采集这边目前一般都是SDK,当前我也是借鉴了很多的SDK与VideoCore,写了目前这个LMLiveStreaming。

架构:分为采集--->编码--->打包上传 我这边为了更好的扩展,在编码打包以及上传这几个模块通过协议抽象了相关的方法,在滤镜方面用的GPUImage,美颜大家可以参考BeautifyFaceDemo(https://github.com/Guikunzhi/BeautifyFaceDemo)

服务器搭建: 对于初学直播的同学没有RTMP服务器还真。。。,这里简单介绍一下RTMP+nginx服务器。 首先下载nginx源码,去nginx.org下载,其次下载nginx-rtmp-module-master(https://github.com/arut/nginx-rtmp-module)代码,再去下载openssl(openssl.org),然后修改openssl makefile,将PLATFORM=dist改为PLATFORM=darwin64-x86_64-cc,然后cd到nginx源码目录,执行export KERNEL_BITS=64 然后再执行./configure --add-module= nginx-rtmp-module-masterde的路径 --with-openssl= oepnssl源码路径,然后make install.最后查找nginx.conf默认只支持http,添加下面代码再次启动就好了。

rtmp {
    server {
            listen 1935;

        #点播配置
                application vod {
                    play /opt/media/nginxrtmp/flv;
                }
        
        #直播流配置
            application live {
                    live on;
            #为 rtmp 引擎设置最大连接数。默认为 off
            max_connections 1024;

                    # default recorder
                    record all;
                    record_path /var/rec;
 
                    recorder audio {
                         record audio;
                         record_suffix -%d-%b-%y-%T.flv;
                    } 

                    recorder chunked {
                        record all;
                         record_interval 15s;
                         record_path /var/rec/chunked;
                    }

            #on_publish http://localhost:8080/publish;  
            #on_play http://localhost:8080/play;  
            #on_record_done http://localhost:8080/record_done;
            
            #rtmp日志设置
             #access_log logs/rtmp_access.log new;
             #access_log logs/rtmp_access.log;
             #access_log off;

             }
        
        #HLS协议支持
        #application hls {  
            #live on;  
            #hls on;  
            #hls_path /tmp/app;  
            #hls_fragment 5s;  
        #} 

            application hls{
        
                    live on;
                    hls on;
                    hls_path /usr/local/nginx/html/app;
                    hls_fragment 1s;
            }
 

    }
}

lmlivestreaming's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lmlivestreaming's Issues

lflivekit 收不到 错误码

在你这个项目中 在代理方法中 ,我收不到lflivekit的错误提示 - (void)liveSession:(nullable LFLiveSession*)session errorCode:(LFLiveSocketErrorCode)errorCode; 不知道是为什么 作者你试过吗 比如随便填一个地址

LFStreamingSessionDelegate

#pragma mark -- LFStreamingSessionDelegate
/** live status changed will callback */
- (void)liveSession:(nullable LFLiveSession *)session liveStateDidChange:(LFLiveState)state{
    switch (state) {
        /// 准备
        case LFLiveReady:
            break;
        /// 连接中
        case LFLivePending:
            break;
        /// 已连接
        case LFLiveStart:
            break;
        /// 已断开
        case LFLiveStop:
            break;
        /// 连接出错
        case LFLiveError:
            break;
        default:
            break;
    }

}

关闭直播,为何不会LFLiveStop?

连续切换推流断流会发生异常

bug场景复现:持续点击开始关闭直播按钮时推流地址会发生异常
错误异常如下:
libsystem_kernel.dylibmach_msg_trap:
0x180db4fd0 <+0>: movn x16, #0x1e
0x180db4fd4 <+4>: svc #0x80
-> 0x180db4fd8 <+8>: ret `
应用场景:
直播时候切换到后台需要停止推流,然后再切换到前台需要再次推流。
感觉是socket问题。
希望作者能看看($ ^ $)

pod insatll can not find header file

新建工程引入pod 'LFLiveKit', '~> 1.6',pod update 之后 build 工程
"openssl/bn.h" file not found
Could not build module "pill_librtmp"

麦克风被占用了,恢复不过来了。

在推流过程中,微信视频,麦克风会被抢占,关闭微信返回程序时,推流音频没有了。你们咋处理的?销毁LFLiveSession,再创建一个吗?

ipv6推流失败

在向不支持ipv6的cdn,用支持ipv6方式,推流失败。这个原因会是什么?

希望添加一个滤镜功能!

项目中经常会用到滤镜的功能,希望可以实现自定义滤镜的功能!如果是给yuv或RGB像素数据添加滤镜,请问在当前的项目中最好是在哪一块修改呢,谢谢!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.