├── build_agpl ├── asm.js │ ├── benchmark.js │ ├── bigbuckbunny.jpg │ ├── bigbuckbunny.webm │ ├── ffmpeg-all-codecs.js │ ├── ffmpeg-all-codecs.js.mem │ ├── ffmpeg.js │ ├── ffmpeg.js.mem │ ├── index.html │ ├── lodash.js │ ├── site │ │ ├── code-blocks │ │ │ ├── example-1.html │ │ │ ├── example-1.txt │ │ │ ├── example-2.html │ │ │ ├── example-2.txt │ │ │ ├── example-3.html │ │ │ ├── example-3.txt │ │ │ ├── example-4.html │ │ │ ├── example-4.txt │ │ │ ├── example-5.html │ │ │ └── example-5.txt │ │ ├── favicon.ico │ │ ├── light_toast.png │ │ ├── load.gif │ │ ├── logo.png │ │ ├── site.css │ │ └── site.js │ ├── terminal.js │ ├── worker-asm.js │ └── worker.js ├── index.html └── wasm │ ├── benchmark.js │ ├── bigbuckbunny.jpg │ ├── bigbuckbunny.webm │ ├── ffmpeg.js │ ├── ffmpeg.wasm │ ├── ffmpeg_post.js │ ├── ffmpeg_pre.js │ ├── index.html │ ├── lodash.js │ ├── site │ ├── code-blocks │ │ ├── example-1.html │ │ ├── example-1.txt │ │ ├── example-2.html │ │ ├── example-2.txt │ │ ├── example-3.html │ │ ├── example-3.txt │ │ ├── example-4.html │ │ ├── example-4.txt │ │ ├── example-5.html │ │ └── example-5.txt │ ├── favicon.ico │ ├── light_toast.png │ ├── load.gif │ ├── logo.png │ ├── site.css │ └── site.js │ ├── terminal.js │ ├── worker-asm.js │ └── worker.js ├── build_all_codecs ├── asm.js │ ├── benchmark.js │ ├── bigbuckbunny.jpg │ ├── bigbuckbunny.webm │ ├── ffmpeg-all-codecs.js │ ├── ffmpeg-all-codecs.js.mem │ ├── index.html │ ├── lodash.js │ ├── site │ │ ├── code-blocks │ │ │ ├── example-1.html │ │ │ ├── example-1.txt │ │ │ ├── example-2.html │ │ │ ├── example-2.txt │ │ │ ├── example-3.html │ │ │ ├── example-3.txt │ │ │ ├── example-4.html │ │ │ ├── example-4.txt │ │ │ ├── example-5.html │ │ │ └── example-5.txt │ │ ├── favicon.ico │ │ ├── light_toast.png │ │ ├── load.gif │ │ ├── logo.png │ │ ├── site.css │ │ └── site.js │ ├── terminal.js │ ├── worker-asm.js │ └── worker.js ├── index.html └── wasm │ ├── benchmark.js │ ├── bigbuckbunny.jpg │ ├── bigbuckbunny.webm │ ├── ffmpeg-all-codecs.js │ ├── ffmpeg-all-codecs.js.mem │ ├── ffmpeg-all-codecs.wasm │ ├── index.html │ ├── lodash.js │ ├── site │ ├── code-blocks │ │ ├── example-1.html │ │ ├── example-1.txt │ │ ├── example-2.html │ │ ├── example-2.txt │ │ ├── example-3.html │ │ ├── example-3.txt │ │ ├── example-4.html │ │ ├── example-4.txt │ │ ├── example-5.html │ │ └── example-5.txt │ ├── favicon.ico │ ├── light_toast.png │ ├── load.gif │ ├── logo.png │ ├── site.css │ └── site.js │ ├── terminal.js │ ├── worker-asm.js │ └── worker.js └── index.html /build_agpl/asm.js/bigbuckbunny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/bigbuckbunny.jpg -------------------------------------------------------------------------------- /build_agpl/asm.js/bigbuckbunny.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/bigbuckbunny.webm -------------------------------------------------------------------------------- /build_agpl/asm.js/ffmpeg-all-codecs.js.mem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/ffmpeg-all-codecs.js.mem -------------------------------------------------------------------------------- /build_agpl/asm.js/ffmpeg.js.mem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/ffmpeg.js.mem -------------------------------------------------------------------------------- /build_agpl/asm.js/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | videoconverter.js - Convert Videos In Your Web Browser 6 | 7 | 8 | 9 | 10 | 62 | 63 | 64 | 65 |
66 |
67 |
68 |
69 |
70 |

videoconverter.js 71 |

72 |
73 | 78 |
79 | 80 |
81 |

Terminal Demo

82 |

83 | Imagine that you have installed FFmpeg on your computer. Also imagine that you have files called input.webm and input.jpeg in the current directory. Feel free to run whatever commands you want, or try the sample commands below: 84 |

85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
115 |
116 | videoconverter.js 117 |
118 |
119 | 120 | 121 | 122 |
123 |
Loading JavaScript files (it may take a minute)
124 |
125 |
126 | 127 |
128 |
129 |
130 |
131 | 132 |
133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-1.html: -------------------------------------------------------------------------------- 1 |
var results = ffmpeg_run({
 2 |   arguments: [string],
 3 |   files: [
 4 |     {
 5 |       data: UInt8Array,
 6 |       name: string
 7 |     }
 8 |   ]
 9 | });
