I wanna to need help that i wanna to convert .fbx to video through script and i found a soluotion to do it through FFmpeg but it not supports .fbx so i need help in to get frame images so i can make video through ffmpeg or if i am goin in wrong direction you can help me
I tried to convert a .fbx file to .obj using three.js and then create a video from the .obj file, but it didn’t work.
<script>
// Function to load FBX using FBXLoader
function loadFBX(blob, loader, callback) {
var url = URL.createObjectURL(blob);
loader.load(url, function(object) {
callback(object);
});
}
// Function to export THREE.Object3D to OBJ format using OBJExporter
function exportToOBJ(object, callback) {
var exporter = new THREE.OBJExporter();
var result = exporter.parse(object);
callback(result);
}
// Function to send OBJ file to PHP script
function sendToPHP(objBlob, fileName) {
var formData = new FormData();
formData.append('objFile', objBlob, fileName);
var xhr = new XMLHttpRequest();
xhr.open('POST', 'convert.php', true);
xhr.onload = function() {
if (xhr.status === 200) {
console.log('Conversion successful:', xhr.responseText);
} else {
console.error('Conversion failed:', xhr.responseText);
}
};
xhr.send(formData);
}
// Function to convert FBX to OBJ
function convertToOBJ() {
var fileInput = document.getElementById('fileInput');
var file = fileInput.files[0];
if (file) {
var reader = new FileReader();
reader.onload = function(event) {
var arrayBuffer = event.target.result;
var blob = new Blob([arrayBuffer]);
var loader = new THREE.FBXLoader();
loadFBX(blob, loader, function(object) {
exportToOBJ(object, function(objText) {
var objBlob = new Blob([objText], { type: 'text/plain' });
sendToPHP(objBlob, file.name.split('.')[0] + '.obj');
});
});
};
reader.readAsArrayBuffer(file);
} else {
alert('Please select an FBX file to convert.');
}
}
</script>
<?php
// Check if form submitted and file uploaded
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES["objFile"])) {
$objFile = $_FILES["objFile"];
$objFilePath = $objFile["tmp_name"];
$outputVideo = 'output.mp4';
// Execute FFmpeg command to convert OBJ to video
exec("ffmpeg -i "$objFilePath" $outputVideo", $output, $returnCode);
if ($returnCode === 0) {
echo 'Conversion successful';
} else {
echo 'Conversion failed';
}
} else {
echo 'No OBJ file uploaded';
}
?>