Skip to content

How do i stop streaming after i finished capturing my video #139

Open
@Tsolmonx

Description

@Tsolmonx

Hi im pretty new to this and might be doing it wrong and help will be useful.

    public function __invoke(Stream $message)
    {
        $projectDir = $this->parameterBag->get('kernel.project_dir');
        $config = [
            'ffmpeg.binaries'  => '/opt/homebrew/bin/ffmpeg',
            'ffprobe.binaries' => '/opt/homebrew/bin/ffprobe',
            'timeout'          => 3600, // The timeout for the underlying process
            'ffmpeg.threads'   => 12,   // The number of threads that FFmpeg should use
        ];

        $log = new Logger('FFmpeg_Streaming');

        $log->pushHandler(new StreamHandler($projectDir . '/var/log/ffmpeg-streaming.log')); // path to log file

        $r_480p  = (new Representation)->setKiloBitrate(750)->setResize(720, 360);

        $ffmpeg = FFMpeg::create($config, $log);

        $capture = $ffmpeg->capture('FaceTime HD Camera', '0', ['framerate'=> 30,]);
        $capture->hls()
                ->x264()
                ->addRepresentation($r_480p)
                ->save('public/stream/hls-stream.mpd');

    }

I needed to make some live streaming service on my symfony backend and I wrote above code reading the docs and from and api call i start capturing video and saving hls file to public dir and client can see the video that im streaming http://localhost:8000/stream/hls-stream_360p.m3u8 and it works fine.
Problem is how do i finish my recording. i had to shut down the server to stop the recording. any help ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions