- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发 VOD 功能,过去几天我无法将生成的 HLS 播放列表和文件输出到 GCP。我正在使用 fluent-ffmpeg用于将 hls 播放列表上传到 GCP。下面是使用 Node.js 上传 HLS 到 GCP 的测试代码环境
const path = require('path');
const { Storage } = require('@google-cloud/storage');
const { createHLSPlaylist } = require('./utils/ffmpeg');
//* Creates a client, keyFileName is link to service account authentication credentials
const storage = new Storage({
keyFilename: path.join(
__dirname,
'./config/FILE.json'
),
projectId: process.env.GCP_PROJECT_ID,
});
//* To be used in upload GCP videos controller (copy this file contents within controller)
const url = 'URL';
const bucket = storage.bucket('BUCKETNAME');
const playlistName = 'file.m3u8';
const newFile = bucket.file(playlistName);
createHLSPlaylist(url, newFile.createWriteStream());
这是将 url 中的视频转码为 hls 播放列表的 ffmpeg 代码
const ffmpeg = require('fluent-ffmpeg');
const ffmpegInstaller = require('@ffmpeg-installer/ffmpeg');
ffmpeg.setFfmpegPath(ffmpegInstaller.path);
const createHLSPlaylist = (url, stream) => {
const command = ffmpeg(url, { timeout: 432000 })
.addOption([
'-profile:v baseline',
'-level 3.0',
'-start_number 0',
'-hls_time 10',
'-hls_list_size 0',
'-f hls',
])
.on('end', (stdout, stderr) => {
console.log('Transcoding succeeded !');
process.exit(1);
})
.on('start', (commandLine) => {
console.log('start', commandLine);
})
.on('codecData', (data) => {
console.log(`Input is ${data.audio} audio with ${data.video} video`);
})
.on('progress', (progress) => {
console.log(`Processing. Timemark: -> ${progress.timemark}`);
})
.on('stderr', (stderrLine) => {
// do nothing
})
.on('error', (err, stdout, stderr) => {
console.log(`error1: ${err}`);
console.log(`error2: ${stdout}`);
console.log(`error3: ${stderr}`);
console.log(`Cannot process video: ${err.message}`);
})
.on('data', (chunk) => {
console.log(`ffmpeg just wrote ${chunk.length} bytes`);
})
.pipe(stream, { end: true }); //end = true, close output stream after writing
};
module.exports = {
createHLSPlaylist,
};
我通过 console.log 收到以下消息
Processing. Timemark: -> 00:00:28.62
Processing. Timemark: -> 00:00:28.62
Processing. Timemark: -> 00:00:28.62
Processing. Timemark: -> 00:00:28.89
Transcoding succeeded !
最佳答案
目前,我已经设法通过使用提到的临时文件存储将 HLS 播放列表上传到 GCP here。 .我设法通过以下方式解决了这个问题
newVideo = somebucket.file(filename);
file
.pipe(newVideo.createWriteStream({ gzip: 'auto' }))
.on('error', (err) => {
console.log(err);
})
.on('finish', () => {
console.log(`File ${filename} upload finished`);
newVideo
.getSignedUrl({ action: 'read', expires: '03-17-2022' })
.then((url) => {
const command = ffmpeg(url[0], { timeout: 432000 })
.addOptions([
'-profile:v baseline',
'-f segment',
'-level 3.0',
'-start_number 0',
'-hls_base_url segments/',
`-hls_segment_filename ./assets/${playlistName}/file%03d.ts`,
// Apple recommended time = 6,
// In seconds
'-hls_time 6',
'-hls_list_size 0',
// format
'-f hls',
])
.output(`./assets/${playlistName}/${playlistName}.m3u8`)
.on('end', async () => {
console.log('Transcoding succeeded !');
try {
const files = await readdir(`./assets/${playlistName}`);
console.log('files', files);
await Promise.all(
files.map((folderFile) =>
securebucket.upload(
`./assets/${playlistName}/${folderFile}`,
{
destination: folderFile,
}
)
)
).then(() => {
fs.rm(
`./assets/${playlistName}`,
{ recursive: true },
(err) => {
if (err) {
throw err;
}
console.log(`./assets/${playlistName} is deleted!`);
res.status(201).json(url[0]);
res.end();
}
);
});
} catch (err) {
console.error(err);
}
})
.on('start', (commandLine) => {
console.log('start', commandLine);
})
.on('codecData', (data) => {
console.log(
`Input is ${data.audio} audio with ${data.video} video`
);
})
.on('progress', (progress) => {
console.log(`Processing. Timemark: -> ${progress.timemark}`);
})
.on('error', (err, stdout, stderr) => {
console.log(`Cannot process video: ${err.message}`);
});
fs.mkdir(`./assets/${playlistName}`, (err) => {
if (err && err.code !== 'EEXIST') {
throw err;
} else {
command.run();
}
});
});
我仍然不相信这种方法,因为我相信这可以通过流媒体以更简单的方式实现,但似乎我无法为我的解决方案找到明确的答案,因为 fluent-ffmpeg 没有提供 s3 或 GCP 的示例
关于node.js - 将 HLS 播放列表 list 文件和媒体片段文件直接上传到 GCP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70435518/
似乎最近我看到越来越多的人开始在他们的样式表中使用 media="all" 而不是 media="screen"。 我的问题是什么时候应该使用 media="all" 而不是 media="scree
我正在尝试使用 https://www.instagram.com/developer/endpoints/media/ ,但对于我使用的每个媒体 ID,我总是得到相同的结果: { "meta
哟,我正在为服务器制作一个 MOTD 供最终用户阅读。但是,对于使用较小显示器的用户来说,它看起来非常压缩,例如,当分辨率为 1280x1040 时,它会被拉低。我不熟悉 CSS 中的 @media
我在我的 CSS 文件中使用了 @media screen 而不是 (-webkit-min-device-pixel-ratio:0)。我的问题是关于指定的值,即在这种情况下为“0”。值的变化将如何
我正在播放 Activity 中的视频,我需要显示/隐藏顶部栏 View 以及媒体 Controller 。所以当媒体 Controller 在屏幕上时,我的顶部 View 应该是可见的,当媒体 Co
我在我的 WordPress 主题中创建了一个小部件来显示图像。到目前为止,小部件可以工作,我可以输入值并在前端显示这些值。 当我选择一个小部件并将其放入小部件区域时,媒体上传按钮不起作用。在 Wor
我正在使用MWFeedParser从此处读取Youtube原子供稿:here xml代码: 我如何获取媒体的网址:缩略图? 我试图更改MWFeedParser.m 由此: else if ([cu
当使用 Python 向 Instagram API 发出 GET 请求时,传递所需的变量,如下所示 photos = api.media_search(lat=latitude, lng=longi
我正在使用与媒体播放器关联的媒体 Controller 来播放声音。问题是媒体 Controller 一旦失去焦点就会隐藏起来。我有一个按钮,按下时会播放声音,媒体 Controller 会出现在屏幕
我有一个媒体播放器并与它关联了一个媒体 Controller 。控件工作正常。 我遇到了两个问题: 当媒体 Controller 获得焦点时,即用户触摸它然后触摸屏幕的另一部分时,媒体 Control
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我在对话框中显示一个 VideoView 并向其附加一个媒体控件。 但是当我尝试点击媒体控件(播放、搜索栏等)时,对话框会消失。 媒体控制按钮不会被点击,而是将点击注册为 Dialog 的 Outsi
我目前正在使用 HTML 编写可打印文档,它将显示从数据库中提取的数据。我的想法是我将使用 HTML/CSS 使文档看起来不错,但它将专门用于打印。 文档的布局使用表格来控制数据库中数据的显示方式。
我需要在网络应用程序中打印我的报告。 我有在我的代码中。但它不应用任何样式。另一方面,如果我使用 在文档中编写 print.css 代码一切正常。 怎么了? 最佳答案 也许你在主样式之前插入打印样式
CSS html{ overflow-y:scroll; } js function showW(){ var a=($(window).width()); $('#
我编写了一个 Chrome 扩展程序,其中一个功能是您可以在您所在的页面中调出一个帮助面板,其中包含其使用指南。这个帮助面板是通过JS插入到页面中的,它的CSS都是通过$('#selector_for
我需要为 WORM 媒体开发归档软件。 这种类型的媒体允许通常的访问操作:读取、写入,但文件一旦写入,就无法修改或删除。 因为这样的媒体可能很昂贵,我想知道如何在开发阶段为测试创建一个假的 WORM
下面的这个 Activity 工作正常,但 mediaController 仅在我单击屏幕时显示。第二个问题是媒体 Controller 只显示 3 秒。我应该怎么做才能消除这个问题? public
我正在使用 VideoView 播放本地 mp4,我也在使用 MediaController。媒体控制栏未显示在我的视频剪辑下方,而是显示在屏幕中间。我使用 setAnchorView 将其附加到我的
我的布局包含 videoView 还有java代码中的Medicontrolleri: final MediaController mediaCont
我是一名优秀的程序员,十分优秀!