Amazon Kinesis Video Streams: GStreamer コマンドラインツールによる送信方法¶
GStreamer のコマンドラインツール (gst-launch-1.0) を使って Kinesis Video Streams に映像を送信するコマンドの例です。
参考) GStreamer Element Parameter Reference
環境変数設定¶
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export AWS_DEFAULT_REGION=ap-northeast-1
STREAM_NAME=stream-test
参考¶
RTSP → mp4 ファイル (H.264)¶
RTSP_URL=rtsp://...
gst-launch-1.0 -e \
rtspsrc location="${RTSP_URL}" protocols=tcp \
! decodebin \
! x264enc \
! mp4mux \
! filesink location=output.mp4
Kinesis Video Streams への送信¶
テスト映像 (RAW) → Kinesis Video Streams (H.264)¶
gst-launch-1.0 \
videotestsrc \
! video/x-raw,width=640,height=480,framerate=30/1 \
! x264enc \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au,profile=high \
! kvssink stream-name="${STREAM_NAME}" storage-size=512
mp4 ファイル (H.264) → Kinesis Video Streams (H.264)¶
MOVIE_FILE=test.mp4
gst-launch-1.0 \
filesrc location="${MOVIE_FILE}" \
! qtdemux \
! queue \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au \
! kvssink stream-name="${STREAM_NAME}" storage-size=512
mp4 ファイル (H.264) → Kinesis Video Streams (H.264) / 時間指定¶
MOVIE_FILE=test.mp4
START_TIME=1640185200
gst-launch-1.0 \
filesrc location="${MOVIE_FILE}" \
! qtdemux \
! queue \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au \
! kvssink stream-name="${STREAM_NAME}" storage-size=512 \
streaming-type=offline \
file-start-time=${START_TIME}
※streaming-type=offline と file-start-time パラメーターは 2021-12-23 現在ドキュメント上は未サポートとなっています。
RTSP (MP4V) → Kinesis Video Streams (H.264)¶
RTSP_URL=rtsp://...
BPS=1024000
gst-launch-1.0 \
rtspsrc location="${RTSP_URL}" protocols=tcp \
! rtpmp4vdepay \
! avdec_mpeg4 \
! queue \
! x264enc bitrate=${BPS} key-int-max=10 \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au \
! kvssink stream-name="${STREAM_NAME}" storage-size=512
RTSP (H.264) → Kinesis Video Streams (H.264)¶
RTSP_URL=rtsp://...
gst-launch-1.0 \
rtspsrc location="${RTSP_URL}" protocols=tcp \
! rtph264depay \
! queue \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au \
! kvssink stream-name="${STREAM_NAME}" storage-size=512
RTSP (H.264) → Kinesis Video Streams (H.264) ※再エンコード¶
RTSP_URL=rtsp://...
BPS=1024000
gst-launch-1.0 \
rtspsrc location="${RTSP_URL}" protocols=tcp \
! rtph264depay \
! avdec_h264 \
! queue \
! x264enc bitrate=${BPS} key-int-max=10 \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au \
! kvssink stream-name="${STREAM_NAME}" storage-size=512
組み合わせ例¶
H.264 配信しながら 1 FPS で JPEG 保存¶
RTSP_URL=rtsp://...
gst-launch-1.0 \
rtspsrc location="${RTSP_URL}" protocols=tcp \
! rtph264depay \
! tee name=t \
! h264parse \
! video/x-h264,stream-format=avc,alignment=au \
! kvssink stream-name="${STREAM_NAME}" storage-size=512 \
t. \
! queue \
! avdec_h264 \
! videorate \
! video/x-raw,framerate=1/1 \
! jpegenc \
! multifilesink location="frame%02d.jpg" max-files=10