Copy link to clipboard
Copied
Dear all!
I use ffmepg to push a livestream to my flash media server. Then I want to catchup live stream to file.
/opt/ffmpeg-1.1.1/bin/ffmpeg -i udp://238.1.1.2:1234 -filter:v yadif -acodec libfaac -ac 2 -ar 44100 -b:a 96k -af volume=5 -b:v 1000k -c:v libx264 -preset fast -pix_fmt yuv420p -s 720x476 -r 25 -threads 0 -t 300 -f flv "rtmp://10.84.70.120/dvrcast_origin/vtv22"
After, I create an application that main.asc file is:
application.onConnect = function (){
name = Stream.name();
stream = Stream.get(name);
if(stream){
stream.record();
}
}
I can not catch live stream to file.
Can you show me how to get a live stream name?
Thanks!
Copy link to clipboard
Copied
Hi,
If you want to record your livestream into a file on disk you can try this -
application.onPublish = function(clientObj,streamObj){
trace(" in application publish : " + streamObj.name);
streamObj.record("record");
}
application.onUnpublish = function(clientObj,streamObj){
trace(" on unpublish : " + streamObj.type + ":" + streamObj.name);
streamObj.record(false);
}
Let me know if this helps.
Thanks,
Apurva
Copy link to clipboard
Copied
Thanks Apurva!
I've copy your suggest to file that name is main.asc
But not ok. Can you show me step by step to record a live stream?
I am a fresher with FMS.
Copy link to clipboard
Copied
Here is the full code for main.asc:
application.onConnect=function(clientObj){
trace(" on connect ");
return true;
};
application.onDisconnect=function(clientObj){
trace(" on disconnect ");
};
application.onPublish = function(clientObj,streamObj){
trace(" in application publish : " + streamObj.name);
streamObj.record("record");
}
application.onUnpublish = function(clientObj,streamObj){
trace(" on unpublish : " + streamObj.type + ":" + streamObj.name);
streamObj.record(false);
}
Let me know if this works.
Copy link to clipboard
Copied
Thanks for your answer!
what is the path that file recorded located?
Copy link to clipboard
Copied
It should create a streams folder under the application and record it there. I suggest you first try this with a new application (create a folder say test under root_install/applications and give it write permissions. place the main.asc under it). If it works as you desire, you can adapt it to your setting.
Copy link to clipboard
Copied
I did it as your suggest.
I created a folder "dvrcast_origin/streams" under application folder.
fms/applications/dvrcast_origin/streams
That is permission
drwxrwxrwx 3 fms fms 4096 Apr 5 15:10 streams
and place main.asc to folder "fms/applications/dvrcast_origin".
Then I put livestream from ffmpeg:
/opt/ffmpeg-1.1.1/bin/ffmpeg -i udp://238.1.1.2:1234 -filter:v yadif -acodec libfaac -ac 2 -ar 44100 -b:a 96k -af volume=5 -b:v 1000k -c:v libx264 -preset fast -pix_fmt yuv420p -s 720x476 -r 25 -threads 0 -t 300 -f flv "rtmp://10.84.70.120/dvrcast_origin/vtv22"
I checked the folder "fms/applications/dvrcast_origin/streams"
There is no file.
Thanks
Copy link to clipboard
Copied
That's because you're still publishing to dvrcast_origin/vtv22. You only need to publish to your application, in this case dvrcast_origin. Also, there is no need to create the streams folder. FMS will create it. And the permissions should be given to the application folder, in this case dvrcast_origin.
Copy link to clipboard
Copied
When I publish live stream as the following:
/opt/ffmpeg-1.1.1/bin/ffmpeg -i udp://238.1.1.2:1234 -filter:v yadif -acodec libfaac -ac 2 -ar 44100 -b:a 96k -af volume=5 -b:v 1000k -c:v libx264 -preset fast -pix_fmt yuv420p -s 720x476 -r 25 -threads 0 -f flv "rtmp://10.84.70.120/dvrcast_origin/"
Then there is error:
[rtmp @ 0x121549c0] Server error: Invalid tincan object name (stream ID: 1).
rtmp://10.84.70.120/dvrcast_origin/: Operation not permitted
Why's that?
Copy link to clipboard
Copied
I'm suspecting the problem lies with the ffmpeg command line. As I don't have much experience with it I'm investigating it on my end. In the mean time some suggestions/questions:
1. Could you re-try using the -ru option? for realtime publish
2. Have you compiled the ffmpeg with rtmp libraries?
3. Are you able to record the udp stream onto the disk? (to verify there are no problems with the input stream?
4. Are there any error messages logged in FMS? (core logs/application logs)
Copy link to clipboard
Copied
The error only appeare when there is no stream name in output.
rtmp://10.84.70.120/dvrcast_origin/ --> error
rtmp://10.84.70.120/dvrcast_origin/vtv22 --> ok.
1. Could you re-try using the -ru option? for realtime publish?
2. Have you compiled the ffmpeg with rtmp libraries?
I can publish without error as the format above. So it is not problem.
3. Are you able to record the udp stream onto the disk? (to verify there are no problems with the input stream? --> I've test with input without FMS. It's ok.
4. Are there any error messages logged in FMS? (core logs/application logs)
There is no error log file in logs/ folder.
When I test with Flash media live encoder. I press "record" button. Everything is ok.
The problem only appeare when I put stream with ffmpeg .
Is there special anyconfig that effect it?
Copy link to clipboard
Copied
Dear all!
I have edit my main.asc file as following.
FMS have created the folder streams/_definst_ that contain *.flv.
But the file size is not changing during push stream to FMS.
Any idea for this.
Thanks.
application.onConnect=function(clientObj){
trace("on connect ");
return true;
}
function debug( output )
{
if (application.debugTrace)
{
trace("###### " + output + " ######");
}
}
application.onDisconnect=function(clientObj){
trace("on disconnect ");
}
Client.prototype.FCPublish = function( name )
{
debug("Inside FCPublish - stream name: " + name);
this.call("onFCPublish", null, {code:"NetStream.Publish.Start", description:name});
}
Client.prototype.FCUnpublish = function( name )
{
debug("Inside FCUnpublish - stream name: " + name);
this.call("onFCUnpublish", null, {code:"NetStream.Unpublish.Success", description:name});
}
Client.prototype.releaseStream = function( name )
{
debug("Inside releaseStream - stream name: " + name);
//add alternate function to release a stream
stream = Stream.get(name);
if (stream)
{
stream.play(false);
}
}
application.onPublish = function(clientObj,streamObj){
streamObj= Stream.get(streamObj.name);
trace("in application publish : " + streamObj.name);
streamObj.record("record");
}
application.onUnpublish = function(clientObj,streamObj){
trace("on unpublish : " + streamObj.type + ":" + streamObj.name);
trace("----------"+streamObj.name);
streamObj.record(false);
}