-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
213 lines (157 loc) · 5.05 KB
/
index.php
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>FFmpeg Video Thumbnailer By Pedram</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Description" lang="en" content="ADD SITE DESCRIPTION">
<meta name="author" content="ponishweb.ir">
<meta name="robots" content="index, follow">
<!-- icons -->
<link rel="apple-touch-icon" href="assets/img/apple-touch-icon.png">
<link rel="shortcut icon" href="favicon.ico">
<!-- Bootstrap Core CSS file -->
<link rel="stylesheet" href="./bootstrap.min.css">
<!-- Conditional comment containing JS files for IE6 - 8 -->
<!--[if lt IE 9]>
<script src="assets/js/html5.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->
<!-- JQuery scripts -->
<script src="./jquery.min.js"></script>
<style>.hidden {display:none;} .mw50 {max-width:100%;}</style>
</head>
<body style="">
<!-- Page Content -->
<div class="container">
<div class="row" style="border:1px solid #CCC; padding:30px;">
<div class="col-sm-12">
<h4 class="text-center">An Easy Way to Make Tile Video Screenshot With Ajax</h4>
<h4 class="text-danger text-center">By Pedram - Amoo Pedram</h4>
<hr/>
<div id="fileStep" class="">
<h5>Select Video File</h5>
<input type="file" class="btn btn-info" id="file" name="file">
</div>
<br/>
<div id="secondStep" class="hidden">
<input type="hidden" id="video" value=""> <!--Uploaded Video Path-->
<div class="form-group">
<h5>Set Number Of Tiles</h5>
<div class="row">
<div class="col-md-5">
<input type="number" id="tile_1" class="form-control" placeholder="2" value="2">
</div>
<div class="col-md-1 text-center">
<h5> ==> </h5>
</div>
<div class="col-md-5">
<input type="number" id="tile_2" class="form-control" placeholder="3" value="3">
</div>
</div>
</div>
<div class="form-group">
<h5>Set Each Capture Size</h5>
<div class="row">
<div class="col-md-5">
<input type="number" id="size_1" class="form-control" placeholder="320" value="320">
</div>
<div class="col-md-1 text-center">
<h5> ==> </h5>
</div>
<div class="col-md-5">
<input type="number" id="size_2" class="form-control" placeholder="240" value="240">
</div>
</div>
</div>
<br/>
<div class="col-md-12 text-center">
<input onclick="generateThumbnail();" id="submit" class="btn btn-danger" value="Generate Thumbnail">
</div>
</div> <!--#hidden-->
<div class="col-md-12 text-center">
<br/><br/>
<div id="result" class="text-center"></div>
</div>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
<script>
//Ajax Script
$(document).ready(function(){
$("#file").change(function() {
if ($(this).val() != '')
{
uploadFile(this); //Upload File
}
});
});
//Upload VIDEO
function uploadFile(file) {
var form_data = new FormData();
form_data.append('file', file.files[0]);
$.ajax({
url: './upload.php',
data: form_data,
type: 'POST',
contentType: false,
processData: false,
dataType: 'json',
xhr: function() {
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener('progress',progress, false);
}
return myXhr;
},
success:function (data) {
if(data.status == true) {
$('#result').html('Video Succesfully Uploaded !');
$('#fileStep').addClass('hidden');
$('#secondStep').removeClass('hidden');
$('#video').val(data.file);
}
else {
$('#result').html(data.status);
}
},
});
};
// Simple Upload Proress Bar
function progress(e){
if(e.lengthComputable){
var percentage = (e.loaded / e.total) * 100;
$('#result').html('Please Wait... / ' + percentage.toFixed(0) + '%');
}
};
// Generate Thumbnail
function generateThumbnail(){
$('#result').html('Generating Thumbnail, Please Wait...');
$.ajax({
url: './thumbnail.php',
type: 'POST',
data: {
video: $('#video').val(),
tile_1: $('#tile_1').val(),
tile_2: $('#tile_2').val(),
size_1: $('#size_1').val(),
size_2: $('#size_2').val(),
},
dataType: 'json',
success:function (data)
{
if(data.status == true) {
$('#result').html('<a target="_blank" href="' + data.image +'"><img src="' + data.image +'" class="img-fluid mw50"></a>');
}
else {
$('#result').html(data.status);
}
},
});
};
</script>
</body>
</html>