/douyin-stream-helper

抖音视频流/直播流保存插件

Primary LanguageGoMIT LicenseMIT

douyin-stream-helper

抖音/小红书/快手等视频流(短视频/直播)保存插件。

Usage

  • Build image
docker build -t ffmpeg-golang-app:1.22.1-alpine3.19 .
  • Run container
docker run --rm -v /tmp/out:/app/out -p 9999:9999 -e SIGN_CHECK=false ffmpeg-golang-app:1.22.1-alpine3.19
  • Run container with ENV

ENV list:

SIGN_CHECK : boolean, 默认 true, true 是需传 `s` 和 `t` 参数
MAX_STREAM_FILE_DURATION_SECS : int, 默认 300(秒), 用于控制保存直播流时每个文件的时长
SHOW_TIMESTAMP : boolean, 默认 false, 用于控制保存直播时是否显示当前时间戳

Run CMD:

docker run --rm -v /tmp/out:/app/out -p 9999:9999  -e MAX_STREAM_FILE_DURATION_SECS=300 -e SHOW_TIMESTAMP=true ffmpeg-golang-app:1.22.1-alpine3.19
  • 客户端请求

SIGN_CHECK 为 false 时:

curl 'http://127.0.0.1:9999/22a4c19296767a3dcb03a6c516ffbeb82f35c3a6848556c598e8d6fb7c5c3415?t=1711106486&s=6ee41603ba54d302fb85040715fc21fcd1275c25f84b410a87296b7f8963ba65' \
  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
  --data-raw '{"url":"https://sns-video-al.xhscdn.com/stream/110/259/01e5d6bb3438268e010371038dced32369_259.mp4","title":"视频标题或文件名"}'

SIGN_CHECK 为 true 时:

curl 'http://127.0.0.1:9999/22a4c19296767a3dcb03a6c516ffbeb82f35c3a6848556c598e8d6fb7c5c3415?t=1711106486&s=6ee41603ba54d302fb85040715fc21fcd1275c25f84b410a87296b7f8963ba65' \
  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
  --data-raw '{"url":"https://sns-video-al.xhscdn.com/stream/110/259/01e5d6bb3438268e010371038dced32369_259.mp4","title":"视频标题或文件名"}'

t 和 s 生成:

// jQuery
function postToServer(msg) {
    const url = HOST + "/22a4c19296767a3dcb03a6c516ffbeb82f35c3a6848556c598e8d6fb7c5c3415"
    const t = parseInt(new Date().getTime()/1000)
    const body = JSON.stringify(msg)
    const sha256 = $.sha256(msg.url + t.toString())    
    $.post(url + "?t=" + t + "&s=" + sha256, body, function(data, status){
        alert("#发送请求至服务器: " + (data) + "\t状态: " + status);
    });
}