Skip to content

Commit 9010d88

Browse files
committed
almost done just a couple more things to do
1 parent 992a34f commit 9010d88

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

controllers/backend/uploading.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ exports.postFileUpload = async(req, res) => {
427427

428428
let bitrate, codecName, codecProfile;
429429

430+
// if not an image, requires ffprobe data collection
430431
if(upload.fileType !== 'image'){
431432

432433
// load the ffprobe data in response
@@ -502,12 +503,16 @@ exports.postFileUpload = async(req, res) => {
502503

503504
console.log('done moving file');
504505

506+
507+
/** BASIC VIDEO PROCESSING COMPLETED, CHECKING IF NEEDS CONVERSION **/
508+
505509
const specificMatches = ( codecName == 'hevc' || codecProfile == 'High 4:4:4 Predictive' );
506510

507511
if(specificMatches || bitrate > maxBitrate){
508512
upload.fileType = 'convert';
509513
}
510514

515+
// TODO: a bit ugly, wish we could pull out 'only video' stuff and then do convert in its own conditional
511516
/** TELL THE USER WE ARE CONVERTING / COMPRESSING THEIR VIDEO **/
512517
if(upload.fileType == 'convert' || bitrate > maxBitrate || upload.fileType == 'video'){
513518

@@ -519,6 +524,7 @@ exports.postFileUpload = async(req, res) => {
519524
// set upload progress as 1 so it has something to show on the frontend
520525
redisClient.setAsync(`${uniqueTag}uploadProgress`, 'Your upload is beginning processing...');
521526

527+
// video is marked as processing, end the request and send user to upload page
522528
if(!responseSent){
523529
responseSent = true;
524530
aboutToProcess(res, channelUrl, uniqueTag);
@@ -535,13 +541,14 @@ exports.postFileUpload = async(req, res) => {
535541

536542
// TODO: savePath and fileInDirectory are the same thing, need to clean this code up
537543

544+
// if we need to convert, move it to this 'old' location so we can write to the new location
538545
if(fileExtension == '.mp4' && bitrate > maxBitrate || specificMatches){
539546
await fs.move(savePath, `${saveAndServeFilesDirectory}/${channelUrl}/${uniqueTag}-old.mp4`);
540547

541548
fileInDirectory = `${saveAndServeFilesDirectory}/${channelUrl}/${uniqueTag}-old.mp4`;
542549
}
543550

544-
// if the file type is convert or it's over max bitrate
551+
// if the file type is convert or it's over max bitrate, convert it with ffmpeg
545552
if(upload.fileType == 'convert' || (bitrate > maxBitrate && fileExtension == '.mp4')){
546553

547554
console.log(fileInDirectory);
@@ -556,7 +563,8 @@ exports.postFileUpload = async(req, res) => {
556563

557564
uploadLogger.info('Finished converting file', logObject);
558565

559-
// assuming an mp4 is created at this point so we delete the old uncoverted video
566+
// assuming an mp4 is created at this point so we delete the old unconverted video
567+
// note, $fileInDirectory is changed
560568
await fs.remove(`${fileInDirectory}`);
561569

562570
uploadLogger.info('Deleted unconverted file', logObject);
@@ -591,21 +599,6 @@ exports.postFileUpload = async(req, res) => {
591599
await backblaze.uploadToB2(upload, fileInDirectory, hostFilePath);
592600
}
593601

594-
// todo: only run if user has plus
595-
// will automatically stick it at /uploads/$channelUrl/$uniqueTag_sprite.png and /$uniqueTag_sprite.vtt
596-
597-
try {
598-
if(1 == 1){
599-
await createSpriteImageAndVtt(channelUrl, uniqueTag, fileInDirectory)
600-
601-
upload.hasPreviewSpriteThumbnail = true;
602-
await upload.save();
603-
}
604-
} catch (err){
605-
console.log(err);
606-
}
607-
608-
609602
await markUploadAsComplete(uniqueTag, channelUrl, user);
610603

611604
uploadLogger.info('Upload marked as complete', logObject);
@@ -643,6 +636,19 @@ exports.postFileUpload = async(req, res) => {
643636
responseSent = true;
644637
aboutToProcess(res, channelUrl, uniqueTag);
645638
}
639+
640+
// once everything is done, generate thumbnail previews
641+
if(upload.fileType === 'video'){
642+
// will automatically stick it at /uploads/$channelUrl/$uniqueTag_sprite.png and /$uniqueTag_sprite.vtt
643+
(async function(){
644+
if(user.plan === 'plus') {
645+
await createSpriteImageAndVtt(channelUrl, uniqueTag, fileInDirectory)
646+
647+
upload.hasPreviewSpriteThumbnail = true;
648+
await upload.save();
649+
}
650+
})()
651+
}
646652
});
647653

648654
// });

views/widgets/zopim.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ script.
55
setTimeout(function(){
66
// TODO: thing here
77
$zopim(function () {
8-
$zopim.livechat.window.hide();
8+
// $zopim.livechat.window.hide();
99
});
1010
}, 2000)
1111
//End of Zendesk Widget script

0 commit comments

Comments
 (0)