10 | 
11 | // results is an Array of { data: UInt8Array, name: string }
12 | results.forEach(function(file) {
13 |   console.log("File recieved", file.name, file.data);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-1.txt: -------------------------------------------------------------------------------- 1 | var results = ffmpeg_run({ 2 | arguments: [string], 3 | files: [ 4 | { 5 | data: UInt8Array, 6 | name: string 7 | } 8 | ] 9 | }); 10 | 11 | // results is an Array of { data: UInt8Array, name: string } 12 | results.forEach(function(file) { 13 | console.log("File recieved", file.name, file.data); 14 | }); 15 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-2.html: -------------------------------------------------------------------------------- 1 |
importScripts('ffmpeg.js');
 2 | 
 3 | function print(text) {
 4 |   postMessage({
 5 |     'type' : 'stdout',
 6 |     'data' : text
 7 |   });
 8 | }
 9 | 
10 | onmessage = function(event) {
11 |   var module = {
12 |     files: event.data.files || [],
13 |     arguments: event.data.arguments || [],
14 |     print: print,
15 |     printErr: print
16 |   };
17 |   postMessage({
18 |     'type' : 'start',
19 |     'data' : module.arguments
20 |   });
21 |   var result = ffmpeg_run(module);
22 |   postMessage({
23 |     'type' : 'done',
24 |     'data' : result
25 |   });
26 | };
27 | 
28 | postMessage({
29 |   'type' : 'ready'
30 | });
31 | 
32 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-2.txt: -------------------------------------------------------------------------------- 1 | importScripts('ffmpeg.js'); 2 | 3 | function print(text) { 4 | postMessage({ 5 | 'type' : 'stdout', 6 | 'data' : text 7 | }); 8 | } 9 | 10 | onmessage = function(event) { 11 | var module = { 12 | files: event.data.files || [], 13 | arguments: event.data.arguments || [], 14 | print: print, 15 | printErr: print 16 | }; 17 | postMessage({ 18 | 'type' : 'start', 19 | 'data' : module.arguments 20 | }); 21 | var result = ffmpeg_run(module); 22 | postMessage({ 23 | 'type' : 'done', 24 | 'data' : result 25 | }); 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'ready' 30 | }); 31 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-3.html: -------------------------------------------------------------------------------- 1 |
var worker = new Worker("worker.js");
 2 | worker.onmessage = function (event) {
 3 |   var message = event.data;
 4 |   if (message.type == "ready") {
 5 |     outputElement.textContent = "Loaded";
 6 |     worker.postMessage({
 7 |       type: 'command',
 8 |       arguments: ['-help']
 9 |     })
10 |   } else if (message.type == "stdout") {
11 |     outputElement.textContent += message.data + "\n";
12 |   } else if (message.type == "start") {
13 |     outputElement.textContent = "Worker has received command\n";
14 |   }
15 | };
16 | 
17 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-3.txt: -------------------------------------------------------------------------------- 1 | var worker = new Worker("worker.js"); 2 | worker.onmessage = function (event) { 3 | var message = event.data; 4 | if (message.type == "ready") { 5 | outputElement.textContent = "Loaded"; 6 | worker.postMessage({ 7 | type: 'command', 8 | arguments: ['-help'] 9 | }) 10 | } else if (message.type == "stdout") { 11 | outputElement.textContent += message.data + "\n"; 12 | } else if (message.type == "start") { 13 | outputElement.textContent = "Worker has received command\n"; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-4.html: -------------------------------------------------------------------------------- 1 |
var sampleVideoData;
 2 | function retrieveSampleVideo() {
 3 |   var oReq = new XMLHttpRequest();
 4 |   oReq.open("GET", "bigbuckbunny.webm", true);
 5 |   oReq.responseType = "arraybuffer";
 6 | 
 7 |   oReq.onload = function (oEvent) {
 8 |     var arrayBuffer = oReq.response;
 9 |     if (arrayBuffer) {
10 |       sampleVideoData = new Uint8Array(arrayBuffer);
11 |     }
12 |   };
13 | 
14 |   oReq.send(null);
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-4.txt: -------------------------------------------------------------------------------- 1 | var sampleVideoData; 2 | function retrieveSampleVideo() { 3 | var oReq = new XMLHttpRequest(); 4 | oReq.open("GET", "bigbuckbunny.webm", true); 5 | oReq.responseType = "arraybuffer"; 6 | 7 | oReq.onload = function (oEvent) { 8 | var arrayBuffer = oReq.response; 9 | if (arrayBuffer) { 10 | sampleVideoData = new Uint8Array(arrayBuffer); 11 | } 12 | }; 13 | 14 | oReq.send(null); 15 | } 16 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-5.html: -------------------------------------------------------------------------------- 1 |
function getDownloadLink(fileData, fileName) {
 2 |   var a = document.createElement('a');
 3 |   a.download = fileName;
 4 |   var blob = new Blob([fileData]);
 5 |   var src = window.URL.createObjectURL(blob);
 6 |   a.href = src;
 7 |   a.textContent = 'Click here to download ' + fileName + "!";
 8 |   return a;
 9 | }
10 | 
11 | var result = ffmpeg_run(module);
12 | result.forEach(function(file) {
13 |   getDownloadLink(file.data, file.name);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/code-blocks/example-5.txt: -------------------------------------------------------------------------------- 1 | function getDownloadLink(fileData, fileName) { 2 | var a = document.createElement('a'); 3 | a.download = fileName; 4 | var blob = new Blob([fileData]); 5 | var src = window.URL.createObjectURL(blob); 6 | a.href = src; 7 | a.textContent = 'Click here to download ' + fileName + "!"; 8 | return a; 9 | } 10 | 11 | var result = ffmpeg_run(module); 12 | result.forEach(function(file) { 13 | getDownloadLink(file.data, file.name); 14 | }); 15 | -------------------------------------------------------------------------------- /build_agpl/asm.js/site/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/site/favicon.ico -------------------------------------------------------------------------------- /build_agpl/asm.js/site/light_toast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/site/light_toast.png -------------------------------------------------------------------------------- /build_agpl/asm.js/site/load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/site/load.gif -------------------------------------------------------------------------------- /build_agpl/asm.js/site/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/site/logo.png -------------------------------------------------------------------------------- /build_agpl/asm.js/site/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | 5 | html, body { 6 | padding: 0; 7 | margin: 0; 8 | } 9 | 10 | body { 11 | position: relative; 12 | } 13 | 14 | body { 15 | min-height: 100%; 16 | background: #eee url(light_toast.png); 17 | font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif; 18 | line-height: 1.5; 19 | font-weight: 300; 20 | color: #4D4D4D; 21 | min-width: 630px; 22 | } 23 | 24 | center { 25 | margin: 10px 0; 26 | } 27 | 28 | strong { 29 | font-weight: bold; 30 | } 31 | 32 | .container-fluid { 33 | width: 90%; 34 | margin: 0 auto; 35 | height: 100%; 36 | min-height: 100%; 37 | font-size: 14px; 38 | background: rgba(255, 255, 255, .8); 39 | padding: 0 10px; 40 | } 41 | 42 | .content { 43 | padding-bottom: 20px; 44 | } 45 | 46 | p, li { 47 | font-size: 16px; 48 | } 49 | 50 | .header { 51 | margin: 0 -5.6%; 52 | padding: 5px 5.6%; 53 | box-shadow: 0 0 3px #74ad5a; 54 | margin-bottom: 4px; 55 | background-image: -webkit-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 56 | background-image: -moz-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 57 | background-image: -o-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 58 | background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 59 | -webkit-background-size: 4px 4px; 60 | -moz-background-size: 4px 4px; 61 | background-size: 4px 4px; 62 | } 63 | 64 | h2 { 65 | font-family: Georgia; 66 | text-transform: uppercase; 67 | margin: 5px 0; 68 | font-size: 24px; 69 | font-weight: lighter; 70 | } 71 | 72 | h2 a { 73 | opacity: 0; 74 | text-decoration: none; 75 | font-style: normal; 76 | color: #333; 77 | vertical-align: text-top; 78 | font-size: 80%; 79 | text-transform: none; 80 | transition: opacity linear .1s; 81 | } 82 | 83 | h2:hover a { 84 | opacity: 1; 85 | } 86 | 87 | h2 a:hover { 88 | color: #74ad5a; 89 | } 90 | 91 | h3 { 92 | font-size: 18px; 93 | text-decoration: underline; 94 | font-family: Georgia; 95 | font-weight: normal; 96 | } 97 | 98 | h1 { 99 | margin: 0; 100 | padding: 0; 101 | font-size: 32px; 102 | line-height: 32px; 103 | font-weight: 300; 104 | } 105 | 106 | h1 a, h1 a:visited { 107 | color: #333; 108 | text-decoration: none; 109 | } 110 | 111 | h1 a:hover { 112 | text-decoration: underline; 113 | } 114 | 115 | h1 span { 116 | vertical-align: top; 117 | margin-left: 5px; 118 | } 119 | 120 | .warning { 121 | background-color: #FEE8E8; 122 | border: 1px solid #DDD; 123 | font-size: 13px; 124 | line-height: 19px; 125 | overflow: auto; 126 | padding: 6px 10px; 127 | border-radius: 3px; 128 | } 129 | .note { 130 | background-color: #E8FEE8; 131 | border: 1px solid #DDD; 132 | font-size: 13px; 133 | line-height: 19px; 134 | overflow: auto; 135 | padding: 6px 10px; 136 | border-radius: 3px; 137 | } 138 | 139 | code, pre { 140 | font-family: Consolas,"Liberation Mono",Courier,monospace; 141 | } 142 | 143 | pre { 144 | font-size: 12px; 145 | background-color: #F8F8F8; 146 | border: 1px solid #BDB; 147 | font-size: 13px; 148 | line-height: 19px; 149 | overflow: auto; 150 | padding: 6px 10px; 151 | border-radius: 3px; 152 | color: #232; 153 | } 154 | 155 | code { 156 | color: #696; 157 | font-family: inherit; 158 | } 159 | 160 | .tagline { 161 | font-size: 24px; 162 | } 163 | 164 | a.big { 165 | -moz-box-shadow: inset 0px 1px 0px 0px #9acc85; 166 | -webkit-box-shadow: inset 0px 1px 0px 0px #9acc85; 167 | box-shadow: inset 0px 1px 0px 0px #9acc85; 168 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #74ad5a), color-stop(1, #68a54b)); 169 | background: -moz-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 170 | background: -webkit-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 171 | background: -o-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 172 | background: -ms-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 173 | background: linear-gradient(to bottom, #74ad5a 5%, #68a54b 100%); 174 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#74ad5a', endColorstr='#68a54b',GradientType=0); 175 | background-color: #74ad5a; 176 | border: 1px solid #3b6e22; 177 | display: inline-block; 178 | color: #ffffff; 179 | font-size: 20px; 180 | padding: 8px 12px; 181 | text-decoration: none; 182 | } 183 | 184 | a.big:hover { 185 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #68a54b), color-stop(1, #74ad5a)); 186 | background: -moz-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 187 | background: -webkit-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 188 | background: -o-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 189 | background: -ms-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 190 | background: linear-gradient(to bottom, #68a54b 5%, #74ad5a 100%); 191 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#68a54b', endColorstr='#74ad5a',GradientType=0); 192 | background-color: #68a54b; 193 | } 194 | 195 | a.big:active { 196 | position: relative; 197 | top: 1px; 198 | } 199 | 200 | .plain-button { 201 | cursor: pointer; 202 | -moz-box-shadow: inset 0px 1px 0px 0px #ffffff; 203 | -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff; 204 | box-shadow: inset 0px 1px 0px 0px #ffffff; 205 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #f6f6f6)); 206 | background: -moz-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 207 | background: -webkit-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 208 | background: -o-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 209 | background: -ms-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 210 | background: linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%); 211 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f6f6f6',GradientType=0); 212 | background-color: #ffffff; 213 | -moz-border-radius: 6px; 214 | -webkit-border-radius: 6px; 215 | border-radius: 6px; 216 | border: 1px solid #dcdcdc; 217 | display: inline-block; 218 | color: #666666; 219 | font-size: 14px; 220 | padding: 6px 8px; 221 | text-decoration: none; 222 | text-shadow: 0px 1px 0px #ffffff; 223 | } 224 | 225 | .plain-button:hover { 226 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff)); 227 | background: -moz-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 228 | background: -webkit-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 229 | background: -o-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 230 | background: -ms-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 231 | background: linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); 232 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6f6f6', endColorstr='#ffffff',GradientType=0); 233 | background-color: #f6f6f6; 234 | } 235 | 236 | .plain-button:active { 237 | position: relative; 238 | top: 1px; 239 | } 240 | 241 | .links a { 242 | background: #333; 243 | color: #fff; 244 | padding: 10px; 245 | padding-bottom: 8px; 246 | text-decoration: none; 247 | transition: top ease-in-out .05s; 248 | position: relative; 249 | top: -2px; 250 | } 251 | 252 | .links a:hover { 253 | /*padding-bottom: 10px;*/ 254 | top: 0; 255 | } 256 | 257 | .links a:visited { 258 | color: #ddd; 259 | } 260 | 261 | .pull-left { 262 | float: left; 263 | } 264 | 265 | .pull-right { 266 | float: right; 267 | } 268 | 269 | .clearfix { 270 | *zoom: 1; 271 | } 272 | 273 | .clearfix:before, 274 | .clearfix:after { 275 | display: table; 276 | line-height: 0; 277 | content: ""; 278 | } 279 | 280 | .clearfix:after { 281 | clear: both; 282 | } -------------------------------------------------------------------------------- /build_agpl/asm.js/site/site.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/asm.js/site/site.js -------------------------------------------------------------------------------- /build_agpl/asm.js/terminal.js: -------------------------------------------------------------------------------- 1 | 2 | var worker; 3 | var sampleImageData; 4 | var sampleVideoData; 5 | var outputElement; 6 | var filesElement; 7 | var running = false; 8 | var isWorkerLoaded = false; 9 | var isSupported = (function() { 10 | return document.querySelector && window.URL && window.Worker; 11 | })(); 12 | 13 | function isReady() { 14 | return !running && isWorkerLoaded && sampleImageData && sampleVideoData; 15 | } 16 | 17 | function startRunning() { 18 | document.querySelector("#image-loader").style.visibility = "visible"; 19 | outputElement.className = ""; 20 | filesElement.innerHTML = ""; 21 | running = true; 22 | } 23 | function stopRunning() { 24 | document.querySelector("#image-loader").style.visibility = "hidden"; 25 | running = false; 26 | } 27 | 28 | function retrieveSampleImage() { 29 | var oReq = new XMLHttpRequest(); 30 | oReq.open("GET", "bigbuckbunny.jpg", true); 31 | oReq.responseType = "arraybuffer"; 32 | 33 | oReq.onload = function (oEvent) { 34 | var arrayBuffer = oReq.response; 35 | if (arrayBuffer) { 36 | sampleImageData = new Uint8Array(arrayBuffer); 37 | } 38 | }; 39 | 40 | oReq.send(null); 41 | } 42 | 43 | function retrieveSampleVideo() { 44 | var oReq = new XMLHttpRequest(); 45 | oReq.open("GET", "bigbuckbunny.webm", true); 46 | oReq.responseType = "arraybuffer"; 47 | 48 | oReq.onload = function (oEvent) { 49 | var arrayBuffer = oReq.response; 50 | if (arrayBuffer) { 51 | sampleVideoData = new Uint8Array(arrayBuffer); 52 | } 53 | }; 54 | 55 | oReq.send(null); 56 | } 57 | 58 | function parseArguments(text) { 59 | text = text.replace(/\s+/g, ' '); 60 | var args = []; 61 | // Allow double quotes to not split args. 62 | text.split('"').forEach(function(t, i) { 63 | t = t.trim(); 64 | if ((i % 2) === 1) { 65 | args.push(t); 66 | } else { 67 | args = args.concat(t.split(" ")); 68 | } 69 | }); 70 | return args; 71 | } 72 | 73 | 74 | function runCommand(text) { 75 | if (isReady()) { 76 | startRunning(); 77 | var args = parseArguments(text); 78 | console.log(args); 79 | if (typeof(args[0]) == "string" && args[0] == "benchmark") { 80 | args.shift(); 81 | worker.postMessage({ 82 | type: "benchmark", 83 | arguments: args, 84 | files: [ 85 | { 86 | "name": "input.jpeg", 87 | "data": sampleImageData 88 | }, 89 | { 90 | "name": "input.webm", 91 | "data": sampleVideoData 92 | } 93 | ] 94 | }); 95 | } else { 96 | worker.postMessage({ 97 | type: "command", 98 | arguments: args, 99 | files: [ 100 | { 101 | "name": "input.jpeg", 102 | "data": sampleImageData 103 | }, 104 | { 105 | "name": "input.webm", 106 | "data": sampleVideoData 107 | } 108 | ] 109 | }); 110 | } 111 | } 112 | } 113 | 114 | function getDownloadLink(fileData, fileName) { 115 | if (fileName.match(/\.jpeg|\.gif|\.jpg|\.png/)) { 116 | var blob = new Blob([fileData]); 117 | var src = window.URL.createObjectURL(blob); 118 | var img = document.createElement('img'); 119 | 120 | img.src = src; 121 | return img; 122 | } 123 | else { 124 | var a = document.createElement('a'); 125 | a.download = fileName; 126 | var blob = new Blob([fileData]); 127 | var src = window.URL.createObjectURL(blob); 128 | a.href = src; 129 | a.textContent = 'Click here to download ' + fileName + "!"; 130 | return a; 131 | } 132 | } 133 | 134 | function initWorker() { 135 | worker = new Worker("worker-asm.js"); 136 | worker.onmessage = function (event) { 137 | var message = event.data; 138 | if (message.type == "ready") { 139 | isWorkerLoaded = true; 140 | worker.postMessage({ 141 | type: "command", 142 | arguments: ["-help"] 143 | }); 144 | } else if (message.type == "stdout") { 145 | outputElement.textContent += message.data + "\n"; 146 | } else if (message.type == "start") { 147 | outputElement.textContent = "Worker has received command\n"; 148 | } else if (message.type == "done") { 149 | stopRunning(); 150 | var buffers = message.data; 151 | if (buffers.length) { 152 | outputElement.className = "closed"; 153 | } 154 | buffers.forEach(function(file) { 155 | filesElement.appendChild(getDownloadLink(file.data, file.name)); 156 | }); 157 | } 158 | }; 159 | } 160 | 161 | document.addEventListener("DOMContentLoaded", function() { 162 | 163 | initWorker(); 164 | retrieveSampleVideo(); 165 | retrieveSampleImage(); 166 | 167 | var inputElement = document.querySelector("#input"); 168 | outputElement = document.querySelector("#output"); 169 | filesElement = document.querySelector("#files"); 170 | 171 | inputElement.addEventListener("keydown", function(e) { 172 | if (e.keyCode === 13) { 173 | runCommand(inputElement.value); 174 | } 175 | }, false); 176 | document.querySelector("#run").addEventListener("click", function() { 177 | runCommand(inputElement.value); 178 | }); 179 | 180 | [].forEach.call(document.querySelectorAll(".sample"), function(link) { 181 | link.addEventListener("click", function(e) { 182 | inputElement.value = this.getAttribute("data-command"); 183 | runCommand(inputElement.value); 184 | e.preventDefault(); 185 | }); 186 | }); 187 | 188 | }); 189 | -------------------------------------------------------------------------------- /build_agpl/asm.js/worker-asm.js: -------------------------------------------------------------------------------- 1 | importScripts('./ffmpeg.js'); 2 | importScripts('./lodash.js'); 3 | importScripts('./benchmark.js'); 4 | 5 | var now = Date.now; 6 | 7 | function print(text) { 8 | postMessage({ 9 | 'type' : 'stdout', 10 | 'data' : text 11 | }); 12 | } 13 | 14 | onmessage = function(event) { 15 | 16 | var message = event.data; 17 | 18 | if (message.type === "command") { 19 | 20 | var Module = { 21 | print: print, 22 | printErr: print, 23 | files: message.files || [], 24 | arguments: message.arguments || [], 25 | TOTAL_MEMORY: 268435456 26 | // Can play around with this option - must be a power of 2 27 | // TOTAL_MEMORY: 268435456 28 | }; 29 | 30 | postMessage({ 31 | 'type' : 'start', 32 | 'data' : Module.arguments.join(" ") 33 | }); 34 | 35 | postMessage({ 36 | 'type' : 'stdout', 37 | 'data' : 'Received command: ' + 38 | Module.arguments.join(" ") + 39 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 40 | }); 41 | 42 | var time = now(); 43 | 44 | Module['returnCallback'] = function(result) { 45 | var totalTime = now() - time; 46 | 47 | postMessage({ 48 | 'type' : 'stdout', 49 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 50 | }); 51 | 52 | postMessage({ 53 | 'type' : 'done', 54 | 'data' : result, 55 | 'time' : totalTime 56 | }); 57 | } 58 | 59 | var result = ffmpeg_run(Module); 60 | 61 | } 62 | 63 | if (message.type === "benchmark") { 64 | 65 | var Module = {}; 66 | 67 | postMessage({ 68 | 'type' : 'start', 69 | 'data' : message.arguments.join(" ") 70 | }); 71 | print("Starting benchmark") 72 | 73 | var suite = new Benchmark.Suite 74 | suite.add('ffmpeg', { 75 | 'defer': true, 76 | 'setup': function() { 77 | Module = { 78 | print: function(data){}, 79 | printErr: function(data){}, 80 | files: message.files || [], 81 | arguments: message.arguments.slice() || [], 82 | TOTAL_MEMORY: 268435456 83 | // Can play around with this option - must be a power of 2 84 | // TOTAL_MEMORY: 268435456 85 | }; 86 | print("."); 87 | }, 88 | 'fn': function(deferred) { 89 | Module['returnCallback'] = function(result) { 90 | deferred.resolve(); 91 | } 92 | ffmpeg_run(Module); 93 | } 94 | }).on('complete', function() { 95 | var results = this.filter('fastest')[0]; 96 | print("Samples:" + results.stats.sample.length) 97 | print("Mean:" + results.stats.mean) 98 | print("Variance:" + results.stats.variance) 99 | print("Stddev:" + Math.sqrt(results.stats.variance)) 100 | postMessage({ 101 | 'type' : 'done', 102 | 'data' : [], 103 | 'time' : 0 104 | }); 105 | }).run({'async': true}); 106 | } 107 | }; 108 | 109 | postMessage({ 110 | 'type' : 'ready' 111 | }); 112 | -------------------------------------------------------------------------------- /build_agpl/asm.js/worker.js: -------------------------------------------------------------------------------- 1 | importScripts('./ffmpeg.js'); 2 | 3 | var now = Date.now; 4 | 5 | function print(text) { 6 | postMessage({ 7 | 'type' : 'stdout', 8 | 'data' : text 9 | }); 10 | } 11 | 12 | onmessage = function(event) { 13 | 14 | var message = event.data; 15 | 16 | if (message.type === "command") { 17 | 18 | var Module = { 19 | print: print, 20 | printErr: print, 21 | files: message.files || [], 22 | arguments: message.arguments || [], 23 | TOTAL_MEMORY: message.TOTAL_MEMORY || false 24 | // Can play around with this option - must be a power of 2 25 | // TOTAL_MEMORY: 268435456 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'start', 30 | 'data' : Module.arguments.join(" ") 31 | }); 32 | 33 | postMessage({ 34 | 'type' : 'stdout', 35 | 'data' : 'Received command: ' + 36 | Module.arguments.join(" ") + 37 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 38 | }); 39 | 40 | var time = now(); 41 | var result = ffmpeg_run(Module); 42 | console.log(result); 43 | console.log("post result") 44 | 45 | var totalTime = now() - time; 46 | postMessage({ 47 | 'type' : 'stdout', 48 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 49 | }); 50 | 51 | postMessage({ 52 | 'type' : 'done', 53 | 'data' : result, 54 | 'time' : totalTime 55 | }); 56 | } 57 | }; 58 | 59 | postMessage({ 60 | 'type' : 'ready' 61 | }); 62 | -------------------------------------------------------------------------------- /build_agpl/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/index.html -------------------------------------------------------------------------------- /build_agpl/wasm/bigbuckbunny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/bigbuckbunny.jpg -------------------------------------------------------------------------------- /build_agpl/wasm/bigbuckbunny.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/bigbuckbunny.webm -------------------------------------------------------------------------------- /build_agpl/wasm/ffmpeg.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/ffmpeg.wasm -------------------------------------------------------------------------------- /build_agpl/wasm/ffmpeg_post.js: -------------------------------------------------------------------------------- 1 | 2 | return Module['return']; 3 | } 4 | 5 | if (typeof(exports) !== 'undefined') { 6 | ffmpeg_run.call(this); 7 | } 8 | -------------------------------------------------------------------------------- /build_agpl/wasm/ffmpeg_pre.js: -------------------------------------------------------------------------------- 1 | /* 2 | Most files in FFmpeg are under the GNU Lesser General Public License version 2.1 3 | or later (LGPL v2.1+). Read the file COPYING.LGPLv2.1 for details. Some other 4 | files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to 5 | FFmpeg. 6 | 7 | The source code used to build this file can be obtained at https://github.com/bgrins/videoconverter.js, 8 | and in zip form at https://github.com/bgrins/videoconverter.js/archive/master.zip 9 | */ 10 | var Module = {}; 11 | function ffmpeg_run(opts) { 12 | var isNode = typeof(exports) !== 'undefined'; 13 | if (!isNode) { 14 | var Module = { 15 | 'outputDirectory': 'output' 16 | }; 17 | for (var i in opts) { 18 | Module[i] = opts[i]; 19 | } 20 | var outputFilePath = Module['arguments'][Module['arguments'].length - 1]; 21 | if (Module['arguments'].length > 2 && outputFilePath && outputFilePath.indexOf(".") > -1) { 22 | Module['arguments'][Module['arguments'].length - 1] = "output/" + outputFilePath; 23 | } 24 | Module['preRun'] = function() { 25 | FS.createFolder('/', Module['outputDirectory'], true, true); 26 | /* fileData / fileName is deprecated - please use file.name and file.data instead */ 27 | if (Module['fileData']) { 28 | FS.createDataFile('/', Module['fileName'], Module['fileData'], true, true); 29 | } 30 | if (Module['files']) { 31 | Module['files'].forEach(function(file) { 32 | FS.createDataFile('/', file.name, file.data, true, true); 33 | }); 34 | } 35 | }; 36 | Module['postRun'] = function() { 37 | var handle = FS.analyzePath(Module['outputDirectory']); 38 | Module['return'] = getAllBuffers(handle); 39 | if (typeof(Module['returnCallback']) == "function") { 40 | Module['returnCallback'](Module['return']); 41 | } 42 | }; 43 | function getAllBuffers(result) { 44 | var buffers = []; 45 | if (result && result.object && result.object.contents) { 46 | for (var i in result.object.contents) { 47 | if (result.object.contents.hasOwnProperty(i)) { 48 | buffers.push({ 49 | name: i, 50 | data: new Uint8Array(result.object.contents[i].contents).buffer 51 | }); 52 | } 53 | } 54 | } 55 | return buffers; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /build_agpl/wasm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | videoconverter.js - Convert Videos In Your Web Browser 6 | 7 | 8 | 9 | 10 | 62 | 63 | 64 | 65 |
66 |
67 |
68 |
69 | 73 | 78 |
79 | 80 |
81 |

Terminal Demo

82 |

83 | Imagine that you have installed FFmpeg on your computer. Also imagine that you have files called input.webm and input.jpeg in the current directory. Feel free to run whatever commands you want, or try the sample commands below: 84 |

85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
115 |
116 | videoconverter.js 117 |
118 |
119 | 120 | 121 | 122 |
123 |
Loading JavaScript files (it may take a minute)
124 |
125 |
126 | 127 |
128 |
129 |
130 |
131 | 132 |
133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-1.html: -------------------------------------------------------------------------------- 1 |
var results = ffmpeg_run({
 2 |   arguments: [string],
 3 |   files: [
 4 |     {
 5 |       data: UInt8Array,
 6 |       name: string
 7 |     }
 8 |   ]
 9 | });
10 | 
11 | // results is an Array of { data: UInt8Array, name: string }
12 | results.forEach(function(file) {
13 |   console.log("File recieved", file.name, file.data);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-1.txt: -------------------------------------------------------------------------------- 1 | var results = ffmpeg_run({ 2 | arguments: [string], 3 | files: [ 4 | { 5 | data: UInt8Array, 6 | name: string 7 | } 8 | ] 9 | }); 10 | 11 | // results is an Array of { data: UInt8Array, name: string } 12 | results.forEach(function(file) { 13 | console.log("File recieved", file.name, file.data); 14 | }); 15 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-2.html: -------------------------------------------------------------------------------- 1 |
importScripts('ffmpeg.js');
 2 | 
 3 | function print(text) {
 4 |   postMessage({
 5 |     'type' : 'stdout',
 6 |     'data' : text
 7 |   });
 8 | }
 9 | 
10 | onmessage = function(event) {
11 |   var module = {
12 |     files: event.data.files || [],
13 |     arguments: event.data.arguments || [],
14 |     print: print,
15 |     printErr: print
16 |   };
17 |   postMessage({
18 |     'type' : 'start',
19 |     'data' : module.arguments
20 |   });
21 |   var result = ffmpeg_run(module);
22 |   postMessage({
23 |     'type' : 'done',
24 |     'data' : result
25 |   });
26 | };
27 | 
28 | postMessage({
29 |   'type' : 'ready'
30 | });
31 | 
32 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-2.txt: -------------------------------------------------------------------------------- 1 | importScripts('ffmpeg.js'); 2 | 3 | function print(text) { 4 | postMessage({ 5 | 'type' : 'stdout', 6 | 'data' : text 7 | }); 8 | } 9 | 10 | onmessage = function(event) { 11 | var module = { 12 | files: event.data.files || [], 13 | arguments: event.data.arguments || [], 14 | print: print, 15 | printErr: print 16 | }; 17 | postMessage({ 18 | 'type' : 'start', 19 | 'data' : module.arguments 20 | }); 21 | var result = ffmpeg_run(module); 22 | postMessage({ 23 | 'type' : 'done', 24 | 'data' : result 25 | }); 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'ready' 30 | }); 31 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-3.html: -------------------------------------------------------------------------------- 1 |
var worker = new Worker("worker.js");
 2 | worker.onmessage = function (event) {
 3 |   var message = event.data;
 4 |   if (message.type == "ready") {
 5 |     outputElement.textContent = "Loaded";
 6 |     worker.postMessage({
 7 |       type: 'command',
 8 |       arguments: ['-help']
 9 |     })
10 |   } else if (message.type == "stdout") {
11 |     outputElement.textContent += message.data + "\n";
12 |   } else if (message.type == "start") {
13 |     outputElement.textContent = "Worker has received command\n";
14 |   }
15 | };
16 | 
17 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-3.txt: -------------------------------------------------------------------------------- 1 | var worker = new Worker("worker.js"); 2 | worker.onmessage = function (event) { 3 | var message = event.data; 4 | if (message.type == "ready") { 5 | outputElement.textContent = "Loaded"; 6 | worker.postMessage({ 7 | type: 'command', 8 | arguments: ['-help'] 9 | }) 10 | } else if (message.type == "stdout") { 11 | outputElement.textContent += message.data + "\n"; 12 | } else if (message.type == "start") { 13 | outputElement.textContent = "Worker has received command\n"; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-4.html: -------------------------------------------------------------------------------- 1 |
var sampleVideoData;
 2 | function retrieveSampleVideo() {
 3 |   var oReq = new XMLHttpRequest();
 4 |   oReq.open("GET", "bigbuckbunny.webm", true);
 5 |   oReq.responseType = "arraybuffer";
 6 | 
 7 |   oReq.onload = function (oEvent) {
 8 |     var arrayBuffer = oReq.response;
 9 |     if (arrayBuffer) {
10 |       sampleVideoData = new Uint8Array(arrayBuffer);
11 |     }
12 |   };
13 | 
14 |   oReq.send(null);
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-4.txt: -------------------------------------------------------------------------------- 1 | var sampleVideoData; 2 | function retrieveSampleVideo() { 3 | var oReq = new XMLHttpRequest(); 4 | oReq.open("GET", "bigbuckbunny.webm", true); 5 | oReq.responseType = "arraybuffer"; 6 | 7 | oReq.onload = function (oEvent) { 8 | var arrayBuffer = oReq.response; 9 | if (arrayBuffer) { 10 | sampleVideoData = new Uint8Array(arrayBuffer); 11 | } 12 | }; 13 | 14 | oReq.send(null); 15 | } 16 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-5.html: -------------------------------------------------------------------------------- 1 |
function getDownloadLink(fileData, fileName) {
 2 |   var a = document.createElement('a');
 3 |   a.download = fileName;
 4 |   var blob = new Blob([fileData]);
 5 |   var src = window.URL.createObjectURL(blob);
 6 |   a.href = src;
 7 |   a.textContent = 'Click here to download ' + fileName + "!";
 8 |   return a;
 9 | }
10 | 
11 | var result = ffmpeg_run(module);
12 | result.forEach(function(file) {
13 |   getDownloadLink(file.data, file.name);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/code-blocks/example-5.txt: -------------------------------------------------------------------------------- 1 | function getDownloadLink(fileData, fileName) { 2 | var a = document.createElement('a'); 3 | a.download = fileName; 4 | var blob = new Blob([fileData]); 5 | var src = window.URL.createObjectURL(blob); 6 | a.href = src; 7 | a.textContent = 'Click here to download ' + fileName + "!"; 8 | return a; 9 | } 10 | 11 | var result = ffmpeg_run(module); 12 | result.forEach(function(file) { 13 | getDownloadLink(file.data, file.name); 14 | }); 15 | -------------------------------------------------------------------------------- /build_agpl/wasm/site/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/site/favicon.ico -------------------------------------------------------------------------------- /build_agpl/wasm/site/light_toast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/site/light_toast.png -------------------------------------------------------------------------------- /build_agpl/wasm/site/load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/site/load.gif -------------------------------------------------------------------------------- /build_agpl/wasm/site/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/site/logo.png -------------------------------------------------------------------------------- /build_agpl/wasm/site/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | 5 | html, body { 6 | padding: 0; 7 | margin: 0; 8 | } 9 | 10 | body { 11 | position: relative; 12 | } 13 | 14 | body { 15 | min-height: 100%; 16 | background: #eee url(light_toast.png); 17 | font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif; 18 | line-height: 1.5; 19 | font-weight: 300; 20 | color: #4D4D4D; 21 | min-width: 630px; 22 | } 23 | 24 | center { 25 | margin: 10px 0; 26 | } 27 | 28 | strong { 29 | font-weight: bold; 30 | } 31 | 32 | .container-fluid { 33 | width: 90%; 34 | margin: 0 auto; 35 | height: 100%; 36 | min-height: 100%; 37 | font-size: 14px; 38 | background: rgba(255, 255, 255, .8); 39 | padding: 0 10px; 40 | } 41 | 42 | .content { 43 | padding-bottom: 20px; 44 | } 45 | 46 | p, li { 47 | font-size: 16px; 48 | } 49 | 50 | .header { 51 | margin: 0 -5.6%; 52 | padding: 5px 5.6%; 53 | box-shadow: 0 0 3px #74ad5a; 54 | margin-bottom: 4px; 55 | background-image: -webkit-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 56 | background-image: -moz-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 57 | background-image: -o-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 58 | background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 59 | -webkit-background-size: 4px 4px; 60 | -moz-background-size: 4px 4px; 61 | background-size: 4px 4px; 62 | } 63 | 64 | h2 { 65 | font-family: Georgia; 66 | text-transform: uppercase; 67 | margin: 5px 0; 68 | font-size: 24px; 69 | font-weight: lighter; 70 | } 71 | 72 | h2 a { 73 | opacity: 0; 74 | text-decoration: none; 75 | font-style: normal; 76 | color: #333; 77 | vertical-align: text-top; 78 | font-size: 80%; 79 | text-transform: none; 80 | transition: opacity linear .1s; 81 | } 82 | 83 | h2:hover a { 84 | opacity: 1; 85 | } 86 | 87 | h2 a:hover { 88 | color: #74ad5a; 89 | } 90 | 91 | h3 { 92 | font-size: 18px; 93 | text-decoration: underline; 94 | font-family: Georgia; 95 | font-weight: normal; 96 | } 97 | 98 | h1 { 99 | margin: 0; 100 | padding: 0; 101 | font-size: 32px; 102 | line-height: 32px; 103 | font-weight: 300; 104 | } 105 | 106 | h1 a, h1 a:visited { 107 | color: #333; 108 | text-decoration: none; 109 | } 110 | 111 | h1 a:hover { 112 | text-decoration: underline; 113 | } 114 | 115 | h1 span { 116 | vertical-align: top; 117 | margin-left: 5px; 118 | } 119 | 120 | .warning { 121 | background-color: #FEE8E8; 122 | border: 1px solid #DDD; 123 | font-size: 13px; 124 | line-height: 19px; 125 | overflow: auto; 126 | padding: 6px 10px; 127 | border-radius: 3px; 128 | } 129 | .note { 130 | background-color: #E8FEE8; 131 | border: 1px solid #DDD; 132 | font-size: 13px; 133 | line-height: 19px; 134 | overflow: auto; 135 | padding: 6px 10px; 136 | border-radius: 3px; 137 | } 138 | 139 | code, pre { 140 | font-family: Consolas,"Liberation Mono",Courier,monospace; 141 | } 142 | 143 | pre { 144 | font-size: 12px; 145 | background-color: #F8F8F8; 146 | border: 1px solid #BDB; 147 | font-size: 13px; 148 | line-height: 19px; 149 | overflow: auto; 150 | padding: 6px 10px; 151 | border-radius: 3px; 152 | color: #232; 153 | } 154 | 155 | code { 156 | color: #696; 157 | font-family: inherit; 158 | } 159 | 160 | .tagline { 161 | font-size: 24px; 162 | } 163 | 164 | a.big { 165 | -moz-box-shadow: inset 0px 1px 0px 0px #9acc85; 166 | -webkit-box-shadow: inset 0px 1px 0px 0px #9acc85; 167 | box-shadow: inset 0px 1px 0px 0px #9acc85; 168 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #74ad5a), color-stop(1, #68a54b)); 169 | background: -moz-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 170 | background: -webkit-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 171 | background: -o-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 172 | background: -ms-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 173 | background: linear-gradient(to bottom, #74ad5a 5%, #68a54b 100%); 174 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#74ad5a', endColorstr='#68a54b',GradientType=0); 175 | background-color: #74ad5a; 176 | border: 1px solid #3b6e22; 177 | display: inline-block; 178 | color: #ffffff; 179 | font-size: 20px; 180 | padding: 8px 12px; 181 | text-decoration: none; 182 | } 183 | 184 | a.big:hover { 185 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #68a54b), color-stop(1, #74ad5a)); 186 | background: -moz-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 187 | background: -webkit-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 188 | background: -o-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 189 | background: -ms-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 190 | background: linear-gradient(to bottom, #68a54b 5%, #74ad5a 100%); 191 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#68a54b', endColorstr='#74ad5a',GradientType=0); 192 | background-color: #68a54b; 193 | } 194 | 195 | a.big:active { 196 | position: relative; 197 | top: 1px; 198 | } 199 | 200 | .plain-button { 201 | cursor: pointer; 202 | -moz-box-shadow: inset 0px 1px 0px 0px #ffffff; 203 | -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff; 204 | box-shadow: inset 0px 1px 0px 0px #ffffff; 205 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #f6f6f6)); 206 | background: -moz-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 207 | background: -webkit-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 208 | background: -o-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 209 | background: -ms-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 210 | background: linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%); 211 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f6f6f6',GradientType=0); 212 | background-color: #ffffff; 213 | -moz-border-radius: 6px; 214 | -webkit-border-radius: 6px; 215 | border-radius: 6px; 216 | border: 1px solid #dcdcdc; 217 | display: inline-block; 218 | color: #666666; 219 | font-size: 14px; 220 | padding: 6px 8px; 221 | text-decoration: none; 222 | text-shadow: 0px 1px 0px #ffffff; 223 | } 224 | 225 | .plain-button:hover { 226 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff)); 227 | background: -moz-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 228 | background: -webkit-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 229 | background: -o-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 230 | background: -ms-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 231 | background: linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); 232 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6f6f6', endColorstr='#ffffff',GradientType=0); 233 | background-color: #f6f6f6; 234 | } 235 | 236 | .plain-button:active { 237 | position: relative; 238 | top: 1px; 239 | } 240 | 241 | .links a { 242 | background: #333; 243 | color: #fff; 244 | padding: 10px; 245 | padding-bottom: 8px; 246 | text-decoration: none; 247 | transition: top ease-in-out .05s; 248 | position: relative; 249 | top: -2px; 250 | } 251 | 252 | .links a:hover { 253 | /*padding-bottom: 10px;*/ 254 | top: 0; 255 | } 256 | 257 | .links a:visited { 258 | color: #ddd; 259 | } 260 | 261 | .pull-left { 262 | float: left; 263 | } 264 | 265 | .pull-right { 266 | float: right; 267 | } 268 | 269 | .clearfix { 270 | *zoom: 1; 271 | } 272 | 273 | .clearfix:before, 274 | .clearfix:after { 275 | display: table; 276 | line-height: 0; 277 | content: ""; 278 | } 279 | 280 | .clearfix:after { 281 | clear: both; 282 | } -------------------------------------------------------------------------------- /build_agpl/wasm/site/site.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_agpl/wasm/site/site.js -------------------------------------------------------------------------------- /build_agpl/wasm/terminal.js: -------------------------------------------------------------------------------- 1 | 2 | var worker; 3 | var sampleImageData; 4 | var sampleVideoData; 5 | var outputElement; 6 | var filesElement; 7 | var running = false; 8 | var isWorkerLoaded = false; 9 | var isSupported = (function() { 10 | return document.querySelector && window.URL && window.Worker; 11 | })(); 12 | 13 | function isReady() { 14 | return !running && isWorkerLoaded && sampleImageData && sampleVideoData; 15 | } 16 | 17 | function startRunning() { 18 | document.querySelector("#image-loader").style.visibility = "visible"; 19 | outputElement.className = ""; 20 | filesElement.innerHTML = ""; 21 | running = true; 22 | } 23 | function stopRunning() { 24 | document.querySelector("#image-loader").style.visibility = "hidden"; 25 | running = false; 26 | } 27 | 28 | function retrieveSampleImage() { 29 | var oReq = new XMLHttpRequest(); 30 | oReq.open("GET", "bigbuckbunny.jpg", true); 31 | oReq.responseType = "arraybuffer"; 32 | 33 | oReq.onload = function (oEvent) { 34 | var arrayBuffer = oReq.response; 35 | if (arrayBuffer) { 36 | sampleImageData = new Uint8Array(arrayBuffer); 37 | } 38 | }; 39 | 40 | oReq.send(null); 41 | } 42 | 43 | function retrieveSampleVideo() { 44 | var oReq = new XMLHttpRequest(); 45 | oReq.open("GET", "bigbuckbunny.webm", true); 46 | oReq.responseType = "arraybuffer"; 47 | 48 | oReq.onload = function (oEvent) { 49 | var arrayBuffer = oReq.response; 50 | if (arrayBuffer) { 51 | sampleVideoData = new Uint8Array(arrayBuffer); 52 | } 53 | }; 54 | 55 | oReq.send(null); 56 | } 57 | 58 | function parseArguments(text) { 59 | text = text.replace(/\s+/g, ' '); 60 | var args = []; 61 | // Allow double quotes to not split args. 62 | text.split('"').forEach(function(t, i) { 63 | t = t.trim(); 64 | if ((i % 2) === 1) { 65 | args.push(t); 66 | } else { 67 | args = args.concat(t.split(" ")); 68 | } 69 | }); 70 | return args; 71 | } 72 | 73 | 74 | function runCommand(text) { 75 | if (isReady()) { 76 | startRunning(); 77 | var args = parseArguments(text); 78 | console.log(args); 79 | if (typeof(args[0]) == "string" && args[0] == "benchmark") { 80 | args.shift(); 81 | worker.postMessage({ 82 | type: "benchmark", 83 | arguments: args, 84 | files: [ 85 | { 86 | "name": "input.jpeg", 87 | "data": sampleImageData 88 | }, 89 | { 90 | "name": "input.webm", 91 | "data": sampleVideoData 92 | } 93 | ] 94 | }); 95 | } else { 96 | worker.postMessage({ 97 | type: "command", 98 | arguments: args, 99 | files: [ 100 | { 101 | "name": "input.jpeg", 102 | "data": sampleImageData 103 | }, 104 | { 105 | "name": "input.webm", 106 | "data": sampleVideoData 107 | } 108 | ] 109 | }); 110 | } 111 | } 112 | } 113 | 114 | function getDownloadLink(fileData, fileName) { 115 | if (fileName.match(/\.jpeg|\.gif|\.jpg|\.png/)) { 116 | var blob = new Blob([fileData]); 117 | var src = window.URL.createObjectURL(blob); 118 | var img = document.createElement('img'); 119 | 120 | img.src = src; 121 | return img; 122 | } 123 | else { 124 | var a = document.createElement('a'); 125 | a.download = fileName; 126 | var blob = new Blob([fileData]); 127 | var src = window.URL.createObjectURL(blob); 128 | a.href = src; 129 | a.textContent = 'Click here to download ' + fileName + "!"; 130 | return a; 131 | } 132 | } 133 | 134 | function initWorker() { 135 | worker = new Worker("worker-asm.js"); 136 | worker.onmessage = function (event) { 137 | var message = event.data; 138 | if (message.type == "ready") { 139 | isWorkerLoaded = true; 140 | worker.postMessage({ 141 | type: "command", 142 | arguments: ["-help"] 143 | }); 144 | } else if (message.type == "stdout") { 145 | outputElement.textContent += message.data + "\n"; 146 | } else if (message.type == "start") { 147 | outputElement.textContent = "Worker has received command\n"; 148 | } else if (message.type == "done") { 149 | stopRunning(); 150 | var buffers = message.data; 151 | if (buffers.length) { 152 | outputElement.className = "closed"; 153 | } 154 | buffers.forEach(function(file) { 155 | filesElement.appendChild(getDownloadLink(file.data, file.name)); 156 | }); 157 | } 158 | }; 159 | } 160 | 161 | document.addEventListener("DOMContentLoaded", function() { 162 | 163 | initWorker(); 164 | retrieveSampleVideo(); 165 | retrieveSampleImage(); 166 | 167 | var inputElement = document.querySelector("#input"); 168 | outputElement = document.querySelector("#output"); 169 | filesElement = document.querySelector("#files"); 170 | 171 | inputElement.addEventListener("keydown", function(e) { 172 | if (e.keyCode === 13) { 173 | runCommand(inputElement.value); 174 | } 175 | }, false); 176 | document.querySelector("#run").addEventListener("click", function() { 177 | runCommand(inputElement.value); 178 | }); 179 | 180 | [].forEach.call(document.querySelectorAll(".sample"), function(link) { 181 | link.addEventListener("click", function(e) { 182 | inputElement.value = this.getAttribute("data-command"); 183 | runCommand(inputElement.value); 184 | e.preventDefault(); 185 | }); 186 | }); 187 | 188 | }); 189 | -------------------------------------------------------------------------------- /build_agpl/wasm/worker-asm.js: -------------------------------------------------------------------------------- 1 | importScripts('./ffmpeg.js'); 2 | importScripts('./lodash.js'); 3 | importScripts('./benchmark.js'); 4 | 5 | var now = Date.now; 6 | 7 | function print(text) { 8 | postMessage({ 9 | 'type' : 'stdout', 10 | 'data' : text 11 | }); 12 | } 13 | 14 | onmessage = function(event) { 15 | 16 | var message = event.data; 17 | 18 | if (message.type === "command") { 19 | 20 | var Module = { 21 | print: print, 22 | printErr: print, 23 | files: message.files || [], 24 | arguments: message.arguments || [], 25 | TOTAL_MEMORY: 268435456 26 | // Can play around with this option - must be a power of 2 27 | // TOTAL_MEMORY: 268435456 28 | }; 29 | 30 | postMessage({ 31 | 'type' : 'start', 32 | 'data' : Module.arguments.join(" ") 33 | }); 34 | 35 | postMessage({ 36 | 'type' : 'stdout', 37 | 'data' : 'Received command: ' + 38 | Module.arguments.join(" ") + 39 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 40 | }); 41 | 42 | var time = now(); 43 | 44 | Module['returnCallback'] = function(result) { 45 | var totalTime = now() - time; 46 | 47 | postMessage({ 48 | 'type' : 'stdout', 49 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 50 | }); 51 | 52 | postMessage({ 53 | 'type' : 'done', 54 | 'data' : result, 55 | 'time' : totalTime 56 | }); 57 | } 58 | 59 | var result = ffmpeg_run(Module); 60 | 61 | } 62 | 63 | if (message.type === "benchmark") { 64 | 65 | var Module = {}; 66 | 67 | postMessage({ 68 | 'type' : 'start', 69 | 'data' : message.arguments.join(" ") 70 | }); 71 | print("Starting benchmark") 72 | 73 | var suite = new Benchmark.Suite 74 | suite.add('ffmpeg', { 75 | 'defer': true, 76 | 'setup': function() { 77 | Module = { 78 | print: function(data){}, 79 | printErr: function(data){}, 80 | files: message.files || [], 81 | arguments: message.arguments.slice() || [], 82 | TOTAL_MEMORY: 268435456 83 | // Can play around with this option - must be a power of 2 84 | // TOTAL_MEMORY: 268435456 85 | }; 86 | print("."); 87 | }, 88 | 'fn': function(deferred) { 89 | Module['returnCallback'] = function(result) { 90 | deferred.resolve(); 91 | } 92 | ffmpeg_run(Module); 93 | } 94 | }).on('complete', function() { 95 | var results = this.filter('fastest')[0]; 96 | print("Samples:" + results.stats.sample.length) 97 | print("Mean:" + results.stats.mean) 98 | print("Variance:" + results.stats.variance) 99 | print("Stddev:" + Math.sqrt(results.stats.variance)) 100 | postMessage({ 101 | 'type' : 'done', 102 | 'data' : [], 103 | 'time' : 0 104 | }); 105 | }).run({'async': true}); 106 | } 107 | }; 108 | 109 | postMessage({ 110 | 'type' : 'ready' 111 | }); 112 | -------------------------------------------------------------------------------- /build_agpl/wasm/worker.js: -------------------------------------------------------------------------------- 1 | importScripts('ffmpeg.js'); 2 | 3 | var now = Date.now; 4 | 5 | function print(text) { 6 | postMessage({ 7 | 'type' : 'stdout', 8 | 'data' : text 9 | }); 10 | } 11 | 12 | onmessage = function(event) { 13 | 14 | var message = event.data; 15 | 16 | if (message.type === "command") { 17 | 18 | var Module = { 19 | print: print, 20 | printErr: print, 21 | files: message.files || [], 22 | arguments: message.arguments || [], 23 | TOTAL_MEMORY: message.TOTAL_MEMORY || false 24 | // Can play around with this option - must be a power of 2 25 | // TOTAL_MEMORY: 268435456 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'start', 30 | 'data' : Module.arguments.join(" ") 31 | }); 32 | 33 | postMessage({ 34 | 'type' : 'stdout', 35 | 'data' : 'Received command: ' + 36 | Module.arguments.join(" ") + 37 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 38 | }); 39 | 40 | var time = now(); 41 | var result = ffmpeg_run(Module); 42 | console.log(result); 43 | console.log("post result") 44 | 45 | var totalTime = now() - time; 46 | postMessage({ 47 | 'type' : 'stdout', 48 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 49 | }); 50 | 51 | postMessage({ 52 | 'type' : 'done', 53 | 'data' : result, 54 | 'time' : totalTime 55 | }); 56 | } 57 | }; 58 | 59 | postMessage({ 60 | 'type' : 'ready' 61 | }); 62 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/bigbuckbunny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/bigbuckbunny.jpg -------------------------------------------------------------------------------- /build_all_codecs/asm.js/bigbuckbunny.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/bigbuckbunny.webm -------------------------------------------------------------------------------- /build_all_codecs/asm.js/ffmpeg-all-codecs.js.mem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/ffmpeg-all-codecs.js.mem -------------------------------------------------------------------------------- /build_all_codecs/asm.js/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | videoconverter.js - Convert Videos In Your Web Browser 6 | 7 | 8 | 9 | 10 | 62 | 63 | 64 | 65 |
66 |
67 |
68 |
69 | 73 | 78 |
79 | 80 |
81 |

Terminal Demo

82 |

83 | Imagine that you have installed FFmpeg on your computer. Also imagine that you have files called input.webm and input.jpeg in the current directory. Feel free to run whatever commands you want, or try the sample commands below: 84 |

85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
115 |
116 | videoconverter.js 117 |
118 |
119 | 120 | 121 | 122 |
123 |
Loading JavaScript files (it may take a minute)
124 |
125 |
126 | 127 |
128 |
129 |
130 |
131 | 132 |
133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-1.html: -------------------------------------------------------------------------------- 1 |
var results = ffmpeg_run({
 2 |   arguments: [string],
 3 |   files: [
 4 |     {
 5 |       data: UInt8Array,
 6 |       name: string
 7 |     }
 8 |   ]
 9 | });
10 | 
11 | // results is an Array of { data: UInt8Array, name: string }
12 | results.forEach(function(file) {
13 |   console.log("File recieved", file.name, file.data);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-1.txt: -------------------------------------------------------------------------------- 1 | var results = ffmpeg_run({ 2 | arguments: [string], 3 | files: [ 4 | { 5 | data: UInt8Array, 6 | name: string 7 | } 8 | ] 9 | }); 10 | 11 | // results is an Array of { data: UInt8Array, name: string } 12 | results.forEach(function(file) { 13 | console.log("File recieved", file.name, file.data); 14 | }); 15 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-2.html: -------------------------------------------------------------------------------- 1 |
importScripts('ffmpeg.js');
 2 | 
 3 | function print(text) {
 4 |   postMessage({
 5 |     'type' : 'stdout',
 6 |     'data' : text
 7 |   });
 8 | }
 9 | 
10 | onmessage = function(event) {
11 |   var module = {
12 |     files: event.data.files || [],
13 |     arguments: event.data.arguments || [],
14 |     print: print,
15 |     printErr: print
16 |   };
17 |   postMessage({
18 |     'type' : 'start',
19 |     'data' : module.arguments
20 |   });
21 |   var result = ffmpeg_run(module);
22 |   postMessage({
23 |     'type' : 'done',
24 |     'data' : result
25 |   });
26 | };
27 | 
28 | postMessage({
29 |   'type' : 'ready'
30 | });
31 | 
32 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-2.txt: -------------------------------------------------------------------------------- 1 | importScripts('ffmpeg.js'); 2 | 3 | function print(text) { 4 | postMessage({ 5 | 'type' : 'stdout', 6 | 'data' : text 7 | }); 8 | } 9 | 10 | onmessage = function(event) { 11 | var module = { 12 | files: event.data.files || [], 13 | arguments: event.data.arguments || [], 14 | print: print, 15 | printErr: print 16 | }; 17 | postMessage({ 18 | 'type' : 'start', 19 | 'data' : module.arguments 20 | }); 21 | var result = ffmpeg_run(module); 22 | postMessage({ 23 | 'type' : 'done', 24 | 'data' : result 25 | }); 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'ready' 30 | }); 31 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-3.html: -------------------------------------------------------------------------------- 1 |
var worker = new Worker("worker.js");
 2 | worker.onmessage = function (event) {
 3 |   var message = event.data;
 4 |   if (message.type == "ready") {
 5 |     outputElement.textContent = "Loaded";
 6 |     worker.postMessage({
 7 |       type: 'command',
 8 |       arguments: ['-help']
 9 |     })
10 |   } else if (message.type == "stdout") {
11 |     outputElement.textContent += message.data + "\n";
12 |   } else if (message.type == "start") {
13 |     outputElement.textContent = "Worker has received command\n";
14 |   }
15 | };
16 | 
17 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-3.txt: -------------------------------------------------------------------------------- 1 | var worker = new Worker("worker.js"); 2 | worker.onmessage = function (event) { 3 | var message = event.data; 4 | if (message.type == "ready") { 5 | outputElement.textContent = "Loaded"; 6 | worker.postMessage({ 7 | type: 'command', 8 | arguments: ['-help'] 9 | }) 10 | } else if (message.type == "stdout") { 11 | outputElement.textContent += message.data + "\n"; 12 | } else if (message.type == "start") { 13 | outputElement.textContent = "Worker has received command\n"; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-4.html: -------------------------------------------------------------------------------- 1 |
var sampleVideoData;
 2 | function retrieveSampleVideo() {
 3 |   var oReq = new XMLHttpRequest();
 4 |   oReq.open("GET", "bigbuckbunny.webm", true);
 5 |   oReq.responseType = "arraybuffer";
 6 | 
 7 |   oReq.onload = function (oEvent) {
 8 |     var arrayBuffer = oReq.response;
 9 |     if (arrayBuffer) {
10 |       sampleVideoData = new Uint8Array(arrayBuffer);
11 |     }
12 |   };
13 | 
14 |   oReq.send(null);
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-4.txt: -------------------------------------------------------------------------------- 1 | var sampleVideoData; 2 | function retrieveSampleVideo() { 3 | var oReq = new XMLHttpRequest(); 4 | oReq.open("GET", "bigbuckbunny.webm", true); 5 | oReq.responseType = "arraybuffer"; 6 | 7 | oReq.onload = function (oEvent) { 8 | var arrayBuffer = oReq.response; 9 | if (arrayBuffer) { 10 | sampleVideoData = new Uint8Array(arrayBuffer); 11 | } 12 | }; 13 | 14 | oReq.send(null); 15 | } 16 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-5.html: -------------------------------------------------------------------------------- 1 |
function getDownloadLink(fileData, fileName) {
 2 |   var a = document.createElement('a');
 3 |   a.download = fileName;
 4 |   var blob = new Blob([fileData]);
 5 |   var src = window.URL.createObjectURL(blob);
 6 |   a.href = src;
 7 |   a.textContent = 'Click here to download ' + fileName + "!";
 8 |   return a;
 9 | }
10 | 
11 | var result = ffmpeg_run(module);
12 | result.forEach(function(file) {
13 |   getDownloadLink(file.data, file.name);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/code-blocks/example-5.txt: -------------------------------------------------------------------------------- 1 | function getDownloadLink(fileData, fileName) { 2 | var a = document.createElement('a'); 3 | a.download = fileName; 4 | var blob = new Blob([fileData]); 5 | var src = window.URL.createObjectURL(blob); 6 | a.href = src; 7 | a.textContent = 'Click here to download ' + fileName + "!"; 8 | return a; 9 | } 10 | 11 | var result = ffmpeg_run(module); 12 | result.forEach(function(file) { 13 | getDownloadLink(file.data, file.name); 14 | }); 15 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/site/favicon.ico -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/light_toast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/site/light_toast.png -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/site/load.gif -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/site/logo.png -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | 5 | html, body { 6 | padding: 0; 7 | margin: 0; 8 | } 9 | 10 | body { 11 | position: relative; 12 | } 13 | 14 | body { 15 | min-height: 100%; 16 | background: #eee url(light_toast.png); 17 | font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif; 18 | line-height: 1.5; 19 | font-weight: 300; 20 | color: #4D4D4D; 21 | min-width: 630px; 22 | } 23 | 24 | center { 25 | margin: 10px 0; 26 | } 27 | 28 | strong { 29 | font-weight: bold; 30 | } 31 | 32 | .container-fluid { 33 | width: 90%; 34 | margin: 0 auto; 35 | height: 100%; 36 | min-height: 100%; 37 | font-size: 14px; 38 | background: rgba(255, 255, 255, .8); 39 | padding: 0 10px; 40 | } 41 | 42 | .content { 43 | padding-bottom: 20px; 44 | } 45 | 46 | p, li { 47 | font-size: 16px; 48 | } 49 | 50 | .header { 51 | margin: 0 -5.6%; 52 | padding: 5px 5.6%; 53 | box-shadow: 0 0 3px #74ad5a; 54 | margin-bottom: 4px; 55 | background-image: -webkit-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 56 | background-image: -moz-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 57 | background-image: -o-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 58 | background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 59 | -webkit-background-size: 4px 4px; 60 | -moz-background-size: 4px 4px; 61 | background-size: 4px 4px; 62 | } 63 | 64 | h2 { 65 | font-family: Georgia; 66 | text-transform: uppercase; 67 | margin: 5px 0; 68 | font-size: 24px; 69 | font-weight: lighter; 70 | } 71 | 72 | h2 a { 73 | opacity: 0; 74 | text-decoration: none; 75 | font-style: normal; 76 | color: #333; 77 | vertical-align: text-top; 78 | font-size: 80%; 79 | text-transform: none; 80 | transition: opacity linear .1s; 81 | } 82 | 83 | h2:hover a { 84 | opacity: 1; 85 | } 86 | 87 | h2 a:hover { 88 | color: #74ad5a; 89 | } 90 | 91 | h3 { 92 | font-size: 18px; 93 | text-decoration: underline; 94 | font-family: Georgia; 95 | font-weight: normal; 96 | } 97 | 98 | h1 { 99 | margin: 0; 100 | padding: 0; 101 | font-size: 32px; 102 | line-height: 32px; 103 | font-weight: 300; 104 | } 105 | 106 | h1 a, h1 a:visited { 107 | color: #333; 108 | text-decoration: none; 109 | } 110 | 111 | h1 a:hover { 112 | text-decoration: underline; 113 | } 114 | 115 | h1 span { 116 | vertical-align: top; 117 | margin-left: 5px; 118 | } 119 | 120 | .warning { 121 | background-color: #FEE8E8; 122 | border: 1px solid #DDD; 123 | font-size: 13px; 124 | line-height: 19px; 125 | overflow: auto; 126 | padding: 6px 10px; 127 | border-radius: 3px; 128 | } 129 | .note { 130 | background-color: #E8FEE8; 131 | border: 1px solid #DDD; 132 | font-size: 13px; 133 | line-height: 19px; 134 | overflow: auto; 135 | padding: 6px 10px; 136 | border-radius: 3px; 137 | } 138 | 139 | code, pre { 140 | font-family: Consolas,"Liberation Mono",Courier,monospace; 141 | } 142 | 143 | pre { 144 | font-size: 12px; 145 | background-color: #F8F8F8; 146 | border: 1px solid #BDB; 147 | font-size: 13px; 148 | line-height: 19px; 149 | overflow: auto; 150 | padding: 6px 10px; 151 | border-radius: 3px; 152 | color: #232; 153 | } 154 | 155 | code { 156 | color: #696; 157 | font-family: inherit; 158 | } 159 | 160 | .tagline { 161 | font-size: 24px; 162 | } 163 | 164 | a.big { 165 | -moz-box-shadow: inset 0px 1px 0px 0px #9acc85; 166 | -webkit-box-shadow: inset 0px 1px 0px 0px #9acc85; 167 | box-shadow: inset 0px 1px 0px 0px #9acc85; 168 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #74ad5a), color-stop(1, #68a54b)); 169 | background: -moz-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 170 | background: -webkit-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 171 | background: -o-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 172 | background: -ms-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 173 | background: linear-gradient(to bottom, #74ad5a 5%, #68a54b 100%); 174 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#74ad5a', endColorstr='#68a54b',GradientType=0); 175 | background-color: #74ad5a; 176 | border: 1px solid #3b6e22; 177 | display: inline-block; 178 | color: #ffffff; 179 | font-size: 20px; 180 | padding: 8px 12px; 181 | text-decoration: none; 182 | } 183 | 184 | a.big:hover { 185 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #68a54b), color-stop(1, #74ad5a)); 186 | background: -moz-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 187 | background: -webkit-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 188 | background: -o-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 189 | background: -ms-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 190 | background: linear-gradient(to bottom, #68a54b 5%, #74ad5a 100%); 191 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#68a54b', endColorstr='#74ad5a',GradientType=0); 192 | background-color: #68a54b; 193 | } 194 | 195 | a.big:active { 196 | position: relative; 197 | top: 1px; 198 | } 199 | 200 | .plain-button { 201 | cursor: pointer; 202 | -moz-box-shadow: inset 0px 1px 0px 0px #ffffff; 203 | -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff; 204 | box-shadow: inset 0px 1px 0px 0px #ffffff; 205 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #f6f6f6)); 206 | background: -moz-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 207 | background: -webkit-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 208 | background: -o-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 209 | background: -ms-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 210 | background: linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%); 211 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f6f6f6',GradientType=0); 212 | background-color: #ffffff; 213 | -moz-border-radius: 6px; 214 | -webkit-border-radius: 6px; 215 | border-radius: 6px; 216 | border: 1px solid #dcdcdc; 217 | display: inline-block; 218 | color: #666666; 219 | font-size: 14px; 220 | padding: 6px 8px; 221 | text-decoration: none; 222 | text-shadow: 0px 1px 0px #ffffff; 223 | } 224 | 225 | .plain-button:hover { 226 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff)); 227 | background: -moz-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 228 | background: -webkit-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 229 | background: -o-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 230 | background: -ms-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 231 | background: linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); 232 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6f6f6', endColorstr='#ffffff',GradientType=0); 233 | background-color: #f6f6f6; 234 | } 235 | 236 | .plain-button:active { 237 | position: relative; 238 | top: 1px; 239 | } 240 | 241 | .links a { 242 | background: #333; 243 | color: #fff; 244 | padding: 10px; 245 | padding-bottom: 8px; 246 | text-decoration: none; 247 | transition: top ease-in-out .05s; 248 | position: relative; 249 | top: -2px; 250 | } 251 | 252 | .links a:hover { 253 | /*padding-bottom: 10px;*/ 254 | top: 0; 255 | } 256 | 257 | .links a:visited { 258 | color: #ddd; 259 | } 260 | 261 | .pull-left { 262 | float: left; 263 | } 264 | 265 | .pull-right { 266 | float: right; 267 | } 268 | 269 | .clearfix { 270 | *zoom: 1; 271 | } 272 | 273 | .clearfix:before, 274 | .clearfix:after { 275 | display: table; 276 | line-height: 0; 277 | content: ""; 278 | } 279 | 280 | .clearfix:after { 281 | clear: both; 282 | } -------------------------------------------------------------------------------- /build_all_codecs/asm.js/site/site.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/asm.js/site/site.js -------------------------------------------------------------------------------- /build_all_codecs/asm.js/terminal.js: -------------------------------------------------------------------------------- 1 | 2 | var worker; 3 | var sampleImageData; 4 | var sampleVideoData; 5 | var outputElement; 6 | var filesElement; 7 | var running = false; 8 | var isWorkerLoaded = false; 9 | var isSupported = (function() { 10 | return document.querySelector && window.URL && window.Worker; 11 | })(); 12 | 13 | function isReady() { 14 | return !running && isWorkerLoaded && sampleImageData && sampleVideoData; 15 | } 16 | 17 | function startRunning() { 18 | document.querySelector("#image-loader").style.visibility = "visible"; 19 | outputElement.className = ""; 20 | filesElement.innerHTML = ""; 21 | running = true; 22 | } 23 | function stopRunning() { 24 | document.querySelector("#image-loader").style.visibility = "hidden"; 25 | running = false; 26 | } 27 | 28 | function retrieveSampleImage() { 29 | var oReq = new XMLHttpRequest(); 30 | oReq.open("GET", "bigbuckbunny.jpg", true); 31 | oReq.responseType = "arraybuffer"; 32 | 33 | oReq.onload = function (oEvent) { 34 | var arrayBuffer = oReq.response; 35 | if (arrayBuffer) { 36 | sampleImageData = new Uint8Array(arrayBuffer); 37 | } 38 | }; 39 | 40 | oReq.send(null); 41 | } 42 | 43 | function retrieveSampleVideo() { 44 | var oReq = new XMLHttpRequest(); 45 | oReq.open("GET", "bigbuckbunny.webm", true); 46 | oReq.responseType = "arraybuffer"; 47 | 48 | oReq.onload = function (oEvent) { 49 | var arrayBuffer = oReq.response; 50 | if (arrayBuffer) { 51 | sampleVideoData = new Uint8Array(arrayBuffer); 52 | } 53 | }; 54 | 55 | oReq.send(null); 56 | } 57 | 58 | function parseArguments(text) { 59 | text = text.replace(/\s+/g, ' '); 60 | var args = []; 61 | // Allow double quotes to not split args. 62 | text.split('"').forEach(function(t, i) { 63 | t = t.trim(); 64 | if ((i % 2) === 1) { 65 | args.push(t); 66 | } else { 67 | args = args.concat(t.split(" ")); 68 | } 69 | }); 70 | return args; 71 | } 72 | 73 | 74 | function runCommand(text) { 75 | if (isReady()) { 76 | startRunning(); 77 | var args = parseArguments(text); 78 | console.log(args); 79 | if (typeof(args[0]) == "string" && args[0] == "benchmark") { 80 | args.shift(); 81 | worker.postMessage({ 82 | type: "benchmark", 83 | arguments: args, 84 | files: [ 85 | { 86 | "name": "input.jpeg", 87 | "data": sampleImageData 88 | }, 89 | { 90 | "name": "input.webm", 91 | "data": sampleVideoData 92 | } 93 | ] 94 | }); 95 | } else { 96 | worker.postMessage({ 97 | type: "command", 98 | arguments: args, 99 | files: [ 100 | { 101 | "name": "input.jpeg", 102 | "data": sampleImageData 103 | }, 104 | { 105 | "name": "input.webm", 106 | "data": sampleVideoData 107 | } 108 | ] 109 | }); 110 | } 111 | } 112 | } 113 | 114 | function getDownloadLink(fileData, fileName) { 115 | if (fileName.match(/\.jpeg|\.gif|\.jpg|\.png/)) { 116 | var blob = new Blob([fileData]); 117 | var src = window.URL.createObjectURL(blob); 118 | var img = document.createElement('img'); 119 | 120 | img.src = src; 121 | return img; 122 | } 123 | else { 124 | var a = document.createElement('a'); 125 | a.download = fileName; 126 | var blob = new Blob([fileData]); 127 | var src = window.URL.createObjectURL(blob); 128 | a.href = src; 129 | a.textContent = 'Click here to download ' + fileName + "!"; 130 | return a; 131 | } 132 | } 133 | 134 | function initWorker() { 135 | worker = new Worker("worker-asm.js"); 136 | worker.onmessage = function (event) { 137 | var message = event.data; 138 | if (message.type == "ready") { 139 | isWorkerLoaded = true; 140 | worker.postMessage({ 141 | type: "command", 142 | arguments: ["-help"] 143 | }); 144 | } else if (message.type == "stdout") { 145 | outputElement.textContent += message.data + "\n"; 146 | } else if (message.type == "start") { 147 | outputElement.textContent = "Worker has received command\n"; 148 | } else if (message.type == "done") { 149 | stopRunning(); 150 | var buffers = message.data; 151 | if (buffers.length) { 152 | outputElement.className = "closed"; 153 | } 154 | buffers.forEach(function(file) { 155 | filesElement.appendChild(getDownloadLink(file.data, file.name)); 156 | }); 157 | } 158 | }; 159 | } 160 | 161 | document.addEventListener("DOMContentLoaded", function() { 162 | 163 | initWorker(); 164 | retrieveSampleVideo(); 165 | retrieveSampleImage(); 166 | 167 | var inputElement = document.querySelector("#input"); 168 | outputElement = document.querySelector("#output"); 169 | filesElement = document.querySelector("#files"); 170 | 171 | inputElement.addEventListener("keydown", function(e) { 172 | if (e.keyCode === 13) { 173 | runCommand(inputElement.value); 174 | } 175 | }, false); 176 | document.querySelector("#run").addEventListener("click", function() { 177 | runCommand(inputElement.value); 178 | }); 179 | 180 | [].forEach.call(document.querySelectorAll(".sample"), function(link) { 181 | link.addEventListener("click", function(e) { 182 | inputElement.value = this.getAttribute("data-command"); 183 | runCommand(inputElement.value); 184 | e.preventDefault(); 185 | }); 186 | }); 187 | 188 | }); 189 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/worker-asm.js: -------------------------------------------------------------------------------- 1 | importScripts('./ffmpeg-all-codecs.js'); 2 | importScripts('./lodash.js'); 3 | importScripts('./benchmark.js'); 4 | 5 | var now = Date.now; 6 | 7 | function print(text) { 8 | postMessage({ 9 | 'type' : 'stdout', 10 | 'data' : text 11 | }); 12 | } 13 | 14 | onmessage = function(event) { 15 | 16 | var message = event.data; 17 | 18 | if (message.type === "command") { 19 | 20 | var Module = { 21 | print: print, 22 | printErr: print, 23 | files: message.files || [], 24 | arguments: message.arguments || [], 25 | TOTAL_MEMORY: 268435456 26 | // Can play around with this option - must be a power of 2 27 | // TOTAL_MEMORY: 268435456 28 | }; 29 | 30 | postMessage({ 31 | 'type' : 'start', 32 | 'data' : Module.arguments.join(" ") 33 | }); 34 | 35 | postMessage({ 36 | 'type' : 'stdout', 37 | 'data' : 'Received command: ' + 38 | Module.arguments.join(" ") + 39 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 40 | }); 41 | 42 | var time = now(); 43 | 44 | Module['returnCallback'] = function(result) { 45 | var totalTime = now() - time; 46 | 47 | postMessage({ 48 | 'type' : 'stdout', 49 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 50 | }); 51 | 52 | postMessage({ 53 | 'type' : 'done', 54 | 'data' : result, 55 | 'time' : totalTime 56 | }); 57 | } 58 | 59 | var result = ffmpeg_run(Module); 60 | 61 | } 62 | 63 | if (message.type === "benchmark") { 64 | 65 | var Module = {}; 66 | 67 | postMessage({ 68 | 'type' : 'start', 69 | 'data' : message.arguments.join(" ") 70 | }); 71 | print("Starting benchmark") 72 | 73 | var suite = new Benchmark.Suite 74 | suite.add('ffmpeg', { 75 | 'defer': true, 76 | 'setup': function() { 77 | Module = { 78 | print: function(data){}, 79 | printErr: function(data){}, 80 | files: message.files || [], 81 | arguments: message.arguments.slice() || [], 82 | TOTAL_MEMORY: 268435456 83 | // Can play around with this option - must be a power of 2 84 | // TOTAL_MEMORY: 268435456 85 | }; 86 | print("."); 87 | }, 88 | 'fn': function(deferred) { 89 | Module['returnCallback'] = function(result) { 90 | deferred.resolve(); 91 | } 92 | ffmpeg_run(Module); 93 | } 94 | }).on('complete', function() { 95 | var results = this.filter('fastest')[0]; 96 | print("Samples:" + results.stats.sample.length) 97 | print("Mean:" + results.stats.mean) 98 | print("Variance:" + results.stats.variance) 99 | print("Stddev:" + Math.sqrt(results.stats.variance)) 100 | postMessage({ 101 | 'type' : 'done', 102 | 'data' : [], 103 | 'time' : 0 104 | }); 105 | }).run({'async': true}); 106 | } 107 | }; 108 | 109 | postMessage({ 110 | 'type' : 'ready' 111 | }); 112 | -------------------------------------------------------------------------------- /build_all_codecs/asm.js/worker.js: -------------------------------------------------------------------------------- 1 | importScripts('ffmpeg-all-codecs.js'); 2 | 3 | var now = Date.now; 4 | 5 | function print(text) { 6 | postMessage({ 7 | 'type' : 'stdout', 8 | 'data' : text 9 | }); 10 | } 11 | 12 | onmessage = function(event) { 13 | 14 | var message = event.data; 15 | 16 | if (message.type === "command") { 17 | 18 | var Module = { 19 | print: print, 20 | printErr: print, 21 | files: message.files || [], 22 | arguments: message.arguments || [], 23 | TOTAL_MEMORY: message.TOTAL_MEMORY || false 24 | // Can play around with this option - must be a power of 2 25 | // TOTAL_MEMORY: 268435456 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'start', 30 | 'data' : Module.arguments.join(" ") 31 | }); 32 | 33 | postMessage({ 34 | 'type' : 'stdout', 35 | 'data' : 'Received command: ' + 36 | Module.arguments.join(" ") + 37 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 38 | }); 39 | 40 | var time = now(); 41 | var result = ffmpeg_run(Module); 42 | console.log(result); 43 | console.log("post result") 44 | 45 | var totalTime = now() - time; 46 | postMessage({ 47 | 'type' : 'stdout', 48 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 49 | }); 50 | 51 | postMessage({ 52 | 'type' : 'done', 53 | 'data' : result, 54 | 'time' : totalTime 55 | }); 56 | } 57 | }; 58 | 59 | postMessage({ 60 | 'type' : 'ready' 61 | }); 62 | -------------------------------------------------------------------------------- /build_all_codecs/index.html: -------------------------------------------------------------------------------- 1 |

BUILD_ALL_CODECS

2 |

ASM.js

3 |

WASM

4 |

back

5 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/bigbuckbunny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/bigbuckbunny.jpg -------------------------------------------------------------------------------- /build_all_codecs/wasm/bigbuckbunny.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/bigbuckbunny.webm -------------------------------------------------------------------------------- /build_all_codecs/wasm/ffmpeg-all-codecs.js.mem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/ffmpeg-all-codecs.js.mem -------------------------------------------------------------------------------- /build_all_codecs/wasm/ffmpeg-all-codecs.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/ffmpeg-all-codecs.wasm -------------------------------------------------------------------------------- /build_all_codecs/wasm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | videoconverter.js - Convert Videos In Your Web Browser 6 | 7 | 8 | 9 | 10 | 62 | 63 | 64 | 65 |
66 |
67 |
68 |
69 | 73 | 78 |
79 | 80 |
81 |

Terminal Demo

82 |

83 | Imagine that you have installed FFmpeg on your computer. Also imagine that you have files called input.webm and input.jpeg in the current directory. Feel free to run whatever commands you want, or try the sample commands below: 84 |

85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
115 |
116 | videoconverter.js 117 |
118 |
119 | 120 | 121 | 122 |
123 |
Loading JavaScript files (it may take a minute)
124 |
125 |
126 | 127 |
128 |
129 |
130 |
131 | 132 |
133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-1.html: -------------------------------------------------------------------------------- 1 |
var results = ffmpeg_run({
 2 |   arguments: [string],
 3 |   files: [
 4 |     {
 5 |       data: UInt8Array,
 6 |       name: string
 7 |     }
 8 |   ]
 9 | });
10 | 
11 | // results is an Array of { data: UInt8Array, name: string }
12 | results.forEach(function(file) {
13 |   console.log("File recieved", file.name, file.data);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-1.txt: -------------------------------------------------------------------------------- 1 | var results = ffmpeg_run({ 2 | arguments: [string], 3 | files: [ 4 | { 5 | data: UInt8Array, 6 | name: string 7 | } 8 | ] 9 | }); 10 | 11 | // results is an Array of { data: UInt8Array, name: string } 12 | results.forEach(function(file) { 13 | console.log("File recieved", file.name, file.data); 14 | }); 15 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-2.html: -------------------------------------------------------------------------------- 1 |
importScripts('ffmpeg.js');
 2 | 
 3 | function print(text) {
 4 |   postMessage({
 5 |     'type' : 'stdout',
 6 |     'data' : text
 7 |   });
 8 | }
 9 | 
10 | onmessage = function(event) {
11 |   var module = {
12 |     files: event.data.files || [],
13 |     arguments: event.data.arguments || [],
14 |     print: print,
15 |     printErr: print
16 |   };
17 |   postMessage({
18 |     'type' : 'start',
19 |     'data' : module.arguments
20 |   });
21 |   var result = ffmpeg_run(module);
22 |   postMessage({
23 |     'type' : 'done',
24 |     'data' : result
25 |   });
26 | };
27 | 
28 | postMessage({
29 |   'type' : 'ready'
30 | });
31 | 
32 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-2.txt: -------------------------------------------------------------------------------- 1 | importScripts('ffmpeg.js'); 2 | 3 | function print(text) { 4 | postMessage({ 5 | 'type' : 'stdout', 6 | 'data' : text 7 | }); 8 | } 9 | 10 | onmessage = function(event) { 11 | var module = { 12 | files: event.data.files || [], 13 | arguments: event.data.arguments || [], 14 | print: print, 15 | printErr: print 16 | }; 17 | postMessage({ 18 | 'type' : 'start', 19 | 'data' : module.arguments 20 | }); 21 | var result = ffmpeg_run(module); 22 | postMessage({ 23 | 'type' : 'done', 24 | 'data' : result 25 | }); 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'ready' 30 | }); 31 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-3.html: -------------------------------------------------------------------------------- 1 |
var worker = new Worker("worker.js");
 2 | worker.onmessage = function (event) {
 3 |   var message = event.data;
 4 |   if (message.type == "ready") {
 5 |     outputElement.textContent = "Loaded";
 6 |     worker.postMessage({
 7 |       type: 'command',
 8 |       arguments: ['-help']
 9 |     })
10 |   } else if (message.type == "stdout") {
11 |     outputElement.textContent += message.data + "\n";
12 |   } else if (message.type == "start") {
13 |     outputElement.textContent = "Worker has received command\n";
14 |   }
15 | };
16 | 
17 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-3.txt: -------------------------------------------------------------------------------- 1 | var worker = new Worker("worker.js"); 2 | worker.onmessage = function (event) { 3 | var message = event.data; 4 | if (message.type == "ready") { 5 | outputElement.textContent = "Loaded"; 6 | worker.postMessage({ 7 | type: 'command', 8 | arguments: ['-help'] 9 | }) 10 | } else if (message.type == "stdout") { 11 | outputElement.textContent += message.data + "\n"; 12 | } else if (message.type == "start") { 13 | outputElement.textContent = "Worker has received command\n"; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-4.html: -------------------------------------------------------------------------------- 1 |
var sampleVideoData;
 2 | function retrieveSampleVideo() {
 3 |   var oReq = new XMLHttpRequest();
 4 |   oReq.open("GET", "bigbuckbunny.webm", true);
 5 |   oReq.responseType = "arraybuffer";
 6 | 
 7 |   oReq.onload = function (oEvent) {
 8 |     var arrayBuffer = oReq.response;
 9 |     if (arrayBuffer) {
10 |       sampleVideoData = new Uint8Array(arrayBuffer);
11 |     }
12 |   };
13 | 
14 |   oReq.send(null);
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-4.txt: -------------------------------------------------------------------------------- 1 | var sampleVideoData; 2 | function retrieveSampleVideo() { 3 | var oReq = new XMLHttpRequest(); 4 | oReq.open("GET", "bigbuckbunny.webm", true); 5 | oReq.responseType = "arraybuffer"; 6 | 7 | oReq.onload = function (oEvent) { 8 | var arrayBuffer = oReq.response; 9 | if (arrayBuffer) { 10 | sampleVideoData = new Uint8Array(arrayBuffer); 11 | } 12 | }; 13 | 14 | oReq.send(null); 15 | } 16 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-5.html: -------------------------------------------------------------------------------- 1 |
function getDownloadLink(fileData, fileName) {
 2 |   var a = document.createElement('a');
 3 |   a.download = fileName;
 4 |   var blob = new Blob([fileData]);
 5 |   var src = window.URL.createObjectURL(blob);
 6 |   a.href = src;
 7 |   a.textContent = 'Click here to download ' + fileName + "!";
 8 |   return a;
 9 | }
10 | 
11 | var result = ffmpeg_run(module);
12 | result.forEach(function(file) {
13 |   getDownloadLink(file.data, file.name);
14 | });
15 | 
16 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/code-blocks/example-5.txt: -------------------------------------------------------------------------------- 1 | function getDownloadLink(fileData, fileName) { 2 | var a = document.createElement('a'); 3 | a.download = fileName; 4 | var blob = new Blob([fileData]); 5 | var src = window.URL.createObjectURL(blob); 6 | a.href = src; 7 | a.textContent = 'Click here to download ' + fileName + "!"; 8 | return a; 9 | } 10 | 11 | var result = ffmpeg_run(module); 12 | result.forEach(function(file) { 13 | getDownloadLink(file.data, file.name); 14 | }); 15 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/site/favicon.ico -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/light_toast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/site/light_toast.png -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/site/load.gif -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/site/logo.png -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | 5 | html, body { 6 | padding: 0; 7 | margin: 0; 8 | } 9 | 10 | body { 11 | position: relative; 12 | } 13 | 14 | body { 15 | min-height: 100%; 16 | background: #eee url(light_toast.png); 17 | font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif; 18 | line-height: 1.5; 19 | font-weight: 300; 20 | color: #4D4D4D; 21 | min-width: 630px; 22 | } 23 | 24 | center { 25 | margin: 10px 0; 26 | } 27 | 28 | strong { 29 | font-weight: bold; 30 | } 31 | 32 | .container-fluid { 33 | width: 90%; 34 | margin: 0 auto; 35 | height: 100%; 36 | min-height: 100%; 37 | font-size: 14px; 38 | background: rgba(255, 255, 255, .8); 39 | padding: 0 10px; 40 | } 41 | 42 | .content { 43 | padding-bottom: 20px; 44 | } 45 | 46 | p, li { 47 | font-size: 16px; 48 | } 49 | 50 | .header { 51 | margin: 0 -5.6%; 52 | padding: 5px 5.6%; 53 | box-shadow: 0 0 3px #74ad5a; 54 | margin-bottom: 4px; 55 | background-image: -webkit-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 56 | background-image: -moz-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 57 | background-image: -o-repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 58 | background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.8), rgba(255,255,255,.8) 1px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.95) 2px, rgba(255,255,255,.8) 3px); 59 | -webkit-background-size: 4px 4px; 60 | -moz-background-size: 4px 4px; 61 | background-size: 4px 4px; 62 | } 63 | 64 | h2 { 65 | font-family: Georgia; 66 | text-transform: uppercase; 67 | margin: 5px 0; 68 | font-size: 24px; 69 | font-weight: lighter; 70 | } 71 | 72 | h2 a { 73 | opacity: 0; 74 | text-decoration: none; 75 | font-style: normal; 76 | color: #333; 77 | vertical-align: text-top; 78 | font-size: 80%; 79 | text-transform: none; 80 | transition: opacity linear .1s; 81 | } 82 | 83 | h2:hover a { 84 | opacity: 1; 85 | } 86 | 87 | h2 a:hover { 88 | color: #74ad5a; 89 | } 90 | 91 | h3 { 92 | font-size: 18px; 93 | text-decoration: underline; 94 | font-family: Georgia; 95 | font-weight: normal; 96 | } 97 | 98 | h1 { 99 | margin: 0; 100 | padding: 0; 101 | font-size: 32px; 102 | line-height: 32px; 103 | font-weight: 300; 104 | } 105 | 106 | h1 a, h1 a:visited { 107 | color: #333; 108 | text-decoration: none; 109 | } 110 | 111 | h1 a:hover { 112 | text-decoration: underline; 113 | } 114 | 115 | h1 span { 116 | vertical-align: top; 117 | margin-left: 5px; 118 | } 119 | 120 | .warning { 121 | background-color: #FEE8E8; 122 | border: 1px solid #DDD; 123 | font-size: 13px; 124 | line-height: 19px; 125 | overflow: auto; 126 | padding: 6px 10px; 127 | border-radius: 3px; 128 | } 129 | .note { 130 | background-color: #E8FEE8; 131 | border: 1px solid #DDD; 132 | font-size: 13px; 133 | line-height: 19px; 134 | overflow: auto; 135 | padding: 6px 10px; 136 | border-radius: 3px; 137 | } 138 | 139 | code, pre { 140 | font-family: Consolas,"Liberation Mono",Courier,monospace; 141 | } 142 | 143 | pre { 144 | font-size: 12px; 145 | background-color: #F8F8F8; 146 | border: 1px solid #BDB; 147 | font-size: 13px; 148 | line-height: 19px; 149 | overflow: auto; 150 | padding: 6px 10px; 151 | border-radius: 3px; 152 | color: #232; 153 | } 154 | 155 | code { 156 | color: #696; 157 | font-family: inherit; 158 | } 159 | 160 | .tagline { 161 | font-size: 24px; 162 | } 163 | 164 | a.big { 165 | -moz-box-shadow: inset 0px 1px 0px 0px #9acc85; 166 | -webkit-box-shadow: inset 0px 1px 0px 0px #9acc85; 167 | box-shadow: inset 0px 1px 0px 0px #9acc85; 168 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #74ad5a), color-stop(1, #68a54b)); 169 | background: -moz-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 170 | background: -webkit-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 171 | background: -o-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 172 | background: -ms-linear-gradient(top, #74ad5a 5%, #68a54b 100%); 173 | background: linear-gradient(to bottom, #74ad5a 5%, #68a54b 100%); 174 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#74ad5a', endColorstr='#68a54b',GradientType=0); 175 | background-color: #74ad5a; 176 | border: 1px solid #3b6e22; 177 | display: inline-block; 178 | color: #ffffff; 179 | font-size: 20px; 180 | padding: 8px 12px; 181 | text-decoration: none; 182 | } 183 | 184 | a.big:hover { 185 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #68a54b), color-stop(1, #74ad5a)); 186 | background: -moz-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 187 | background: -webkit-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 188 | background: -o-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 189 | background: -ms-linear-gradient(top, #68a54b 5%, #74ad5a 100%); 190 | background: linear-gradient(to bottom, #68a54b 5%, #74ad5a 100%); 191 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#68a54b', endColorstr='#74ad5a',GradientType=0); 192 | background-color: #68a54b; 193 | } 194 | 195 | a.big:active { 196 | position: relative; 197 | top: 1px; 198 | } 199 | 200 | .plain-button { 201 | cursor: pointer; 202 | -moz-box-shadow: inset 0px 1px 0px 0px #ffffff; 203 | -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff; 204 | box-shadow: inset 0px 1px 0px 0px #ffffff; 205 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #f6f6f6)); 206 | background: -moz-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 207 | background: -webkit-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 208 | background: -o-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 209 | background: -ms-linear-gradient(top, #ffffff 5%, #f6f6f6 100%); 210 | background: linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%); 211 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f6f6f6',GradientType=0); 212 | background-color: #ffffff; 213 | -moz-border-radius: 6px; 214 | -webkit-border-radius: 6px; 215 | border-radius: 6px; 216 | border: 1px solid #dcdcdc; 217 | display: inline-block; 218 | color: #666666; 219 | font-size: 14px; 220 | padding: 6px 8px; 221 | text-decoration: none; 222 | text-shadow: 0px 1px 0px #ffffff; 223 | } 224 | 225 | .plain-button:hover { 226 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff)); 227 | background: -moz-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 228 | background: -webkit-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 229 | background: -o-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 230 | background: -ms-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); 231 | background: linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); 232 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6f6f6', endColorstr='#ffffff',GradientType=0); 233 | background-color: #f6f6f6; 234 | } 235 | 236 | .plain-button:active { 237 | position: relative; 238 | top: 1px; 239 | } 240 | 241 | .links a { 242 | background: #333; 243 | color: #fff; 244 | padding: 10px; 245 | padding-bottom: 8px; 246 | text-decoration: none; 247 | transition: top ease-in-out .05s; 248 | position: relative; 249 | top: -2px; 250 | } 251 | 252 | .links a:hover { 253 | /*padding-bottom: 10px;*/ 254 | top: 0; 255 | } 256 | 257 | .links a:visited { 258 | color: #ddd; 259 | } 260 | 261 | .pull-left { 262 | float: left; 263 | } 264 | 265 | .pull-right { 266 | float: right; 267 | } 268 | 269 | .clearfix { 270 | *zoom: 1; 271 | } 272 | 273 | .clearfix:before, 274 | .clearfix:after { 275 | display: table; 276 | line-height: 0; 277 | content: ""; 278 | } 279 | 280 | .clearfix:after { 281 | clear: both; 282 | } -------------------------------------------------------------------------------- /build_all_codecs/wasm/site/site.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonasof/videoconverter.js-wasm-demo/9f326af87b665bb45cdd71f298f481609bc55283/build_all_codecs/wasm/site/site.js -------------------------------------------------------------------------------- /build_all_codecs/wasm/terminal.js: -------------------------------------------------------------------------------- 1 | 2 | var worker; 3 | var sampleImageData; 4 | var sampleVideoData; 5 | var outputElement; 6 | var filesElement; 7 | var running = false; 8 | var isWorkerLoaded = false; 9 | var isSupported = (function() { 10 | return document.querySelector && window.URL && window.Worker; 11 | })(); 12 | 13 | function isReady() { 14 | return !running && isWorkerLoaded && sampleImageData && sampleVideoData; 15 | } 16 | 17 | function startRunning() { 18 | document.querySelector("#image-loader").style.visibility = "visible"; 19 | outputElement.className = ""; 20 | filesElement.innerHTML = ""; 21 | running = true; 22 | } 23 | function stopRunning() { 24 | document.querySelector("#image-loader").style.visibility = "hidden"; 25 | running = false; 26 | } 27 | 28 | function retrieveSampleImage() { 29 | var oReq = new XMLHttpRequest(); 30 | oReq.open("GET", "bigbuckbunny.jpg", true); 31 | oReq.responseType = "arraybuffer"; 32 | 33 | oReq.onload = function (oEvent) { 34 | var arrayBuffer = oReq.response; 35 | if (arrayBuffer) { 36 | sampleImageData = new Uint8Array(arrayBuffer); 37 | } 38 | }; 39 | 40 | oReq.send(null); 41 | } 42 | 43 | function retrieveSampleVideo() { 44 | var oReq = new XMLHttpRequest(); 45 | oReq.open("GET", "bigbuckbunny.webm", true); 46 | oReq.responseType = "arraybuffer"; 47 | 48 | oReq.onload = function (oEvent) { 49 | var arrayBuffer = oReq.response; 50 | if (arrayBuffer) { 51 | sampleVideoData = new Uint8Array(arrayBuffer); 52 | } 53 | }; 54 | 55 | oReq.send(null); 56 | } 57 | 58 | function parseArguments(text) { 59 | text = text.replace(/\s+/g, ' '); 60 | var args = []; 61 | // Allow double quotes to not split args. 62 | text.split('"').forEach(function(t, i) { 63 | t = t.trim(); 64 | if ((i % 2) === 1) { 65 | args.push(t); 66 | } else { 67 | args = args.concat(t.split(" ")); 68 | } 69 | }); 70 | return args; 71 | } 72 | 73 | 74 | function runCommand(text) { 75 | if (isReady()) { 76 | startRunning(); 77 | var args = parseArguments(text); 78 | console.log(args); 79 | if (typeof(args[0]) == "string" && args[0] == "benchmark") { 80 | args.shift(); 81 | worker.postMessage({ 82 | type: "benchmark", 83 | arguments: args, 84 | files: [ 85 | { 86 | "name": "input.jpeg", 87 | "data": sampleImageData 88 | }, 89 | { 90 | "name": "input.webm", 91 | "data": sampleVideoData 92 | } 93 | ] 94 | }); 95 | } else { 96 | worker.postMessage({ 97 | type: "command", 98 | arguments: args, 99 | files: [ 100 | { 101 | "name": "input.jpeg", 102 | "data": sampleImageData 103 | }, 104 | { 105 | "name": "input.webm", 106 | "data": sampleVideoData 107 | } 108 | ] 109 | }); 110 | } 111 | } 112 | } 113 | 114 | function getDownloadLink(fileData, fileName) { 115 | if (fileName.match(/\.jpeg|\.gif|\.jpg|\.png/)) { 116 | var blob = new Blob([fileData]); 117 | var src = window.URL.createObjectURL(blob); 118 | var img = document.createElement('img'); 119 | 120 | img.src = src; 121 | return img; 122 | } 123 | else { 124 | var a = document.createElement('a'); 125 | a.download = fileName; 126 | var blob = new Blob([fileData]); 127 | var src = window.URL.createObjectURL(blob); 128 | a.href = src; 129 | a.textContent = 'Click here to download ' + fileName + "!"; 130 | return a; 131 | } 132 | } 133 | 134 | function initWorker() { 135 | worker = new Worker("worker-asm.js"); 136 | worker.onmessage = function (event) { 137 | var message = event.data; 138 | if (message.type == "ready") { 139 | isWorkerLoaded = true; 140 | worker.postMessage({ 141 | type: "command", 142 | arguments: ["-help"] 143 | }); 144 | } else if (message.type == "stdout") { 145 | outputElement.textContent += message.data + "\n"; 146 | } else if (message.type == "start") { 147 | outputElement.textContent = "Worker has received command\n"; 148 | } else if (message.type == "done") { 149 | stopRunning(); 150 | var buffers = message.data; 151 | if (buffers.length) { 152 | outputElement.className = "closed"; 153 | } 154 | buffers.forEach(function(file) { 155 | filesElement.appendChild(getDownloadLink(file.data, file.name)); 156 | }); 157 | } 158 | }; 159 | } 160 | 161 | document.addEventListener("DOMContentLoaded", function() { 162 | 163 | initWorker(); 164 | retrieveSampleVideo(); 165 | retrieveSampleImage(); 166 | 167 | var inputElement = document.querySelector("#input"); 168 | outputElement = document.querySelector("#output"); 169 | filesElement = document.querySelector("#files"); 170 | 171 | inputElement.addEventListener("keydown", function(e) { 172 | if (e.keyCode === 13) { 173 | runCommand(inputElement.value); 174 | } 175 | }, false); 176 | document.querySelector("#run").addEventListener("click", function() { 177 | runCommand(inputElement.value); 178 | }); 179 | 180 | [].forEach.call(document.querySelectorAll(".sample"), function(link) { 181 | link.addEventListener("click", function(e) { 182 | inputElement.value = this.getAttribute("data-command"); 183 | runCommand(inputElement.value); 184 | e.preventDefault(); 185 | }); 186 | }); 187 | 188 | }); 189 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/worker-asm.js: -------------------------------------------------------------------------------- 1 | importScripts('./ffmpeg-all-codecs.js'); 2 | importScripts('./lodash.js'); 3 | importScripts('./benchmark.js'); 4 | 5 | var now = Date.now; 6 | 7 | function print(text) { 8 | postMessage({ 9 | 'type' : 'stdout', 10 | 'data' : text 11 | }); 12 | } 13 | 14 | onmessage = function(event) { 15 | 16 | var message = event.data; 17 | 18 | if (message.type === "command") { 19 | 20 | var Module = { 21 | print: print, 22 | printErr: print, 23 | files: message.files || [], 24 | arguments: message.arguments || [], 25 | TOTAL_MEMORY: 268435456 26 | // Can play around with this option - must be a power of 2 27 | // TOTAL_MEMORY: 268435456 28 | }; 29 | 30 | postMessage({ 31 | 'type' : 'start', 32 | 'data' : Module.arguments.join(" ") 33 | }); 34 | 35 | postMessage({ 36 | 'type' : 'stdout', 37 | 'data' : 'Received command: ' + 38 | Module.arguments.join(" ") + 39 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 40 | }); 41 | 42 | var time = now(); 43 | 44 | Module['returnCallback'] = function(result) { 45 | var totalTime = now() - time; 46 | 47 | postMessage({ 48 | 'type' : 'stdout', 49 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 50 | }); 51 | 52 | postMessage({ 53 | 'type' : 'done', 54 | 'data' : result, 55 | 'time' : totalTime 56 | }); 57 | } 58 | 59 | var result = ffmpeg_run(Module); 60 | 61 | } 62 | 63 | if (message.type === "benchmark") { 64 | 65 | var Module = {}; 66 | 67 | postMessage({ 68 | 'type' : 'start', 69 | 'data' : message.arguments.join(" ") 70 | }); 71 | print("Starting benchmark") 72 | 73 | var suite = new Benchmark.Suite 74 | suite.add('ffmpeg', { 75 | 'defer': true, 76 | 'setup': function() { 77 | Module = { 78 | print: function(data){}, 79 | printErr: function(data){}, 80 | files: message.files || [], 81 | arguments: message.arguments.slice() || [], 82 | TOTAL_MEMORY: 268435456 83 | // Can play around with this option - must be a power of 2 84 | // TOTAL_MEMORY: 268435456 85 | }; 86 | print("."); 87 | }, 88 | 'fn': function(deferred) { 89 | Module['returnCallback'] = function(result) { 90 | deferred.resolve(); 91 | } 92 | ffmpeg_run(Module); 93 | } 94 | }).on('complete', function() { 95 | var results = this.filter('fastest')[0]; 96 | print("Samples:" + results.stats.sample.length) 97 | print("Mean:" + results.stats.mean) 98 | print("Variance:" + results.stats.variance) 99 | print("Stddev:" + Math.sqrt(results.stats.variance)) 100 | postMessage({ 101 | 'type' : 'done', 102 | 'data' : [], 103 | 'time' : 0 104 | }); 105 | }).run({'async': true}); 106 | } 107 | }; 108 | 109 | postMessage({ 110 | 'type' : 'ready' 111 | }); 112 | -------------------------------------------------------------------------------- /build_all_codecs/wasm/worker.js: -------------------------------------------------------------------------------- 1 | importScripts('./ffmpeg-all-codecs.js'); 2 | 3 | var now = Date.now; 4 | 5 | function print(text) { 6 | postMessage({ 7 | 'type' : 'stdout', 8 | 'data' : text 9 | }); 10 | } 11 | 12 | onmessage = function(event) { 13 | 14 | var message = event.data; 15 | 16 | if (message.type === "command") { 17 | 18 | var Module = { 19 | print: print, 20 | printErr: print, 21 | files: message.files || [], 22 | arguments: message.arguments || [], 23 | TOTAL_MEMORY: message.TOTAL_MEMORY || false 24 | // Can play around with this option - must be a power of 2 25 | // TOTAL_MEMORY: 268435456 26 | }; 27 | 28 | postMessage({ 29 | 'type' : 'start', 30 | 'data' : Module.arguments.join(" ") 31 | }); 32 | 33 | postMessage({ 34 | 'type' : 'stdout', 35 | 'data' : 'Received command: ' + 36 | Module.arguments.join(" ") + 37 | ((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "") 38 | }); 39 | 40 | var time = now(); 41 | var result = ffmpeg_run(Module); 42 | console.log(result); 43 | console.log("post result") 44 | 45 | var totalTime = now() - time; 46 | postMessage({ 47 | 'type' : 'stdout', 48 | 'data' : 'Finished processing (took ' + totalTime + 'ms)' 49 | }); 50 | 51 | postMessage({ 52 | 'type' : 'done', 53 | 'data' : result, 54 | 'time' : totalTime 55 | }); 56 | } 57 | }; 58 | 59 | postMessage({ 60 | 'type' : 'ready' 61 | }); 62 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 |

BUILD_AGPL

2 |

ASM.js

3 |

WASM

4 |

BUILD_ALL_CODECS

5 |

ASM.js

6 |

WASM

7 | --------------------------------------------------------------------------------