fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.85k stars 874 forks source link

Is possible to input a media stream / media stream tracks? #1259

Open Seikon opened 6 months ago

Seikon commented 6 months ago

I was wondering if it could be possible set input as a MediaStream or MediaStreamTrack object and output to video or hls server, etc. like this:

const mediaStream = event.streams[0];

    // Extract video and audio tracks from the media stream
    const videoTrack = mediaStream.getVideoTracks()[0];
    const audioTrack = mediaStream.getAudioTracks()[0];

    // Create FFmpeg process to generate HLS stream
    const ffmpegCommand = ffmpeg()
        .input(videoTrack)
        .input(audioTrack)
        .videoCodec('copy')
        .audioCodec('aac')
        .format('hls')
        .outputOptions([
            '-hls_time 10',
            '-hls_list_size 6',
            '-hls_segment_filename output_%03d.ts',
            'output.m3u8'
        ])
        .output('output.m3u8');