amtech
New Member
Hello,
We use WCS to switch short MP4 clips on a continuously published stream. The base stream is started with /rest-api/vod/startup (a looping MP4 via vod-live://), and every ~20 seconds we replace the picture with another clip:
The base stream is also pulled by a transcoder (transcoder://base_tcode1) that viewers play via WebRTC/MSE. The client sends each request 130-160 ms after its scheduled moment, so the delay described below is entirely server-side.
Problem
About one third of inject2/startup calls take ~3,020 ms instead of ~20 ms, and the clip appears on the output 3 seconds late. The other calls are instant. It does not depend on the file: the same clip is fast in one call and slow in the next. It does not depend on time of day or load either. Counted in the server log for one day:
Where the time goes
In the slow calls the HTTP thread logs exactly the same lines as in the fast calls, except for a single gap of 3000 ms between "Provide stream initialization result" and "Add media process injecting". Nothing else is logged on that thread in between.
The only visible difference between slow and fast calls is when the PullAgent reaches PROCESSED_LOCAL: in slow calls that line is logged just before, or in the same millisecond as, "Provide stream initialization result"; in fast calls it is logged 1-6 ms after it. It looks as if the HTTP thread waits for the PROCESSED_LOCAL state with a 3000 ms timeout and misses the notification when the state change happens first.
Slow call (3030 ms):
Fast call (73 ms, same thread, 35 s earlier):
Environment
WCS build: <paste from /usr/local/FlashphonerWebCallServer/conf/WCS.version>
OS: <e.g. Ubuntu 22.04>
Relevant settings: <paste output of grep -iE "inject|vod|keyframe" conf/flashphoner.properties>
Clips: H.264 MP4, no audio, 5-35 seconds, on local disk. REST auth disabled.
Full server log for the hour above is available on request.
Questions
1. Is this 3000 ms wait in inject2 with a vod-live source a known issue, and is it fixed in a newer build?
2. Is there a setting that controls this wait, or lets inject2 proceed as soon as the agent is CONNECTED?
3. Is there a recommended way to switch VOD clips on a published stream with a deterministic start time?
Thank you.
We use WCS to switch short MP4 clips on a continuously published stream. The base stream is started with /rest-api/vod/startup (a looping MP4 via vod-live://), and every ~20 seconds we replace the picture with another clip:
Code:
POST /rest-api/stream/inject2/startup
{"localStreamName":"base_Stream","remoteStreamName":"vod-live://clips/clipA.mp4","video":true,"audio":false}
The base stream is also pulled by a transcoder (transcoder://base_tcode1) that viewers play via WebRTC/MSE. The client sends each request 130-160 ms after its scheduled moment, so the delay described below is entirely server-side.
Problem
About one third of inject2/startup calls take ~3,020 ms instead of ~20 ms, and the clip appears on the output 3 seconds late. The other calls are instant. It does not depend on the file: the same clip is fast in one call and slow in the next. It does not depend on time of day or load either. Counted in the server log for one day:
Code:
hour 00: 180 calls, 58 slow
hour 01: 184 calls, 61 slow
hour 02: 182 calls, 65 slow
hour 03: 185 calls, 56 slow
hour 04: 180 calls, 48 slow
hour 05: 232 calls, 73 slow
Every call is either < 0.5 s or 3.0-3.1 s, never in between.
Where the time goes
In the slow calls the HTTP thread logs exactly the same lines as in the fast calls, except for a single gap of 3000 ms between "Provide stream initialization result" and "Add media process injecting". Nothing else is logged on that thread in between.
The only visible difference between slow and fast calls is when the PullAgent reaches PROCESSED_LOCAL: in slow calls that line is logged just before, or in the same millisecond as, "Provide stream initialization result"; in fast calls it is logged 1-6 ms after it. It looks as if the HTTP thread waits for the PROCESSED_LOCAL state with a 3000 ms timeout and misses the notification when the state change happens first.
Slow call (3030 ms):
Code:
05:57:35,757 INFO RestApiRouter - SSL-HTTP-pool-5-thread-96 handleRequest method: /rest-api/stream/inject2/startup, params:{localStreamName=base_Stream, remoteStreamName=vod-live://clips/clipA.mp4, video=true, audio=false}
05:57:35,757 INFO PullAgent - SSL-HTTP-pool-5-thread-96 Connect to vod-live://clips/clipA.mp4
05:57:35,768 INFO MediaHandler - SSL-HTTP-pool-5-thread-96 publishStream arguments - Stream{... name='injected_vod_77976108-...'}
05:57:35,779 INFO PullAgent - SSL-HTTP-pool-5-thread-96 Agent vod-live://clips/clipA.mp4-52378d88-... changed state to CONNECTED
05:57:35,785 INFO PullAgent - API-ASYNC-pool-7-thread-170 Agent vod-live://clips/clipA.mp4-52378d88-... changed state to PROCESSED_LOCAL
05:57:35,787 INFO AgentFactory - SSL-HTTP-pool-5-thread-96 Provide stream initialization result com.flashphoner.server.remote.E$_A@d50d316
05:57:38,787 INFO C - SSL-HTTP-pool-5-thread-96 Add media process injecting <-- 3000 ms later
Fast call (73 ms, same thread, 35 s earlier):
Code:
05:57:00,747 INFO RestApiRouter - SSL-HTTP-pool-5-thread-96 handleRequest method: /rest-api/stream/inject2/startup, params:{localStreamName=base_Stream, remoteStreamName=vod-live://clips/clipB.mp4, video=true, audio=false}
05:57:00,748 INFO PullAgent - SSL-HTTP-pool-5-thread-96 Connect to vod-live://clips/clipB.mp4
05:57:00,807 INFO MediaHandler - SSL-HTTP-pool-5-thread-96 publishStream arguments - Stream{... name='injected_vod_25c0f42d-...'}
05:57:00,818 INFO PullAgent - SSL-HTTP-pool-5-thread-96 Agent vod-live://clips/clipB.mp4-99a7efa2-... changed state to CONNECTED
05:57:00,819 INFO AgentFactory - SSL-HTTP-pool-5-thread-96 Provide stream initialization result com.flashphoner.server.remote.E$_A@40c982f0
05:57:00,820 INFO PullAgent - API-ASYNC-pool-7-thread-151 Agent vod-live://clips/clipB.mp4-99a7efa2-... changed state to PROCESSED_LOCAL
05:57:00,820 INFO C - SSL-HTTP-pool-5-thread-96 Add media process injecting <-- 1 ms later
Environment
WCS build: <paste from /usr/local/FlashphonerWebCallServer/conf/WCS.version>
OS: <e.g. Ubuntu 22.04>
Relevant settings: <paste output of grep -iE "inject|vod|keyframe" conf/flashphoner.properties>
Clips: H.264 MP4, no audio, 5-35 seconds, on local disk. REST auth disabled.
Full server log for the hour above is available on request.
Questions
1. Is this 3000 ms wait in inject2 with a vod-live source a known issue, and is it fixed in a newer build?
2. Is there a setting that controls this wait, or lets inject2 proceed as soon as the agent is CONNECTED?
3. Is there a recommended way to switch VOD clips on a published stream with a deterministic start time?
Thank you.