-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
167 lines (166 loc) · 6.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>FFmpeg Online Converter - Free Media Converter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
content="FFmpeg online converter. Web-based FFmpeg. Online image, audio and video converter. Easily convert video and audio formats using your browser. Converting speed depends on your computer's performance.">
<link crossorigin="anonymous" rel="stylesheet" href="https://unpkg.com/[email protected]/lib/theme-chalk/index.css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="alternate" hreflang="en" href="index.html"/>
<link rel="alternate" hreflang="zh" href="index_zh.html"/>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8336276656855850"
crossorigin="anonymous"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZZZQVLS89C"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ZZZQVLS89C');
</script>
</head>
<body>
<div id="app" style="margin-left: 10%; margin-right: 10%; margin-bottom: 5%;">
<h1>FFmpeg Online Converter</h1>
<el-row>
<p>Language/语言:
<el-link type="primary" href="index.html">English</el-link>
<el-link type="primary" href="index_zh.html">中文</el-link>
</p>
</el-row>
<h2>Introduction</h2>
<el-row>
<p>Convert video and audio formats easily. Supports mp3 to wav, ogg to mp3, mp4 to gif, webm to mp4, mp4 to mp3, svg to png, etc.</p>
<p>Your files will be processed locally, ensuring safety and privacy. Use your browser to transcode; the speed depends on your computer's performance. It's recommended for converting short videos or audio
files only. For large videos, use professional software for transcoding.</p>
<p>
<el-link type="warning" href="advanced.html">Click to switch to Expert Mode</el-link>
</p>
<p>
<el-link type="success" href="https://github.com/chn-lee-yumi/ffmpeg_in_browser">This project is open source on GitHub (Welcome to provide
suggestions and feedback through issues)
</el-link>
</p>
<p>
Other tools:
<el-link type="success" href="https://tool.gcc.ac.cn/">https://tool.gcc.ac.cn/</el-link>
</p>
</el-row>
<h2>Transcoding Parameters</h2>
<el-row>
Thread Mode:
<el-switch v-model="threadMode" active-text="Multithread (faster but unstable and not supported by all browsers, please switch it off when encountering errors)"
inactive-text="Single thread" @change="reloadFFmpeg"></el-switch>
</el-row>
<el-row>
Video Bitrate:
<el-input placeholder="Leave blank for default, e.g., 2m, 1m, 512k" v-model="videoBitrate" style="width: 30%;"></el-input>
(Note: Leave blank for image and audio files)
</el-row>
<el-row>
Audio Bitrate:
<el-input placeholder="Leave blank for default, e.g., 128k, 96k" v-model="audioBitrate" style="width: 30%;"></el-input>
(Note: Leave blank for image files)
</el-row>
<el-row>
Output Filename:
<el-input placeholder="" v-model="outputName" style="width: 30%;"></el-input>
(Note: The format is determined by the file extension. Do not use the same name as the selected file.)
</el-row>
<h2>Start Transcoding</h2>
<el-upload v-loading="loading" :on-change="handleFiles" :file-list="fileList" :auto-upload="false">
<el-button size="big" type="primary">Select File</el-button>
</el-upload>
<h2>System Output</h2>
<el-card class="box-card">
<pre id="tty" style="white-space: pre-wrap; word-wrap: break-word;">Loading FFmpeg, please wait...</pre>
<el-row v-if="downloading">
<p v-model="currentLoadingUrl">Downloading: {{currentLoadingUrl}}</p>
<el-progress :percentage="percentage"></el-progress>
</el-row>
</el-card>
</div>
</body>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/lib/index.js"></script>
<script src="common.js"></script>
<script>
new Vue({
el: '#app',
data: {
loading: false,
fileList: [],
videoBitrate: "",
audioBitrate: "",
outputName: "output.mp4",
percentage: 0,
threadMode: false,
currentLoadingUrl: "",
total: 0,
received: 0,
downloading: false,
},
mounted: async function() {
this.loading = true;
this.downloading = true;
await load(this.threadMode, this.cb);
this.downloading = false;
this.loading = false;
log("FFmpeg Loaded!");
},
methods: {
cb: function(data) {
this.currentLoadingUrl = data.url;
this.total = data.total;
this.received = data.received;
this.percentage = ((data.received / data.total) * 100).toFixed(0);
},
reloadFFmpeg: async function() {
cleanLog();
log("Reloading FFmpeg...");
this.loading = true;
this.downloading = true;
await load(this.threadMode, this.cb);
this.downloading = false;
this.loading = false;
log("FFmpeg Loaded!");
},
handleFiles: async function(file, fileList) {
cleanLog();
this.loading = true;
console.log(file.name);
const inputDir = '/input';
const inputFile = `${inputDir}/${file.name}`;
await ffmpeg.createDir(inputDir);
await ffmpeg.mount('WORKERFS', {
files: [file.raw],
}, inputDir);
var args = ['-i', inputFile];
if (this.videoBitrate != "") {
args = args.concat(['-b:v', this.videoBitrate])
}
if (this.audioBitrate != "") {
args = args.concat(['-b:a', this.audioBitrate])
}
args.push(this.outputName);
this.fileList = [];
console.log(args);
const err = await ffmpeg.exec(args);
if (err != 0) {
log("<strong>Transcode Error! Please see the log above.</strong>");
} else {
log("Exporting output file...");
const data = await ffmpeg.readFile(this.outputName);
downloadFileByBlob(URL.createObjectURL(new Blob([data.buffer], {
type: "application/octet-stream"
})), this.outputName);
}
await ffmpeg.unmount(inputDir);
await ffmpeg.deleteDir(inputDir);
this.loading = false;
}
}
})
</script>
</html>