首页 > 其他分享 >折腾笔记[1]-打包ffmpeg-cli到单个wasm二进制

折腾笔记[1]-打包ffmpeg-cli到单个wasm二进制

时间:2024-09-28 15:34:28浏览次数:7  
标签:ago enable cli -- wasmtime hours 12 wasm ffmpeg

摘要

使用c2w打包ffmpeg-cli到单个wasm二进制,实现ffmpeg可执行文件平台无关运行(Build Once,Run Anywhere)。

Abstract

Using c2w to package the ffmpeg-cli into a single wasm binary, achieving platform-independent execution of the ffmpeg executable (Build Once, Run Anywhere).

原理简介

c2w简介

[https://github.com/ktock/container2wasm]
[https://ktock.github.io/container2wasm-demo/]
Container to WASM converter
container2wasm is a container-to-wasm image converter that enables to run the container on WASM.

Converts a container to WASM with emulation by Bochs (for x86_64 containers) and TinyEMU (for riscv64 containers).
Runs on WASI runtimes (e.g. wasmtime, wamr, wasmer, wasmedge, wazero)
Runs on browser
x86_64 or riscv64 containers are recommended. Other platforms (e.g. arm64) also work (but slow).
This is an experimental software.

Demo page of containers on browser (debian,python,node,vim): https://ktock.github.io/container2wasm-demo/

wasmtime简介

[https://wasmtime.dev/]
A fast and secure runtime for WebAssembly
A Bytecode Alliance project

Fast. Wasmtime is built on the optimizing Cranelift code generator to quickly generate high-quality machine code either at runtime or ahead-of-time. Wasmtime is optimized for efficient instantiation, low-overhead calls between the embedder and wasm, and scalability of concurrent instances.

Secure. Wasmtime's development is strongly focused on correctness and security. Building on top of Rust's runtime safety guarantees, each Wasmtime feature goes through careful review and consideration via an RFC process. Once features are designed and implemented, they undergo 24/7 fuzzing donated by Google's OSS Fuzz. As features stabilize they become part of a release, and when things go wrong we have a well-defined security policy in place to quickly mitigate and patch any issues. We follow best practices for defense-in-depth and integrate protections and mitigations for issues like Spectre. Finally, we're working to push the state-of-the-art by collaborating with academic researchers to formally verify critical parts of Wasmtime and Cranelift.

Configurable. Wasmtime uses sensible defaults, but can also be configured to provide more fine-grained control over things like CPU and memory consumption. Whether you want to run Wasmtime in a tiny environment or on massive servers with many concurrent instances, we've got you covered.

WASI. Wasmtime supports a rich set of APIs for interacting with the host environment through the WASI standard.

Standards Compliant. Wasmtime passes the official WebAssembly test suite, implements the official C API of wasm, and implements future proposals to WebAssembly as well. Wasmtime developers are intimately engaged with the WebAssembly standards process all along the way too.

  • wasmtime支持的宿主平台:
    v25.0.1: Release Wasmtime 25.0.1 (#9306) Latest
File Name Size Last Modified
wasi_snapshot_preview1.command.wasm 52.4 KB 12 hours ago
wasi_snapshot_preview1.proxy.wasm 17 KB 12 hours ago
wasi_snapshot_preview1.reactor.wasm 52.3 KB 12 hours ago
wasmtime-dev-aarch64-android-c-api.tar.xz 13.5 MB 12 hours ago
wasmtime-dev-aarch64-android.tar.xz 7.39 MB 12 hours ago
wasmtime-dev-aarch64-linux-c-api.tar.xz 14.1 MB 12 hours ago
wasmtime-dev-aarch64-linux.tar.xz 7.36 MB 12 hours ago
wasmtime-dev-aarch64-macos-c-api.tar.xz 12.3 MB 12 hours ago
wasmtime-dev-aarch64-macos.tar.xz 6.54 MB 12 hours ago
wasmtime-dev-aarch64-windows-c-api.zip 19.9 MB 12 hours ago
wasmtime-dev-aarch64-windows.zip 8.38 MB 12 hours ago
wasmtime-dev-riscv64gc-linux-c-api.tar.xz 16.3 MB 12 hours ago
wasmtime-dev-riscv64gc-linux.tar.xz 7.88 MB 12 hours ago
wasmtime-dev-s390x-linux-c-api.tar.xz 15.4 MB 12 hours ago
wasmtime-dev-s390x-linux.tar.xz 7.83 MB 12 hours ago
wasmtime-dev-src.tar.gz 142 MB 12 hours ago
wasmtime-dev-x86_64-android-c-api.tar.xz 14 MB 12 hours ago
wasmtime-dev-x86_64-android.tar.xz 8.03 MB 12 hours ago
wasmtime-dev-x86_64-linux-c-api.tar.xz 14.7 MB 12 hours ago
wasmtime-dev-x86_64-linux.tar.xz 8.08 MB 12 hours ago
wasmtime-dev-x86_64-macos-c-api.tar.xz 13.3 MB 12 hours ago
wasmtime-dev-x86_64-macos.tar.xz 7.49 MB 12 hours ago
wasmtime-dev-x86_64-mingw-c-api.zip 23.5 MB 12 hours ago
wasmtime-dev-x86_64-mingw.zip 14.9 MB 12 hours ago
wasmtime-dev-x86_64-musl-c-api.tar.xz 14.7 MB 12 hours ago
wasmtime-dev-x86_64-musl.tar.xz 8.11 MB 12 hours ago
wasmtime-dev-x86_64-windows-c-api.zip 21 MB 12 hours ago
wasmtime-dev-x86_64-windows.msi 8.88 MB 12 hours ago
wasmtime-dev-x86_64-windows.zip 9.17 MB 12 hours ago
wasmtime-platform.h 9.14 KB 12 hours ago
Source code (zip) - 13 hours ago
Source code (tar.gz) - 13 hours ago

实现

使用c2w打包ffmpeg-cli进入wasm

[https://github.com/qsbye/ffmpeg.wasm]
[https://gitee.com/qsbye/ffmpeg.wasm] release页面有打包的wasm二进制文件

# 打包/Package
docker pull linuxserver/ffmpeg:version-7.0.2-cli
c2w linuxserver/ffmpeg:version-7.0.2-cli /home/qsbye/ffmpeg-7.0.2-cli.wasm
# 测试/Test
# 安装wasmtime运行时,当然也可以使用wasmer等其他的运行时(未测试)
curl https://wasmtime.dev/install.sh -sSf | bash
wasmtime ffmpeg-7.0.2-cli.wasm
# 转换文件夹下的sheep.mp3到sheep.wav文件
wasmtime run --dir $PWD::/root ffmpeg-7.0.2-cli.wasm -- -i /root/sheep.mp3 /root/sheep.wav

输出:

ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13 (Ubuntu 13.2.0-23ubuntu4)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-alsa --enable-cuda-llvm --enable-cuvid --enable-ffprobe --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libfdk_aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libplacebo --enable-librav1e --enable-librist --enable-libshaderc --enable-libsrt --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-nonfree --enable-nvdec --enable-nvenc --enable-opencl --enable-openssl --enable-stripping --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Universal media converter
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
  • 优点:运行简单,平台无关,不会受到环境变量和动态链接库版本影响,可以在docker镜像缺失的riscv64架构计算机运行。

  • 缺点:二进制文件大,运行比较缓慢

  • 吐槽:

    标签:ago,enable,cli,--,wasmtime,hours,12,wasm,ffmpeg
    From: https://www.cnblogs.com/qsbye/p/18438021

相关文章

  • FFmpeg 初学者需要掌握的基础知识和实用技能。每个部分可以深入讲解,提供具体的命令示
    FFmpeg初级使用教程大纲1. FFmpeg简介什么是FFmpegFFmpeg的主要功能安装FFmpeg2. 基本命令格式FFmpeg的基本命令结构输入与输出文件的指定常用选项的介绍3. 常用命令示例转换视频格式示例:将MP4转换为AVI提取音频示例:从视频中提取音频压缩视......
  • SHAutoClick V3.0.3 无影手自动点击
    前言这个软件至少已有14年历史,起初名为AutoClick,主要用于关闭烦人的弹窗警告、广告,或者持续翻页等。后来因需要调用一个软件批量转换图书格式,就开发了通用的调用第三方软件进行批量操作的功能,这也是本软件最大的特色。因重名软件太多,故更名为SHAutoClick(无影手自动点击),属于标准四......
  • ClioSoft SOS深度解析:从基础入门到高级配置全攻略
    这个目录为用户提供了全面的ClioSoftSOS学习指南,涵盖了从基础概念到高级配置的所有方面。以下是每个部分的简要总结,每个目录内容将持续更新,欢迎大家收藏关注专栏《ClioSoftSOS深度解析:从基础入门到高级配置全攻略》,专栏地址:https://blog.csdn.net/qq_24766857/category_12......
  • 在Linux上安装Cliosoft SOS的具体步骤是什么?
    在Linux上安装ClioSoftSOS的具体步骤如下。这些步骤包括了从下载软件包到完成安装的全过程,确保您能够顺利地在Linux系统上安装和配置SOS。1.准备工作检查系统要求:确保您的Linux系统满足SOS的硬件和软件要求。创建安装目录:建议使用一个专用目录来存放SOS的安装文件。例如:......
  • 什么是ClioSoft SOS?它在硬件配置管理中扮演什么角色?
    ClioSoftSOS(SoftwareOptimizationSystem)是一种硬件配置管理(HardwareConfigurationManagement,HCM)软件,专为电子设计自动化(EDA)行业中的集成电路(IC)设计团队提供数据管理和版本控制功能。SOS帮助设计团队有效地管理项目文件和库,确保设计过程中数据的一致性、完整性和可追溯性......
  • 记ffmpeg subtitles滤镜切换字幕卡顿
    1.subtitles卡顿偷懒在项目中使用ffmpeg的subtitles滤镜进行字幕渲染。后来发现,使用滤镜切换字幕时会出现卡顿。经过进一步测试与代码调式确认,在播放一个时长在一个小时以上的视频文件的内挂字幕时,滤镜初始化花费了较长的时间。使用ffplay+subtitles滤镜播放该文件并显示字幕......
  • [Angular] 从零开始使用 Angular CLI 创建 Angular 项目
    一、安装Node.js......
  • ETLCloud携手ClickHouse:高效的数据查询效率
    自从大数据处理技术走进大众视野、开源项目Hadoop的出现,以前受制于数据库处理能力的大数据技术蓬勃发展,传统关系型数据库所构建的数据仓库,被以Hive为代表的大数据技术所取代,随着技术不断发展,Hadoop虽然带来了诸多便利性,但是其臃肿和复杂的体系使得在海量数据和高时效性的压力下有......
  • JMeter的CLI模式(非GUI模式)常用命令
    JMeter的CLI模式(非GUI模式)常用命令ApacheJMeter是一款强大的开源性能测试工具,它支持图形用户界面(GUI)模式和非图形用户界面(CLI,即CommandLineInterface)模式。在实际的性能测试工作中,CLI模式因其能够减少资源消耗和提高测试效率而备受青睐。本文将详细介绍JMeter在CLI模式下的常......
  • 关于Clion汉化失败Plugin “Chinese (Simplified) Language Pack / 中文语言包“ was
    关于Clion汉化失败出现Plugin"Chinese(Simplified)LanguagePack/中文语言包"wasnotinstalled:Invalidfilenamereturnedbyaserver意思是你安装的汉化包不可被识别,截止到23/7/22pluginsmarket搜索到的汉化包版本不再能兼容21版本的clion了解决方法有两个1.升......