Skip to content

Commit

Permalink
change multimedia-process-flow-v3 to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
rsonghuster committed Aug 22, 2024
1 parent 214b560 commit 8315a1e
Show file tree
Hide file tree
Showing 23 changed files with 615 additions and 431 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/registry-publish.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
name: publish package to serverless-hub
name: auto try publish all

on:
release:
types: [created]
push:
branches:
- V3
env:
REGISTRY_TOKEN: ${{secrets.ALIBABA_REGISTRY_V3_PUBLISH_TOKEN}}

jobs:
deploy:
auto-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v2
with:
python-version: '3.x'
- uses: actions/setup-node@v1
node-version: 16
registry-url: https://registry.npmjs.org/
- uses: actions/setup-python@v5
with:
node-version: 12
- name: Install dependencies
python-version: '3.10'
- name: install s
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install requests
- name: Publish package
env:
publish_token: ${{ secrets.alibaba_registry_publish_token }}
npm i @serverless-devs/s -g
- name: publish
run: |
ls
python publish.py
python auto-publish.py
37 changes: 37 additions & 0 deletions auto-publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding=utf-8

import os
import subprocess

os.system("s registry login --token {}".format(os.environ["REGISTRY_TOKEN"]))


def search_publish_yaml(directory):
succ_app_list = []
for root, dirs, files in os.walk(directory):
if "publish.yaml" in files:
d = os.path.join(os.getcwd(), root)
d = d.replace("/./", "/")
cmd = ["s", "registry", "publish"]
result = subprocess.run(
cmd, cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
)
exit_code = result.returncode
print("publish {}; =====> ExitCode={}".format(d, exit_code))

if exit_code != 0:
errMsg = ""
errMsg += result.stdout
errMsg += result.stderr
if "当前版本号应当大于前一次版本号" not in errMsg:
print(errMsg)
else:
succ_app_list.append(d)

print("\n\npublish success app list:\n")
for item in succ_app_list:
print("{} published success".format(item))


# 在当前目录递归搜索
search_publish_yaml(".")
9 changes: 3 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

本主题一共包括三个部分:

- [FFmpeg的基本操作案例](./ffmpeg-app/src): `s init ffmpeg-app`
- [FFmpeg的基本操作案例](./ffmpeg-app/src)
- AudioConvert: 音频格式转换器 ([案例代码](./ffmpeg-app/src/functions/audio_convert))
- GetMediaMeta: 获取音视频 meta ([案例代码](./ffmpeg-app/src/functions/get_multimedia_meta))
- GetDuration: 获取音视频时长 ([案例代码](./ffmpeg-app/src/functions/get_duration))
- VideoGif: 功能强大的 video 提取为 gif 函数 ([案例代码](./ffmpeg-app/src/functions/video_gif))
- GetSprites: 功能强大雪碧图制作函数 ([案例代码](./ffmpeg-app/src/functions/get_sprites))
- VideoWatermark: 功能强大的视频添加水印功能 ([案例代码](./ffmpeg-app/src/functions/video_watermark))
- [基于 FFmpeg 实现音视频转码](./transcode/src): `s init video-transcode`
- [基于 FFmpeg 实现 HTTP 触发器触发音视频转码](./http-transcode/src): `s init http-video-transcode`
- [基于 FC + Serverless Workflow + OSS + NAS + FFmpeg 实现的弹性高可用、并行处理的视频转码服务](./video-process-flow/src): `s init video-process-flow`
- [对直播视频流截图的应用](./rtmp-snapshot/src): `s init rtmp-snapshot`
- [一个对浏览器全景录制](./headless-ffmpeg/src): `s init headless-ffmpeg`
- [基于 FFmpeg 实现音视频转码](./transcode/src)
- [基于 FC + Serverless Workflow + OSS + NAS + FFmpeg 实现的弹性高可用、并行处理的视频转码服务](./video-flow/src)
1 change: 0 additions & 1 deletion update.list

This file was deleted.

File renamed without changes.
15 changes: 6 additions & 9 deletions video-process-flow/hook/index.js → video-flow/hook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ async function preInit(inputObj) {
}

