illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.9k stars 1.51k forks source link

Record to FLV? #160

Open mertyildiran opened 5 years ago

mertyildiran commented 5 years ago

Is it possible to record in FLV format? I would like to record in FLV format because if something goes wrong and MP4 does not finish properly then it becomes corrupted:

[1] Error while processing: ffprobe exited with code 1
[1] ffprobe version 4.1-1~18.04.york0 Copyright (c) 2007-2018 the FFmpeg developers
[1]   built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
[1]   configuration: --prefix=/usr --extra-version='1~18.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
[1]   libavutil      56. 22.100 / 56. 22.100
[1]   libavcodec     58. 35.100 / 58. 35.100
[1]   libavformat    58. 20.100 / 58. 20.100
[1]   libavdevice    58.  5.100 / 58.  5.100
[1]   libavfilter     7. 40.101 /  7. 40.101
[1]   libavresample   4.  0.  0 /  4.  0.  0
[1]   libswscale      5.  3.100 /  5.  3.100
[1]   libswresample   3.  3.100 /  3.  3.100
[1]   libpostproc    55.  3.100 / 55.  3.100
[1] [mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e93a545080] moov atom not found
[1] /home/mertyildiran/Documents/Cloudtivi4/uploads/live-1547622167480.mp4: Invalid data found when processing input
[1] 
[1] 1/16/2019 10:02:53 4878 [INFO] [rtmp publish] Close stream. id=S8BREDHP streamPath=/live/5c3c71eca396b356e4de2f90_xQRJrfnK3XblNkElRt8MgbLqOdTFfapq streamId=1
[1] [NodeEvent on donePublish] id=S8BREDHP StreamPath=/live/5c3c71eca396b356e4de2f90_xQRJrfnK3XblNkElRt8MgbLqOdTFfapq args={"ac":10,"vc":7}

FLV format does not have such a problem.

mertyildiran commented 5 years ago

By looking this file I can say FLV format is not supported. Could we add FLV support to this library?

illuspas commented 5 years ago

Look at the dev branch, native support for FLV record. Will be merged into the mainline in the future

mertyildiran commented 5 years ago

@illuspas I sent this PR but it become redundant then :blush:

If you are talking about this merge then I cannot see anything related to recording on there. Don't we need a flv: true option in config? I have added that with my PR. Do you want me to send that PR into dev branch?

illuspas commented 5 years ago

This feature should be more comprehensive, like nginx-rtmp record function is configurable. I don't have much free time these days. Maybe you can do it 😄

mertyildiran commented 5 years ago

@illuspas yeah, I have some experience on nginx-rtmp. I'm using my PR on an application and it works just fine. What else should I implement to make it more comprehensive? If you explain a little bit more in detail then I can add the necessary code blocks for you.

Do you want a more configurable recording functionality like in nginx-rtmp#Record? Like recording only audio, keyframes or specifying a file name pattern? Please list the features and I will try to implement them.