Open rodrigosalinas opened 8 years ago
Hello! Can you send me full demo example? And what did you mean when you said about 'on' event of the stream object?
Thanks for your response. I'm using your server example as is. No change but the urls for the streams.
Do you mean that when you change sources to your ip-cams nothing works?
Whether I change it or not. Is the same. The event that never get fired is the
Oh, now I understand. Are you sure that this is wright rstp stream? Try to check it with vlc and ffmpeg with corresponding params
This url I open it in VLC with no problem: rtsp://192.168.1.48:554/profile1
This is my code:
const app = require('express')(),
server = require('http').Server(app),
io = require('socket.io')(server),
rtsp = require('rtsp-ffmpeg');
server.listen(6147);
var uri = 'rtsp://192.168.1.48:554/profile1';
var stream = new rtsp.FFMpeg({input: uri});
io.on('connection', function(socket) {
console.log("Connected.");
var pipeStream = function(data) {
console.log("Stream arrived.");
socket.emit('data', data.toString('base64'));
};
stream.on('data', pipeStream);
socket.on('disconnect', function() {
console.log("Disconnected.");
stream.removeListener('data', pipeStream);
});
});
app.get('/', function (req, res) {
res.sendFile(__dirname + '/public/index.html');
});
Are you're sure that rtsp://192.168.1.48:554/profile1 is pure rtsp stream that can be processed with ffmpeg?
How do you advise me to check that? That URL I open in VLC with no problem.
In fact, if I just open rtsp://192.168.1.48 in VLC, it also works. But not with the code.
And what is the result of ffmpeg -i rtsp://192.168.1.48 -f image2 -updatefirst 1
?
This was the result:
ffmpeg version N-69438-gb47ab04 Copyright (c) 2000-2015 the FFmpeg developers
built on Jan 31 2015 10:37:29 with gcc 4.9.1 (Ubuntu 4.9.1-16ubuntu6)
configuration: --enable-shared --disable-static
libavutil 54. 18.100 / 54. 18.100
libavcodec 56. 21.101 / 56. 21.101
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 9.103 / 5. 9.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
Trailing options were found on the commandline.
[rtsp @ 0xb1f3a0] UDP timeout, retrying with TCP
[rtsp @ 0xb1f3a0] method PAUSE failed: 405 Method Not Allowed
[rtsp @ 0xb1f3a0] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Input #0, rtsp, from 'rtsp://192.168.1.48':
Metadata:
title : \profile1
Duration: N/A, start: 0.000000, bitrate: 128 kb/s
Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
Stream #0:2: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
At least one output file must be specified
Seems that it is failure with your rtsp stream. Just try to fix them with different ffmpeg arguments that you can later pass to the consturtuctor of rtsr.FFMpeg as an argument
Thank you very much anyway. Can I ask your ffmpeg version? Apparently there are some issues with the latest versions.
Hi. Finally this command worked for me to get a snapshot:
ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.48:554/profile1 -map 0:0 -y -updatefirst 1 -q 31 -frames 1 -f image2 camera.jpg
How can I translate that to rtsp-ffmpeg? Thank you very very much.
Oh, this is simple, just look at https://github.com/agsh/rtsp-ffmpeg/blob/master/lib/rtsp-ffmpeg.js#L74 add all missing arguments in array in style of spawn
node.js method https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
Hi. One last time. ¿Like this?
var uri = 'rtsp://192.168.1.48:554/profile1';
var stream = new rtsp.FFMpeg({input: uri}, ['-rtsp_transport', 'tcp', '-map', '0:0', '-frames', '1', '-q', '1']);
And one more thing. I need the -rtsp_transport
argument to be first in the list of arguments, otherwise it doesn't work. It has to be in front of the -i
argument.
Ok, I'll fix it in the next few days
Moved additional options to be first in the list of arguments. You can try either npm version or github master branch. But you should use constructor like this:
var uri = 'rtsp://192.168.1.48:554/profile1';
var stream = new rtsp.FFMpeg({input: uri, arguments: ['-rtsp_transport', 'tcp', '-map', '0:0', '-frames', '1']});
Please try this and comment what happens.
Hi agsh, thank you for your interest. I still can't get the snapshot, or the streaming for my camera, with your updated code. Let me show you the log when I invoke ffmpeg in the console. Perhaps that can help:
ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.48:554/profile1 -map 0:0 -y -updatefirst 1 -q 0 -frames 1 -f image2 camera.jpg
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Input #0, rtsp, from 'rtsp://192.168.1.48:554/profile1':
Metadata:
title : \profile1
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 1920x1080, 30 fps, 30 tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
Stream #0:2: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
[swscaler @ 0x7fc9ac000000] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'camera.jpg':
Metadata:
title : \profile1
encoder : Lavf56.36.100
Stream #0:0: Video: mjpeg, yuvj420p(pc), 1920x1080, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc56.41.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A
video:137kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
I just tried something. Apparently not all optional parameters belongs at the beginning. For what I have read, the order in what the parameters appear instructs ffmpeg to apply them to the input or to the output. So, in my case, -rtsp_transport tcp
belongs to the beginning, but not the map
or frames
options.
Hi, I'm trying to run your server example. Whether I left the URLs unchanged or if I change it to my cameras streams, the socket events fire up as expected, but not the On event of the Stream object. Can you help me pls? My cameras URL are like this: rtsp://192.168.1.48:554/profile1. Thank you.