async function postInit(inputObj) {
console.log(`\n _______ _______ __ __ _______ _______ _______
console.log(`\n _______ _______ __ __ _______ _______ _______
| || || |_| || || || |
| ___|| ___|| || _ || ___|| ___|
| |___ | |___ | || |_| || |___ | | __
| |___ | |___ | || |_| || |___ | | __
| ___|| ___|| || ___|| ___|| || |
| | | | | ||_|| || | | |___ | |_| |
|___| |___| |_| |_||___| |_______||_______|
`)
console.log(`\n Welcome to the ffmpeg-app application
This application requires to open these services:
console.log(`\n Welcome to the multimedia-process-flow-v3 application
This application requires to open these services:
FC : https://fc.console.aliyun.com/
This application can help you quickly deploy the ffmpeg-app project.
The application uses FC component:https://github.com/devsapp/fc
The application homepage: https://github.com/devsapp/start-ffmpeg\n`)
This application can help you quickly deploy the ffmpeg project.
The application uses FC component:https://docs.serverless-devs.com/user-guide/aliyun/#fc3\n`)

const { artTemplate } = inputObj;
artTemplate("code/flows/video-processing-fc.yml");
}

module.exports = {
Expand Down
75 changes: 35 additions & 40 deletions video-process-flow/publish.yaml → video-flow/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Type: Application
Name: video-process-flow
Version: 0.1.6
Edition: 3.0.0
Type: Project
Name: multimedia-process-flow-v3
Version: 0.0.3
Provider:
- 阿里云
Description: 基于 FC + Serverless Workflow + OSS + NAS + FFmpeg 实现的弹性高可用、并行处理的视频转码服务
HomePage: https://github.com/devsapp/start-ffmpeg/tree/master/video-process-flow
HomePage: https://github.com/devsapp/start-ffmpeg/tree/master/multimedia-process-flow
Effective: Public
Tags:
- flow
- ffmpeg
Expand All @@ -18,19 +20,16 @@ Service:
- AliyunFCFullAccess
硬盘挂载:
Authorities:
- AliyunNASFullAccess
VPC:
- AliyunFCServerlessDevsRolePolicy
专有网络:
Authorities:
- AliyunVPCFullAccess
OSS:
- AliyunFCServerlessDevsRolePolicy
对象存储:
Authorities:
- AliyunOSSFullAccess
工作流:
- AliyunFCServerlessDevsRolePolicy
云工作流:
Authorities:
- AliyunFnFFullAccess
其它:
Authorities:
- AliyunECSFullAccess
Parameters:
type: object
additionalProperties: false # 不允许增加其他属性
Expand All @@ -57,14 +56,29 @@ Parameters:
- cn-shenzhen
- ap-southeast-1
- us-west-1
serviceName:
title: 服务名

flowName:
title: 工作流程名称
type: string
default: multimedia-process-flow-${default-suffix}
description: Serverless 工作流流程名称

fnfRoleArn:
title: 工作流 RAM角色ARN
type: string
default: video-process-flow-${default-suffix}
pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$"
description: 应用所属的函数计算服务
serviceRoleArn:
title: 函数计算Service RAM角色ARN
default: ""
pattern: "^acs:ram::[0-9]*:role/.*$"
description: 应用所属的工作流需要的 role, 请提前创建好对应的 role, 授信工作流服务, 并配置好 AliyunFCInvocationAccess 和 AliyunFnFFullAccess policy。
required: true
x-role:
name: fnf-execution-default-role
service: FNF
authorities:
- AliyunFCInvocationAccess
- AliyunFnFFullAccess

functionRoleArn:
title: 函数角色
type: string
default: ""
pattern: "^acs:ram::[0-9]*:role/.*$"
Expand All @@ -79,6 +93,7 @@ Parameters:
- AliyunOSSFullAccess
- AliyunFCDefaultRolePolicy
- AliyunFnFFullAccess

ossBucket:
title: 对象存储存储桶名
type: string
Expand Down Expand Up @@ -124,23 +139,3 @@ Parameters:
type: string
default: mp4, flv, avi
description: 转码后的视频格式,如果有需要输出多种格式, 使用逗号分隔

flowName:
title: 工作流程名称
type: string
default: video-process-flow
description: Serverless 工作流流程名称

fnfRoleArn:
title: 工作流 RAM角色ARN
type: string
default: ""
pattern: "^acs:ram::[0-9]*:role/.*$"
description: 应用所属的工作流需要的 role, 请提前创建好对应的 role, 授信工作流服务, 并配置好 AliyunFCInvocationAccess 和 AliyunFnFFullAccess policy。
required: true
x-role:
name: fnf-execution-default-role
service: FNF
authorities:
- AliyunFCInvocationAccess
- AliyunFnFFullAccess
125 changes: 125 additions & 0 deletions video-flow/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@

> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验)
# multimedia-process-flow-v3 帮助文档

<description>

基于 FC + Serverless Workflow + OSS + NAS + FFmpeg 实现的弹性高可用、并行处理的视频转码服务

</description>

<codeUrl>



</codeUrl>
<preview>



</preview>


## 前期准备

使用该项目,您需要有开通以下服务并拥有对应权限:

<service>



| 服务/业务 | 权限 | 相关文档 |
| --- | --- | --- |
| 函数计算 | AliyunFCFullAccess | [帮助文档](https://help.aliyun.com/product/2508973.html) [计费文档](https://help.aliyun.com/document_detail/2512928.html) |
| 硬盘挂载 | AliyunFCServerlessDevsRolePolicy | [帮助文档](https://help.aliyun.com/zh/nas) [计费文档](https://help.aliyun.com/zh/nas/product-overview/billing) |
| 专有网络 | AliyunFCServerlessDevsRolePolicy | [帮助文档](https://help.aliyun.com/zh/vpc) [计费文档](https://help.aliyun.com/zh/vpc/product-overview/billing) |
| 对象存储 | AliyunFCServerlessDevsRolePolicy | [帮助文档](https://help.aliyun.com/zh/oss) [计费文档](https://help.aliyun.com/zh/oss/product-overview/billing) |
| 云工作流 | AliyunFnFFullAccess | [帮助文档](undefined) [计费文档](undefined) |

</service>

<remark>



</remark>

<disclaimers>



</disclaimers>

## 部署 & 体验

<appcenter>

- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=multimedia-process-flow-v3)
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=multimedia-process-flow-v3) 该应用。

</appcenter>
<deploy>

- 通过 [Serverless Devs Cli](https://docs.serverless-devs.com/user-guide/install) 进行部署:
- [安装 Serverless Devs Cli 开发者工具](https://docs.serverless-devs.com/user-guide/install) ,并进行[授权信息配置]( https://docs.serverless-devs.com/user-guide/config)
- 初始化项目:`s init multimedia-process-flow-v3 -d multimedia-process-flow-v3`
- 进入项目,并进行项目部署:`cd multimedia-process-flow-v3 && s deploy -y`

</deploy>

## 案例介绍

<appdetail id="flushContent">

本案例将FFmpeg包装为一款音视频处理工作流,十分适用于加快视频转码处理速度的场景, 基本原理是对每一个视频,先进行切片处理,然后并行转码切片,最后合成,通过设置合理的切片时间,可以大大加速较大视频的转码速度。

FFmpeg 是音视频处理领域的一款强大工具,它可以被用于格式转换、编解码、录制和流处理等多种音视频相关任务。该技术因其高效性和多功能性,在视频处理、直播流媒体、数字媒体播放和编辑等多个领域中得到广泛应用。截至2023年4月,FFmpeg 在 GitHub 上的 star 数接近30,000,这反映了其在开源社区的受欢迎程度和影响力。被Netflix、YouTube、Facebook等多家知名企业采用,这些公司依赖 FFmpeg 处理其庞大的视频数据,以提供流畅的媒体播放体验、视频内容编辑和优化视频传输效率等服务。

</appdetail>

## 使用流程

<usedetail id="flushContent">

上传一个 mov 格式的视频到对象存储 bucket, OSS 触发器自动触发函数执行,函数调用工作流执行,工作流会同时进行 1 种或者多种格式的转码(由 s.yaml 中的 DST_FORMATS 参数控制), 本示例默认配置的是同时进行 mp4, flv, avi 格式的转码。

基于该工作流,您可以实现如下需求:

1 一个视频文件可以同时被转码成各种格式以及其他各种自定义处理,比如增加水印处理或者在 after-process 更新信息到数据库等。

2 当有多个文件同时上传到 OSS,函数计算会自动伸缩, 并行处理多个文件, 同时每次文件转码成多种格式也是并行。

3 结合 NAS + 视频切片, 可以解决超大视频的转码, 对于每一个视频,先进行切片处理,然后并行转码切片,最后合成,通过设置合理的切片时间,可以大大加速较大视频的转码速度。

![image](https://img.alicdn.com/tfs/TB1A.PSzrj1gK0jSZFuXXcrHpXa-570-613.png)


**操作视频教程:**

[![Watch the video](https://img.alicdn.com/imgextra/i2/O1CN01XvnqJu1XLS8SAU7LT_!!6000000002907-2-tps-250-155.png)](http://devsapp.functioncompute.com/video/multimedia-process-flow.mp4)

**P.S.** 当您想要仅在一个简单的函数中直接完成视频处理逻辑时,可以参考[音视频转码 Job](https://github.com/devsapp/start-ffmpeg/tree/V3/transcode/src)

</usedetail>

## 注意事项

<matters id="flushContent">
</matters>


<devgroup>


## 开发者社区

您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:

<p align="center">

| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://images.devsapp.cn/fc-faq/33947367.png" width="130px" > |
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |
</p>
</devgroup>
File renamed without changes.
Loading

0 comments on commit 8315a1e

Please sign in to comment.