如何在iOS视频播放器中播放webm文件

问题描述 投票:0回答:2

我想在 iOS 中支持 webm 文件,但 iOS 不支持这种格式播放视频。我什至尝试通过 HTML5 视频标签播放它,但 safari 不支持 HTML5 视频标签中的 webm 格式,这意味着我也无法通过 UIWebView 使其工作。但我已经看到一个应用程序在他们的媒体播放器中支持这种格式,这意味着应该有某种方法。

提前感谢您的帮助!

ios iphone xcode webm video-player
2个回答
7
投票

您是否尝试过通过 VLC 集成

MediaVLCKit

根据适用于 iOS 设备的 VLC:该应用程序声称能够播放名副其实的不同视频格式的聚宝盆,包括 .mkv、.vob、.wmvWebM

适用于 iOS 2.5.1 的 VLC 的 PFA 链接,其中还包括 MediaVLCKit 库。 希望这有效:)


0
投票

以编程方式,您必须使用后端将 webm 转换为 mp4。使用一些 ffmpeg 库。在 Node.js 中,最好使用 Fluent-ffmpeg。以下是示例代码。

const ffmpegPath = require("@ffmpeg-installer/ffmpeg").path; const ffmpeg = require("fluent-ffmpeg"); const fs = require("fs"); ffmpeg.setFfmpegPath(ffmpegPath); // Input and output file paths const inputFilePath = "input/file/path/or/url.mp4"; const outputFilePath = "output/file/path"; // Create a FFmpeg command const command = ffmpeg(); // Set input file command.input(inputFilePath); // Set video codec to libx264 (MP4) command.videoCodec("libx264"); // Set fps (30 makes the conversion fast) ommand.outputFPS(30); // Set output file command.output(outputFilePath); // Run the conversion command .on("end", () => { console.log("Conversion finished."); }) .on("error", (err, stdout, stderr) => { console.error("Error:", err); console.error("ffmpeg stdout:", stdout); console.error("ffmpeg stderr:", stderr); }) .run();

© www.soinside.com 2019 - 2024. All rights reserved.