Add file downloader and example option. Update dependencies.

This commit is contained in:
Alf
2021-03-28 00:04:37 -07:00
parent 39da8ac6a7
commit 88110bfd1b
4 changed files with 3241 additions and 919 deletions

3980
www/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "ffprobe-wasm", "name": "ffprobe-wasm",
"version": "0.4.0", "version": "0.5.0",
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
@@ -8,22 +8,22 @@
"deploy": "npm run build && gh-pages -d dist" "deploy": "npm run build && gh-pages -d dist"
}, },
"dependencies": { "dependencies": {
"bootstrap": "^4.5.2", "bootstrap": "^4.6.0",
"bootstrap-vue": "^2.16.0", "bootstrap-vue": "^2.21.2",
"core-js": "^3.6.5", "core-js": "^3.9.1",
"gh-pages": "^3.1.0", "gh-pages": "^3.1.0",
"vue": "^2.6.11", "vue": "^2.6.12",
"wasm-loader": "^1.3.0" "wasm-loader": "^1.3.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "^4.5.12",
"@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-eslint": "^4.5.12",
"@vue/cli-service": "~4.5.0", "@vue/cli-service": "^4.5.12",
"@wasm-tool/wasm-pack-plugin": "^1.3.1", "@wasm-tool/wasm-pack-plugin": "^1.3.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"eslint": "^6.7.2", "eslint": "^6.8.0",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11" "vue-template-compiler": "^2.6.12"
}, },
"eslintConfig": { "eslintConfig": {
"root": true, "root": true,

View File

@@ -13,10 +13,8 @@
<GitHubCorner /> <GitHubCorner />
<div id="app" class="container"> <div id="app" class="container">
<h3>FFProbe</h3> <b-alert variant="warning" size="sm" show>
Please use Google Chrome or Microsoft Edge.
<b-alert variant="warning" show>
Compatible with Chrome and Edge only due to limited support for <a href="https://caniuse.com/sharedarraybuffer">SharedArrayBuffer</a> and the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer">required CORS headers</a> for Firefox on Github Pages.
</b-alert> </b-alert>
<hr /> <hr />

View File

@@ -1,7 +1,15 @@
<template> <template>
<div class="file"> <div class="file">
<b-form-row>
<b-col>
<b-form-group label="Select a file:" label-for="file"> <b-form-group label="Select a file:" label-for="file">
<b-input-group>
<b-form-select class="protocol" v-model="protocol">
<option v-for="o in protocols" :key="o.id" :value="o.value">{{ o.name }}</option>
</b-form-select>
<b-form-file <b-form-file
v-if="protocol === 'file'"
id="file" id="file"
accept=".mp4, .mkv" accept=".mp4, .mkv"
v-model="file" v-model="file"
@@ -10,15 +18,45 @@
drop-placeholder="Drop file here..." drop-placeholder="Drop file here..."
@change="onFile" @change="onFile"
></b-form-file> ></b-form-file>
</b-form-group>
<div v-if="info"> <b-form-input
<div class="mt-3">Selected file: {{ file ? `${file.name}: ${file.size} bytes` : '' }}</div> v-if="protocol === 'url'"
v-model="url"
:state="Boolean(url)"
placeholder="Enter a URL"
></b-form-input>
<b-form-select v-if="protocol === 'example'" v-model="url">
<template #first>
<b-form-select-option :value="null" disabled>-- Please select an option --</b-form-select-option>
</template>
<option v-for="o in examples" :key="o.id" :value="o.value">{{ o.name }}</option>
</b-form-select>
<b-input-group-append v-if="protocol !== 'file'">
<b-button @click="onDownload">Download</b-button>
</b-input-group-append>
</b-input-group>
</b-form-group>
</b-col>
</b-form-row>
<b-progress
class="mb-2"
height="2px"
v-if="showProgress"
:value="progress"
max="100">
</b-progress>
<div v-if="data">
<div v-if="file">Selected file: {{ file ? `${file.name}: ${file.size} bytes` : '' }}</div>
<div v-else>URL: {{ url ? `${url} (${size} bytes)` : '' }}</div>
<b-tabs class="mt-4" v-model="tabIndex"> <b-tabs class="mt-4" v-model="tabIndex">
<b-tab title="Overview" class="mt-2"> <b-tab title="Overview" class="mt-2">
<div v-if="info"> <div v-if="data">
<Overview :info="info" /> <Overview :info="data" />
</div> </div>
</b-tab> </b-tab>
<b-tab title="Frames" class="mt-2" lazy> <b-tab title="Frames" class="mt-2" lazy>
@@ -41,20 +79,62 @@ export default {
}, },
data() { data() {
return { return {
protocols: [
{ name: 'File', value: 'file'},
{ name: 'URL', value: 'url'},
{ name: 'Example', value: 'example'},
],
examples: [
{ name: 'Video Counter (10min, unfragmented, AVC Baseline)', value: 'https://video-examples-public.s3.us-west-2.amazonaws.com/video_counter_10min_unfragmented_avc.mp4' },
],
protocol: 'file',
file: null, file: null,
info: null, url: null,
size: null,
data: null,
tabIndex: 0, tabIndex: 0,
progress: 0,
showProgress: false,
} }
}, },
methods: { methods: {
onFile(event) { onFile(event) {
this.tabIndex = 0; this.tabIndex = 0;
this.$worker.onmessage = (e) => { this.$worker.onmessage = (e) => {
this.info = e.data; this.data = e.data;
} }
const file = event.dataTransfer ? event.dataTransfer.files[0] : event.target.files[0]; const file = event.dataTransfer ? event.dataTransfer.files[0] : event.target.files[0];
this.$worker.postMessage([ 'get_file_info', file ]); this.$worker.postMessage([ 'get_file_info', file ]);
},
onDownload() {
this.showProgress = true;
this.tabIndex = 0;
this.$worker.onmessage = (e) => {
this.data = e.data;
} }
const xhr = new XMLHttpRequest();
xhr.onprogress = (event) => {
if (event.lengthComputable) {
this.progress = parseInt(((event.loaded / event.total) * 100), 10);
}
}
xhr.onload = (event) => {
this.progress = 100;
const file = new File([event.target.response], "file");
this.size = file.size;
this.$worker.postMessage([ 'get_file_info', file ]);
setTimeout(() => { this.showProgress = false; }, 2000);
}
xhr.open('GET', this.url, true);
xhr.responseType = 'blob';
xhr.send();
},
} }
} }
</script> </script>
<style scoped>
.protocol {
flex: 0 0 20% !important;
}
</style>