Streampunk / beamcoder

Node.js native bindings to FFmpeg.
GNU General Public License v3.0
392 stars 76 forks source link

RTSP and openIO #76

Closed samyhocine closed 2 years ago

samyhocine commented 2 years ago

Hi,

I'm trying to connect to an RTSP server by using this:

await mux.openIO({
      url: 'rtsp://127.0.0.1:7554/cam',
      options: {
          rtsp_transport: 'udp'
      }
    }).then(successCallback, failureCallback);

But then I got this error:

Failure: Error: In file ../src/mux.cc on line 203, found error: Problem opening IO context: Protocol not found PID 137823 received SIGSEGV for address: 0x90

The rtsp server is up.

Everything is fine when I use instead:

await mux.openIO({
      url: 'file:out.mp4'
    }).then(successCallback, failureCallback);

The full code bellow (foo test code):

const beamcoder = require('beamcoder');

async function run() {

    console.log(beamcoder.logging());
    beamcoder.logging('trace');
    console.log(beamcoder.logging());

    let encoding_params = {
      name: 'libx264rgb',
      width: 800,
      height: 600,
      bit_rate: 3000000,
      time_base: [1, 30],
      framerate: [30, 1],
      gop_size: 10,
      max_b_frames: 0,
      pix_fmt: 'rgb24',
      priv_data: { preset: 'slow' }
    };

    let encoder = await beamcoder.encoder(encoding_params);
    // console.log('Encoder', encoder);

    const mux = beamcoder.muxer({ format_name: 'mp4' });
    let vstr = mux.newStream({
      name: 'h264',
      time_base: [1, 90000],
      interleaved: true }); // Set to false for manual interleaving, true for automatic
    Object.assign(vstr.codecpar, {
      width: 800,
      height: 600,
      format: 'rgb24'
    });
    function successCallback(result) {
        console.log("Success: " + result);
    }

    function failureCallback(error) {
        console.error("Failure: " + error);
    }

    // console.log(vstr);
    await mux.openIO({
      url: 'rtsp://127.0.0.1:7554/cam',
      options: {
          rtsp_transport: 'udp'
      }
    }).then(successCallback, failureCallback);

    await mux.writeHeader();
}

run();

Is it really possible to connect to an rtsp server ?

Best regards,

samyhocine commented 2 years ago

Solved with:

const mux = beamcoder.muxer({ format_name: 'rtsp' });

And

    // console.log(vstr);
    await mux.openIO({
      url: 'rtsp:127.0.0.1:7554/cam',
      options: {
          rtsp_transport: 'udp'
      }
    }).then(successCallback, failureCallback);

    await mux.writeHeader();

I have now:

Failure: Error: In file ../src/mux.cc on line 203, found error: Problem opening IO context: Protocol not found [tcp @ 0x7f0bcc000ec0] No default whitelist set [tcp @ 0x7f0bcc000ec0] Original list of addresses: [tcp @ 0x7f0bcc000ec0] Address 127.0.0.1 port 7554 [tcp @ 0x7f0bcc000ec0] Interleaved list of addresses: [tcp @ 0x7f0bcc000ec0] Address 127.0.0.1 port 7554 [tcp @ 0x7f0bcc000ec0] Starting connection attempt to 127.0.0.1 port 7554 [tcp @ 0x7f0bcc000ec0] Successfully connected to 127.0.0.1 port 7554 [rtsp @ 0x33a82c0] Sending: OPTIONS rtsp://127.0.0.1:7554/cam RTSP/1.0 OPTIONS rtsp://127.0.0.1:7554/cam RTSP/1.0 CSeq: 1 User-Agent: Lavf58.29.100

-- [...]