Is it possible to start recording by stream name?

burak guder

Member
I want to record a stream I received from the ip camera but I need to use mediaSessionId for recording.

I can't start recording with rest api because I can't access mediaSessionId

rest-api/rtsp/find_all
{
"uri": "rtsp://root:Sxxxxxxx@xxxxxxxx:555/live2.sdp",
"localStreamName": "abcdefghyujk",
"status": "PLAYING"
}

How can I start the recording process for the above stream info.
 

Max

Administrator
Staff member
Good day.
You have at lesat two options:
1. If you want to record all the RTSP streams, use this parameter in flashphoner.properties file
Code:
record_rtsp_streams
2. Use /stream/find query to find stream by name you've set as localStreamName
Code:
POST /rest-api/stream/find HTTP/1.1
Host: localhost:8081
Content-Type: application/json
 
{
    "name":"abcdefghyujk",
    "published":true
}
This query will return stream parameters including mediaSessionId:
Code:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json;charset=UTF-8
Date: Tue, 26 Mar 2021 11:05:16 GMT
 
[
  {
    "appKey": "defaultApp",
    "sessionId": "/x.xxx.xx.xx:51294/xx.xxx.xxx.xx:8443-118f9784-d3b0-4e2b-8837-425eb71efcbe",
    "mediaSessionId": "86108970-8de5-11eb-afa9-0d709beccf93",
    "name": "abcdefghyujk",
    "published": true,
    ...
  }
]
So you can use mediaSessionId to start recording.
 

burak guder

Member
I am able to view the mediaSessionId with "find_all". But when I search with "find" I can't find the information

find_all
Api URL: https://xxxxxxxxxxxxxxxxxxxx/rest-api/stream/find_all

Return Info

[
{
"appKey": "defaultApp",
"sessionId": "rtsp://yyyyyyyyyyyy/live2.sdp-78ae994c-880c-432a-adc3-74923c90dae1",
"mediaSessionId": "01ce25cc-d6bb-4c82-9bf3-179f6a94920b",
"name": "abcdefR3V",
"published": true,
"hasVideo": true,
"hasAudio": true,
"status": "PUBLISHING",
....


"find" method

Api URL: https://xxxxxxxxxxxxxxxxxxxx/rest-api/stream/find
REST CODE ----------------------------
$options = array(
'http' => array(
'header' => "Content-type: application/json",
'method' => 'POST',
'content' => '{
"name": "abcdefR3V
}'
)
);

$imgdatajson = $this->getInfoHeader("https://xxxxxxxxxxxxx/rest-api/stream/find", $options);
____________________________________

return info

{
"exception": "com.flashphoner.rest.server.exception.InternalErrorException",
"path": "/rest-api/stream/find",
"error": "Internal Server Error",
"message": null,
"timestamp": 1624950250607,
"status": 500
}
 

Max

Administrator
Staff member
I am able to view the mediaSessionId with "find_all". But when I search with "find" I can't find the information
You should set the additional parameter to search as we recommended above:
Code:
'content' => '{
"name": "abcdefR3V",
"published": true
}'
By default, published is false, so your query seraches playing streams only.
 

burak guder

Member
I can't get a response like you said.


Code:
'content' => '{
                                    "name": "abcdefR3V,
                                    "published":true
                              }'
return :
Code:
{
    "exception": "com.flashphoner.rest.server.exception.InternalErrorException",
    "path": "/rest-api/stream/find",
    "error": "Internal Server Error",
    "message": null,
    "timestamp": 1625039213505,
    "status": 500
}

Flashphoner version : FlashphonerWebCallServer-5.2.966-0f58719690171777d29bd5e7a9f2a6a3da3725c9
 

burak guder

Member
Hello there

I successfully initiate registration via api. but the script I want to run at the end of the registration does not work.

The setting I use is:
on_record_hook_script=/usr/local/nginx/html/api/record.sh

script not triggering
 

Max

Administrator
Staff member
The setting I use is:
on_record_hook_script=/usr/local/nginx/html/api/record.sh
script not triggering
1. Please check if read and execution permissions are set correctly to the script. Make the command
Code:
sudo chmod +rx /usr/local/nginx/html/api/record.sh
2. Add the following lines to the script (and more logging if needed)
Code:
STREAM_NAME=$1
FILE_NAME=$2

echo $STREAM_NAME >> /usr/local/FlashphonerWebCallServer/logs/record.log
echo $FILE_NAME >> /usr/local/FlashphonerWebCallServer/logs/record.log
and check the log
3. Check if write permissions are correctly set to a folder to which the script copies or moves recording files to. Make the command
Code:
sudo chmod o+w /path/to/the/folder
If nothing helps, please provide SSH access to the server using this form, we will check
 

burak guder

Member
Hello there

i want to do:
I want it to notify when file saving is complete (it should do this every rotation)


problem:
when I run the script manually it works and writes log.

on_record_hook_script process not working when i start recording process via api

i am currently solving the problem with file tracking using incron. While the same script is triggered in incron, flashphoner is not triggered either.
 
Top