Просмотр исходного кода

Revert "Editor: @ffmpeg/ffmpeg@0.12.15 (#31467)" (#31469)

This reverts commit f82dd5e3e9df2e04875fd0fcd886fa07f792e754.
Michael Herzog 7 месяцев назад
Родитель
Сommit
a15e758bd8
2 измененных файлов с 12 добавлено и 13 удалено
  1. 3 3
      editor/index.html
  2. 9 10
      editor/js/Sidebar.Project.Video.js

+ 3 - 3
editor/index.html

@@ -20,9 +20,7 @@
 
 					"three/examples/": "../examples/",
 					"three-gpu-pathtracer": "https://cdn.jsdelivr.net/npm/three-gpu-pathtracer@0.0.23/build/index.module.js",
-					"three-mesh-bvh": "https://cdn.jsdelivr.net/npm/three-mesh-bvh@0.7.4/build/index.module.js",
-					"@ffmpeg/ffmpeg": "https://cdn.jsdelivr.net/npm/@ffmpeg/ffmpeg@0.12.15/dist/esm/index.js",
-					"@ffmpeg/util": "https://cdn.jsdelivr.net/npm/@ffmpeg/util@0.12.2/dist/esm/index.js"
+					"three-mesh-bvh": "https://cdn.jsdelivr.net/npm/three-mesh-bvh@0.7.4/build/index.module.js"
 				}
 			}
 		</script>
@@ -38,6 +36,8 @@
 		<script src="js/libs/esprima.js"></script>
 		<script src="js/libs/jsonlint.js"></script>
 
+		<script src="https://cdn.jsdelivr.net/npm/@ffmpeg/ffmpeg@0.11.6/dist/ffmpeg.min.js"></script>
+
 		<link rel="stylesheet" href="js/libs/codemirror/addon/dialog.css">
 		<link rel="stylesheet" href="js/libs/codemirror/addon/show-hint.css">
 		<link rel="stylesheet" href="js/libs/codemirror/addon/tern.css">

+ 9 - 10
editor/js/Sidebar.Project.Video.js

@@ -1,6 +1,4 @@
 import { UIBreak, UIButton, UIInteger, UIPanel, UIRow, UIText } from './libs/ui.js';
-import { FFmpeg } from '@ffmpeg/ffmpeg';
-import { fetchFile } from '@ffmpeg/util';
 
 import { APP } from './libs/app.js';
 
@@ -136,11 +134,12 @@ function SidebarProjectVideo( editor ) {
 
 		//
 
-		const ffmpeg = new FFmpeg();
+		const { createFFmpeg, fetchFile } = FFmpeg; // eslint-disable-line no-undef
+		const ffmpeg = createFFmpeg( { log: true } );
 
 		await ffmpeg.load();
 
-		ffmpeg.on( 'progress', ( { ratio } ) => {
+		ffmpeg.setProgress( ( { ratio } ) => {
 
 			encodingStatus.textContent = `( ${ Math.floor( ratio * 100 ) }% )`;
 
@@ -154,7 +153,7 @@ function SidebarProjectVideo( editor ) {
 
 			} else {
 
-				ffmpeg.terminate();
+				ffmpeg.exit();
 
 			}
 
@@ -178,7 +177,7 @@ function SidebarProjectVideo( editor ) {
 
 				if ( output.closed ) return;
 
-				await ffmpeg.writeFile( `tmp.${num}.png`, await fetchFile( canvas.toDataURL() ) );
+				ffmpeg.FS( 'writeFile', `tmp.${num}.png`, await fetchFile( canvas.toDataURL() ) );
 				currentTime += 1 / fps;
 
 				const frame = i + 1;
@@ -190,18 +189,18 @@ function SidebarProjectVideo( editor ) {
 			encodingText.hidden = false;
 			encodingStatus.hidden = false;
 
-			await ffmpeg.exec( [ '-framerate', String( fps ), '-pattern_type', 'glob', '-i', '*.png', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-preset', 'slow', '-crf', String( 5 ), 'out.mp4' ] );
+			await ffmpeg.run( '-framerate', String( fps ), '-pattern_type', 'glob', '-i', '*.png', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-preset', 'slow', '-crf', String( 5 ), 'out.mp4' );
 
-			const videoData = await ffmpeg.readFile( 'out.mp4' );
+			const videoData = ffmpeg.FS( 'readFile', 'out.mp4' );
 
 			for ( let i = 0; i < frames; i ++ ) {
 
 				const num = i.toString().padStart( 5, '0' );
-				await ffmpeg.deleteFile( `tmp.${num}.png` );
+				ffmpeg.FS( 'unlink', `tmp.${num}.png` );
 
 			}
 
-			await ffmpeg.deleteFile( 'out.mp4' );
+			ffmpeg.FS( 'unlink', 'out.mp4' );
 
 			output.document.body.removeChild( canvas );
 

粤ICP备19079148号