Easiest way to collect a list of stream parts with start/end timestamps

AlanM

Member
What is the easiest way to collect a list of all stream parts? We'd like to include the start and end timestamps for the recorded portion. We've tried to generate a start/creation timestamp using the file system, but it is unreliable. We have tried to use the modified time from the file system, but have concerns about processes touching the file after the actual recording or delaying the release of the file.

Ideal data set for us would be:
- Stream Name
- Recording Start Timestamp
- Recording End Timestamp
- Contains audio? (Boolean)
- Contains video? (Boolean)

Does the WCS server have an internal database that we collect from? or do you have recommendations on how to accurately collect this information?

Thanks
 

Max

Administrator
Staff member
Hello.
We are planning to release soon a new WCS build that will allow to define custom record name via REST API. This build will also fix the {startTime} record name template parameter, it will be set to recording start time (now, it is set to stream start time).
Anotther template parameters ({endTime} and so on) will be added in futher builds. Please stay tuned.
 

AlanM

Member
Is there an estimated completion time for this?

We've attempted to use the file modified at time, but sometimes it seems Flashphoner touches the file after it is finished, so we can't get an accurate timestamp.
 

Max

Administrator
Staff member
Hello.
Please update to 5.2.28 build. In this build, {startTime} record name template parameter will be set to recording start timestamp. Also this build supports custom record name definition via REST API, see this doc for details.
 

AlanM

Member
We are using

Code:
record_rotation=300
For each of the files that are created, we need to know the timestamp that that recorded part was started at, and the timestamp it ended it.

For example:

Code:
Config:
record_rotation=300
stream_record_policy=template
stream_record_policy_template={streamName}-{partStartTime}-{partEndTime}
Then for a recorded stream named 'stream', starting at time 0, and running for 12 minutes, the files would be:

Code:
stream-0-300_1.mp4
stream-300-600_2.mp4
stream-600-720.mp4
 

AlanM

Member
I tested on WCS 5.2.36, the startTime is just the stream start time, not the file start time.
In previous builds we have tested using the modified at time, but it appears WCS sometimes touches the file after the stream has finished.
 
Last edited:

Max

Administrator
Staff member
Hello.
You can rename next recording part based on last modification time of previuos part.
it appears WCS sometimes touches the file after the stream has finished
We'll try to reproduce it.
Commonly, WCS should not toch a recording file after stream is actually finished. But, for example, pulled RTSP stream finished in 60 seconds after last subscriber is off, and it will be recorded during this time.
Anyway, if you stop a stream with REST API, it finishes immediately, and recording should finish too. In this case, recording file should not be additionally touched.
 

AlanM

Member
We saw errors with the modified time when the stream had a poor connection and was stopped by the server. The actual file could contain ~10 seconds of media, but the last modified would be ~25 seconds in.

Could that part start / end time be added to the filename template so that we can avoid any chance for error, and just have WCS set it?
 

Max

Administrator
Staff member
Hello.
We work on it (internal ticket WCS-1861) and let you know when we fix {startTime} and add {endTime}
 

Max

Administrator
Staff member
Hello.
We released build 5.2.47. In this build:
{startTime} is set to recording fragment start time
{endTime} is set to recording fragment end time right after it is finished
See example in docs here.
 

AlanM

Member
We ran tests on WCS 5.2.56

Config:
Code:
/usr/local/FlashphonerWebCallServer/conf/flashphoner.properties

stream_record_policy=template
stream_record_policy_template={startTime}_{endTime}_{streamName}_{mediaSessionId}_{audioCodec}_{videoCodec}
record_rotation=300
The files should be splitting every 5 minutes (300 seconds), but instead they start splitting at 5 minutes, and the interval slowly decreases.

Code:
start_time    end_time      length     length from metadata
2:25:46 PM    2:30:42 PM    0:04:56    4:59
2:30:42 PM    2:35:35 PM    0:04:53    4:56
2:35:35 PM    2:40:25 PM    0:04:50    4:52
2:40:25 PM    2:45:11 PM    0:04:46    4:49
2:45:11 PM    2:49:53 PM    0:04:42    4:45
For references, the files:

Code:
1553804746212_1553805042709_56446_ab98a510-5197-11e9-98b5-0d24f3f35c69_opus_H264.mp4
1553805042709_1553805335736_56446_ab98a510-5197-11e9-98b5-0d24f3f35c69_opus_H264.mp4
1553805335736_1553805625093_56446_ab98a510-5197-11e9-98b5-0d24f3f35c69_opus_H264.mp4
1553805625093_1553805911047_56446_ab98a510-5197-11e9-98b5-0d24f3f35c69_opus_H264.mp4
1553805911047_1553806193896_56446_ab98a510-5197-11e9-98b5-0d24f3f35c69_opus_H264.mp4
The stream:

Code:
name: 56446
width: 620 px
height: 415 px
bitrate: 300 kbps
 

Max

Administrator
Staff member
Good day.
We work on this issue, it took a time to reproduce the problem steadily. Please be patient.
 

Max

Administrator
Staff member
Good day.
We are on testing stage, the fix supposed to be released next week.
 
Top