How to record live streaming video?

799 Views Asked by At

I'm using VideoCore library for streaming the live video which is working perfectly.

my requirement is that i want that live streaming video record and store in document directory so anyone can tell me how can i do that?

how can i record live streaming video?

1

There are 1 best solutions below

0
On

I checked library and it looks like the only way to have record function is creation of custom output.

There is Split class which allows to push a buffer to multiple outputs. So you need to create new IOuput implementation with file saving function and add it to flow using that Split class.

Update #1

I found that there is a file output example inside library (VCSimpleSession.mm file):

{
    m_h264Packetizer = std::make_shared<videocore::rtmp::H264Packetizer>(ctsOffset);
    m_aacPacketizer = std::make_shared<videocore::rtmp::AACPacketizer>(self.audioSampleRate, self.audioChannelCount, ctsOffset);

    m_h264Split->setOutput(m_h264Packetizer);
    m_aacSplit->setOutput(m_aacPacketizer);

}
{
    /*m_muxer = std::make_shared<videocore::Apple::MP4Multiplexer>();
     videocore::Apple::MP4SessionParameters_t parms(0.) ;
     std::string file = [[[self applicationDocumentsDirectory] stringByAppendingString:@"/output.mp4"] UTF8String];
     parms.setData(file, self.fps, self.videoSize.width, self.videoSize.height);
     m_muxer->setSessionParameters(parms);
     m_aacSplit->setOutput(m_muxer);
     m_h264Split->setOutput(m_muxer);*/
}

m_h264Packetizer->setOutput(m_outputSession);
m_aacPacketizer->setOutput(m_outputSession);

Try to uncomment it and check.