node-rtsp-recorder icon indicating copy to clipboard operation
node-rtsp-recorder copied to clipboard

Recorded video and audio files are not playing

Open uzenith360 opened this issue 5 years ago • 17 comments

Hi,

I've been having quite a painful time recording my ip camera rtsp stream, the recorded audio/video files arent playing. Please i need some help.

I'm using a windows 10 x64 machine.

Thanks so much.

uzenith360 avatar May 17 '19 12:05 uzenith360

I noticed that some of the last files before the timeout (in the code example) could play, the rest couldnt

uzenith360 avatar May 17 '19 18:05 uzenith360

While running one of the files that didnt play through ffmpeg, i get the following error: "moov atom not found". Could the issue be from the way the file was closed? sdsd

uzenith360 avatar May 17 '19 18:05 uzenith360

Was this resolved??

Cain310 avatar May 23 '19 17:05 Cain310

No it wasnt. I tried experimenting with ffmpeg and i got the mp4 recorded files, but it was with the command line and quite unwieldy. I'm trying to work out a cleaner way to achieve that maybe with the an npm ffmpeg module or spawning an ffmpeg process anytime i need to record my ip camera rtsp stream. I used the following command line arguments with ffmpeg; ffmpeg -i rtsp://192.168.0.103/live/ch00_1 -f mp4 -t 20 -c:v libx264 -preset veryfast -c:a aac summary4.mp4 -hide_banner - rtsp://192.168.0.103/live/ch00_1 is my ip camera live rtsp stream and summary4.mp4 is the name of the output mp4 video file, -t 20 specifies that the video should be 20 seconds long. You can get more info from the follow links [https://www.bugcodemaster.com/article/convert-videos-mp4-format-using-ffmpeg], [https://www.bugcodemaster.com/article/how-extract-and-join-video-files-using-ffmpeg]. Cheers!

uzenith360 avatar May 23 '19 21:05 uzenith360

At a point i realised the issue with the node-rtsp-recorder was that it wasnt ending the mp4 files properly. The mp4 files need some metadata information in order to play but the module was apparently closing the files without including those information hence the files it generated couldnt be played.

uzenith360 avatar May 23 '19 22:05 uzenith360

I figured this out. I will make a pull request. The correct tags are needed.

Cain310 avatar May 29 '19 23:05 Cain310

I figured this out. I will make a pull request. The correct tags are needed.

Was this solved? Getting the same result. Thanks

Skullcan avatar Jul 29 '19 23:07 Skullcan

https://github.com/Cain310/securityCam-demo

On Mon, Jul 29, 2019, 7:36 PM Skullcan [email protected] wrote:

I figured this out. I will make a pull request. The correct tags are needed.

Was this solved? Getting the same result. Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sahilchaddha/node-rtsp-recorder/issues/9?email_source=notifications&email_token=ALIXJ2VOIVR5KFID4JGJWHTQB55IZA5CNFSM4HNU5XHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3CJ2AQ#issuecomment-516201730, or mute the thread https://github.com/notifications/unsubscribe-auth/ALIXJ2XAEZTLYIBAIU2VTG3QB55IZANCNFSM4HNU5XHA .

Cain310 avatar Jul 30 '19 00:07 Cain310

https://github.com/Cain310/securityCam-demo On Mon, Jul 29, 2019, 7:36 PM Skullcan @.***> wrote: I figured this out. I will make a pull request. The correct tags are needed. Was this solved? Getting the same result. Thanks — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#9?email_source=notifications&email_token=ALIXJ2VOIVR5KFID4JGJWHTQB55IZA5CNFSM4HNU5XHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3CJ2AQ#issuecomment-516201730>, or mute the thread https://github.com/notifications/unsubscribe-auth/ALIXJ2XAEZTLYIBAIU2VTG3QB55IZANCNFSM4HNU5XHA .

Ok, thank you very much!

Skullcan avatar Jul 30 '19 01:07 Skullcan

I tryed to fix, but I have the problem again, my file is corrupted

mbDilepix avatar Dec 23 '19 13:12 mbDilepix

my solution: in record.js replace kill stream method to killStream() { this.writeStream.stdin.write('q') } and

get child process to

getChildProcess(fileName) { var args = ['ffmpeg', '-rtsp_transport','tcp','-i', this.url] const mediaArgs = this.getArguments() mediaArgs.forEach((item) => { args.push(item) }); args.push(fileName) console.log("args", args.join(' ')) return childProcess.exec(args.join(' '), function(err, stdout, stderr) {}) }

kraiymbek avatar Feb 18 '20 19:02 kraiymbek

one quick fix is to change output format on recorder.js

replace -- return '.mp4'

with ++ return '.mov'

the problem could be rooted to a codec issue with .mp4

leodesigndev avatar Jun 05 '21 20:06 leodesigndev

@leodesigndev ur solution didnt work for me :(

lakshaydulani avatar Aug 17 '21 08:08 lakshaydulani

Maybe someone will need it, my gist. Tested only under windows 10

  • make sure the ffmpeg command is available from the console
  • ... other requirements

lablist avatar Nov 24 '21 16:11 lablist

the .mp4 file was corrupted, I tried changing it to .mkv and it worked. You can try to change in file /node_modules/node-rtsp-recorder/src/helpers/recorder.js and edit in getExxtension() function, change .mp4 file name to .mkv getExtension(){ if (this.categoryType === 'audio') { return '.avi'
} if (this.categoryType === 'image') { return '.jpg' } return '.mkv' }

anhuong98 avatar Dec 21 '22 06:12 anhuong98

my solution: in record.js replace kill stream method to killStream() { this.writeStream.stdin.write('q') } and

get child process to

getChildProcess(fileName) { var args = ['ffmpeg', '-rtsp_transport','tcp','-i', this.url] const mediaArgs = this.getArguments() mediaArgs.forEach((item) => { args.push(item) }); args.push(fileName) console.log("args", args.join(' ')) return childProcess.exec(args.join(' '), function(err, stdout, stderr) {}) }

Thanks your so much!

nitdev avatar Apr 13 '23 17:04 nitdev

this module just copy raw rtsp encoding, it is not mp4, I think the point is just to record the stream. To play the file must be encode first to let say mpeg

ffmpeg -i recorded.mp4 -f mpegts -c:v mpeg1video playable.mp4

it works for me

anton78bon avatar May 06 '23 14:05 anton78bon