admin管理员组文章数量:1393064
this is the code that i used. this code create a minifest.mpd file, with the same resolution AdaptationSet set
const createCourse = async (req: Request, res: Response, next: NextFunction) => {
try {
const VIDEO_STORAGE_PATH = path.join(__dirname, "../../public/uploads").replace(/\\/g, "/");
const videoId = req.body.videoId;
const inputPath = path.join(VIDEO_STORAGE_PATH, "original", `${videoId}.mp4`).replace(/\\/g, "/");
const outputDir = path.join(VIDEO_STORAGE_PATH, "dash", videoId).replace(/\\/g, "/");
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
if (!ffmpegStatic) {
return next(new Error("❌ ffmpegStatic path is null"));
}
ffmpeg.setFfmpegPath(ffmpegStatic);
const qualities = [
{ resolution: "1280x720", bitrate: "1800k" },
{ resolution: "854x480", bitrate: "1200k" },
{ resolution: "640x360", bitrate: "800k" },
{ resolution: "426x240", bitrate: "400k" }
];
const outputMpd = path.join(outputDir, "manifest.mpd").replace(/\\/g, "/");
// Create FFmpeg command
let command = ffmpeg(inputPath)
.output(outputMpd)
.outputOptions([
'-f dash', // Output format
'-seg_duration 4', // Segment duration in seconds
'-window_size 10', // Number of segments in the manifest
'-init_seg_name init-stream$RepresentationID$.webm', // Name for initialization segments
'-media_seg_name chunk-stream$RepresentationID$-$Number%05d$.webm', // Name for media segments
]);
// Add multiple resolutions
qualities.forEach(({ resolution, bitrate }) => {
console.log('esolution, bitrate :>> ', resolution, bitrate);
command
.outputOptions([
`-map 0:v`, // Map the video stream
`-s ${resolution}`, // Set resolution
`-b:v ${bitrate}`, // Set bitrate
`-c:v libvpx-vp9`, // Use VP9 codec
`-c:a libopus`, // Use Opus codec
]);
});
command
.on("end", () => {
console.log(`
本文标签:
expresswhy mpd file contain same resolution AdaptationSetStack Overflow
版权声明:本文标题:express - why mpd file contain same resolution AdaptationSet - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1744630468a2616506.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论