Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tsolmonx opened this issue Nov 21, 2023 · 0 comments
Open

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

Tsolmonx opened this issue Nov 21, 2023 · 0 comments

Comments

@Tsolmonx
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant