concat demux bug
This commit is contained in:
parent
aa39f0f1c6
commit
f93ae84794
53
examples/browser/concatDemux.html
Normal file
53
examples/browser/concatDemux.html
Normal file
@ -0,0 +1,53 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="/dist/ffmpeg.dev.js"></script>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>Upload a Video File</h3>
|
||||
<video id="output-video" controls></video><br />
|
||||
<input type="file" id="uploader" />
|
||||
<p id="message"></p>
|
||||
<script>
|
||||
const { createWorker } = FFmpeg;
|
||||
const worker = createWorker({
|
||||
corePath: "../../node_modules/@ffmpeg/core/ffmpeg-core.js",
|
||||
logger: ({ message }) => console.log(message)
|
||||
});
|
||||
|
||||
const transcode = async ({ target: { files } }) => {
|
||||
const message = document.getElementById("message");
|
||||
const { name } = files[0];
|
||||
message.innerHTML = "Loading ffmpeg-core.js";
|
||||
await worker.load();
|
||||
message.innerHTML = "Start Concating";
|
||||
await worker.write(name, files[0]);
|
||||
const textFileName = "list.txt";
|
||||
await worker.writeText(textFileName, `file ${name}\nfile ${name}`);
|
||||
await worker.concatDemux(textFileName, "output.mp4");
|
||||
message.innerHTML = "Complete Concating";
|
||||
const { data } = await worker.read("output.mp4");
|
||||
const video = document.getElementById("output-video");
|
||||
video.src = URL.createObjectURL(
|
||||
new Blob([data.buffer], { type: "video/mp4" })
|
||||
);
|
||||
};
|
||||
const elm = document.getElementById("uploader");
|
||||
elm.addEventListener("change", transcode);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -122,6 +122,12 @@ module.exports = (_options = {}) => {
|
||||
)
|
||||
);
|
||||
|
||||
const concatDemux = (texFilePath, outputPath, opts = '', del = false, jobId) => {
|
||||
run(`${opts} -f concat -safe 0 -i /data/${texFilePath} -c copy ${outputPath}`,
|
||||
{ del },
|
||||
jobId);
|
||||
};
|
||||
|
||||
const ls = (path, jobId) => (
|
||||
startJob(createJob({
|
||||
id: jobId, action: 'ls', payload: { path },
|
||||
@ -175,6 +181,7 @@ module.exports = (_options = {}) => {
|
||||
run,
|
||||
transcode,
|
||||
trim,
|
||||
concatDemux,
|
||||
ls,
|
||||
terminate,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user