Skip to content

Commit f01fbd5

Browse files
committed
add keyframe option
1 parent 5442834 commit f01fbd5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/core/src/media/factory.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,20 @@ export class StreamFactory {
5656
}
5757

5858
/**h264 only */
59-
async registerGstVideo(_: any = {}) {
59+
async registerGstVideo({
60+
keyframeIntervalSec,
61+
}: {
62+
keyframeIntervalSec?: number;
63+
} = {}) {
64+
keyframeIntervalSec ??= 2;
65+
66+
const keyIntMax = Math.round(keyframeIntervalSec * 30);
67+
6068
const [track, port, disposer] = await MediaStreamTrackFactory.rtpSource({
6169
kind: 'video',
6270
});
6371
const launch = this.gst.parseLaunch(
64-
`videotestsrc ! video/x-raw,width=640,height=480,format=I420 ! x264enc key-int-max=60 ! rtph264pay ! udpsink host=127.0.0.1 port=${port}`
72+
`videotestsrc ! video/x-raw,width=640,height=480,format=I420 ! x264enc key-int-max=${keyIntMax} ! rtph264pay ! udpsink host=127.0.0.1 port=${port}`
6573
);
6674
launch.setState(this.gst.State.PLAYING);
6775
SkyWayStreamFactory.registerMediaDevices({ video: track });

0 commit comments

Comments
 (0)