使用RTMP + LFLiveKit的iOS Facebook Live视频

时间:2017-08-21 16:30:16

标签: ios facebook video-streaming live rtmp

我从资产视频到LFLiveSession.pushVideo(BufferFrame)开发了Facebook直播视频选项,但最后直播视频看起来非常模糊。

所以我更新会话以使用H264编码Facebook所需的内容。还遵循其他Facebook直播视频流规则,直播30fps,2秒内关键帧,最大比特率4mbps等。还尝试了差异比特率和fps的差异视频。

由于我使用的是H246编码器,因此质量有所改善,但不是100%,视频中仍然有很多噪音。

注意:我通过将像素缓冲区推送到RTMP会话的资产视频来实现。

任何帮助都会表示赞赏。

谢谢!

enter image description here

代码编辑2:

var session: LFLiveSession = {
        let audioConfiguration = LFLiveAudioConfiguration.defaultConfiguration(for: LFLiveAudioQuality.high)
        let videoConfiguration = LFLiveVideoConfiguration.defaultConfiguration(for: LFLiveVideoQuality.high3, outputImageOrientation: .landscapeLeft)
        let session = LFLiveSession(audioConfiguration: audioConfiguration, videoConfiguration: videoConfiguration, captureType: LFLiveCaptureTypeMask.captureDefaultMask)

        return session!
    }()

func displayLinkDidRefresh(link: CADisplayLink) {
    let itemTime = videoOutput.itemTime(forHostTime: CACurrentMediaTime())

    if videoOutput.hasNewPixelBuffer(forItemTime: itemTime) {
        if let pixelBuffer = videoOutput.copyPixelBuffer(forItemTime: itemTime, itemTimeForDisplay: nil){
            self.session.pushVideo(pixelBuffer)
        }
    }
}
session.startLive(stream)

视频通过输入掩码,音频通过麦克风

LFLiveCaptureDefaultMask = (LFLiveCaptureMaskAudio | LFLiveInputMaskVideo)

配置:

case LFLiveVideoQuality_High3:{
    configuration.sessionPreset = LFCaptureSessionPreset720x1280;
    configuration.videoFrameRate = 30;
    configuration.videoMaxFrameRate = 30;
    configuration.videoMinFrameRate = 15;
    configuration.videoBitRate = 1200 * 1000;
    configuration.videoMaxBitRate = 1440 * 1000;
    configuration.videoMinBitRate = 500 * 1000;
    configuration.videoSize = CGSizeMake(720, 1280);
}

编辑3:

    let stream = LFLiveStreamInfo()
    stream.url = fbLive.url!
    print("rtmp :\(fbLive.url!)")
    session.startLive(stream)

0 个答案:

没有答案