6
6
<Presets v-model =" preset" />
7
7
8
8
<!-- Input and Output protocol and filenames. -->
9
- <b-form-row >
10
- <b-col >
11
- <b-form-group label =" Input:" label-for =" input" >
12
- <b-input-group >
13
- <b-form-select
14
- v-if =" !$store.state.ffmpegdEnabled || !$store.state.wsConnected"
15
- class =" protocol"
16
- v-model =" protocolInput"
17
- @change =" setProtocol('input', $event)"
18
- >
19
- <option v-for =" o in protocols" :key =" o.id" :value =" o.value" >{{o.name}}</option >
20
- </b-form-select >
21
-
22
- <b-form-input
23
- v-if =" !$store.state.ffmpegdEnabled || !$store.state.wsConnected"
24
- v-model =" form.input"
25
- :state =" Boolean(form.input)"
26
- placeholder =" Example: output.mp4"
27
- ></b-form-input >
28
-
29
- <b-form-input
30
- v-else
31
- v-model =" form.input"
32
- placeholder =" "
33
- @focus =" onFileFocus"
34
- ></b-form-input >
35
-
36
- <div v-if =" showFileBrowser" >
37
- <FileBrowser v-on:file =" onFileSelect" v-on:close =" onClose" />
38
- </div >
39
-
40
- <!-- <b-form-file
41
- v-else
42
- v-model="form.inputFile"
43
- :state="Boolean(form.inputFile)"
44
- placeholder="Choose a file or drop it here..."
45
- drop-placeholder="Drop file here..."
46
- ></b-form-file> -->
47
- </b-input-group >
48
- </b-form-group >
49
- </b-col >
50
-
51
- <b-col >
52
- <b-form-group label =" Output:" label-for =" output" >
53
- <b-input-group >
54
- <b-form-select
55
- v-if =" !$store.state.ffmpegdEnabled"
56
- class =" protocol"
57
- v-model =" protocolOutput"
58
- @change =" setProtocol('output', $event)"
59
- >
60
- <option v-for =" o in protocols" :key =" o.id" :value =" o.value" >{{o.name}}</option >
61
- </b-form-select >
62
-
63
- <b-form-input
64
- v-model =" form.output"
65
- :state =" Boolean(form.output)"
66
- placeholder =" Example: output.mp4"
67
- ></b-form-input >
68
- </b-input-group >
69
- </b-form-group >
70
- </b-col >
71
- </b-form-row >
9
+ <FileIO v-model =" form.io" />
72
10
73
11
<!-- Tabs for each command building component.
74
12
Format, Video, Audio, Filters and Options -->
@@ -139,6 +77,7 @@ import util from '@/util';
139
77
import storage from ' @/storage' ;
140
78
141
79
import Presets from ' ./Presets.vue' ;
80
+ import FileIO from ' ./FileIO.vue' ;
142
81
import Format from ' ./Format.vue' ;
143
82
import Video from ' ./Video.vue' ;
144
83
import Audio from ' ./Audio.vue' ;
@@ -147,7 +86,6 @@ import Options from './Options.vue';
147
86
import Command from ' ./Command.vue' ;
148
87
import Toolbar from ' ./Toolbar.vue' ;
149
88
import JsonViewer from ' ./JsonViewer.vue' ;
150
- import FileBrowser from ' ./FileBrowser.vue' ;
151
89
152
90
const {
153
91
protocols ,
@@ -159,6 +97,7 @@ export default {
159
97
name: ' Editor' ,
160
98
components: {
161
99
Presets,
100
+ FileIO,
162
101
Format,
163
102
Video,
164
103
Audio,
@@ -167,7 +106,6 @@ export default {
167
106
Command,
168
107
Toolbar,
169
108
JsonViewer,
170
- FileBrowser,
171
109
},
172
110
props: {},
173
111
data () {
@@ -177,12 +115,11 @@ export default {
177
115
id: ' custom' ,
178
116
name: null ,
179
117
},
180
- protocolInput: ' movie.mp4' ,
181
- protocolOutput: ' movie.mp4' ,
182
118
form: {
183
- input: ' input.mp4' ,
184
- inputFile: null ,
185
- output: ' output.mp4' ,
119
+ io: {
120
+ input: ' input.mp4' ,
121
+ output: ' output.mp4' ,
122
+ },
186
123
format: {
187
124
container: ' mp4' ,
188
125
clip: false ,
@@ -284,13 +221,6 @@ export default {
284
221
},
285
222
},
286
223
methods: {
287
- setProtocol (type , value ) {
288
- if (type === ' input' ) {
289
- this .form .input = value;
290
- } else if (type === ' output' ) {
291
- this .form .output = value;
292
- }
293
- },
294
224
setPreset (value ) {
295
225
this .reset ();
296
226
const preset = presets .getPreset (value);
@@ -302,11 +232,11 @@ export default {
302
232
this .cmd = ffmpeg .build (opt);
303
233
},
304
234
updateOutput () {
305
- if (this .form .output ) {
306
- const { format , output } = this .form ;
307
- const ext = path .extname (output);
235
+ if (this .form .io . output ) {
236
+ const { format , io } = this .form ;
237
+ const ext = path .extname (io . output );
308
238
if (ext) {
309
- this .form .output = ` ${ output .replace (ext, ` .${ format .container } ` )} ` ;
239
+ this .form .io . output = ` ${ io . output .replace (ext, ` .${ format .container } ` )} ` ;
310
240
}
311
241
}
312
242
},
@@ -318,9 +248,6 @@ export default {
318
248
const params = util .transformToQueryParams (this .form );
319
249
this .$router .push ({ query: params }).catch (() => {});
320
250
},
321
- update (key , value ) {
322
- this .$emit (' input' , { ... this .value , [key]: value });
323
- },
324
251
reset () {
325
252
// Restore form from default copy.
326
253
this .form = merge (this .form , this .default );
@@ -341,29 +268,19 @@ export default {
341
268
this .preset .name = this .preset .name || this .preset .id ;
342
269
},
343
270
encode () {
344
- const { input , inputFile , output } = this .form ;
271
+ const { input , output } = this .form . io ;
345
272
const json = util .transformToJSON (this .form );
346
273
storage .add (' queue' , {
347
274
id: Date .now (),
348
275
type: ' encode' ,
349
276
payload: json,
350
277
status: ' queued' ,
351
- input: inputFile ? inputFile . name : input ,
278
+ input,
352
279
output,
353
280
_showDetails: false ,
354
281
});
355
282
this .$emit (' onEncode' );
356
283
},
357
- onFileSelect (file ) {
358
- this .form .input = file;
359
- this .showFileBrowser = false ;
360
- },
361
- onFileFocus () {
362
- this .showFileBrowser = true ;
363
- },
364
- onClose () {
365
- this .showFileBrowser = false ;
366
- },
367
284
},
368
285
};
369
286
</script >
0 commit comments