So my program is setup to download a video and stream it into a file. These videos are .mp4 and .mov.
The problem is that .mov files do not work and I think it's just the way I am streaming the file. But I am not sure. Because .mp4 files work without any errors. But when I use .mov files I get an error saying
Powershell Errors: [mov,mp4,m4a,3gp,3g2,mj2 @ 000002707b9cb700] moov atom not found
Which is coming from this powershell script:
ffmpeg -i $Args[0] -vcodec copy -acodec copy -movflags +faststart $Args[1]
The code that calls this script is as follows:
streamVideos_PROMISES.push(
axios({
method: "get",
url: video.url,
responseType: "stream"
})
);
}
});
Promise.all(streamVideos_PROMISES)
.then(function(response) {
response.map(response_item => {
let tempFileName = new Date().valueOf();
let videoType = response_item.headers["content-type"].split("/")[1];
if (videoType === "quicktime") videoType = "mov"; <---Maybe the issue?
const file = fs.createWriteStream(
`./cache/videos/${tempFileName + "."}${videoType}`
);
var spawn = require("child_process").spawn,
child;
response_item.data.pipe(file);
child = spawn("powershell.exe", [
"./scripts/ffmpeg_convert.ps1",
`./cache/videos/${tempFileName + "."}${videoType}`,
` ./cache/converted_videos/${tempFileName + "."}${videoType}`
]);
child.stdout.on("data", function(data) {
console.log("Powershell Data: " + data);
});
child.stderr.on("data", function(data) {
console.log("Powershell Errors: " + data);
});
child.on("exit", function() {
console.log("Finished converting thumbnails");
return thumbsupply.generateThumbnail(
`./cache/converted_videos/${tempFileName + "."}${videoType}`,
{
mimetype: response_item.headers["content-type"]
}
);
});
child.stdin.end(); //end input
});
})
.catch(err => {
console.log(err);
res.status(500).json({ Error: "Could not generate thumbnail" });
});
note
The response_item.headers["content-type"].split("/") for .mov is quicktime, so I assumed that I could interchange the extensions...Which is probably wrong.
Edit
So I manually typed in the $args as follows:
ffmpeg -i "./cache/videos/1556897345129.mov" -vcodec copy -acodec copy -movflags +faststart "./cache/converted_videos/are_you_kidding_me.mov"
and it works.
Edit 2
child = spawn("powershell.exe", [
"./scripts/ffmpeg_convert.ps1",
"./cache/videos/1556897345129.mov", <-- Using the string literal works.
` ./cache/converted_videos/${tempFileName + "."}${videoType}`
]);