• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Detecting failed/corrupt uploads?

Started by thexyd,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

thexydTopic starter

So after a few days experimentation with PHPVibe, I've noticed on occasion certain uploads people do have either (1) failed - i.e. they close the browser during the upload, or (2) the file is corrupt for some reason - i.e. it wasn't properly encoded on the client side.

For (1) - failed uploads, PHPVibe will convert the file up to the point where it was cut off, and publish it (assuming publish is the default option chosen). This results in a working video, but obviously it's not the whole video.

For (2) - corrupt uploads, PHPVibe isn't even able to convert the file - not any piece of it. This results in a completely broken published video where the 'file is missing' error is shown.

Is there a way to detect whether a video wasn't completely uploaded, or if the video has failed conversion, before publishing it?

I've looked around and it doesn't appear there is a built-in remedy for this, so I think I'm going to end up writing a simple 'ffprobe' command into videocron.php to check the file for errors prior to converting. Just thought I'd ask here before doing any extra work though.

Thanks!
  •  

Marius P.

Didn't use ffprobe yet, I have yet failed to find time to test it.
Can it tell if the video is corrupted with accuracy?
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

thexydTopic starter

I've tested it against a bunch of uploads and unfortunately ffprobe is able to detect fully corrupt uploads but not uploads which have uploaded only part-way (yet they still convert).

However, I have a different solution to this - using ffmpeg, you can do basically the same thing with a specific command. This is a very very dirty way to do this, but I'm using phpvibe on a private VM so I really have no interest in beautifying the code. Either way, here's what I did... in videocron.php:

if (file_exists($input)) {

//check integrity
$rnd = rand(111111, 999999);
shell_exec("/bin/ffmpeg -v error -i $input -f null - 2>/tmp/x" . $rnd . ".log");
$intcheck = file_get_contents("/tmp/x" . $rnd . ".log");
shell_exec("rm -rf /tmp/x" . $rnd . ".log");
if (strlen($intcheck) > 2) {
$db->query("DELETE FROM `phpvibe`.`vibe_videos` WHERE `vibe_videos`.`id` = " . intval($cron->id));
goto skipall;
}
//


And at the bottom of the file...

add_activity('4', $cron->id);               
skipall:  
/* End this loops item */


Files that are either corrupt/don't convert at all will throw an error into the temporary file, and files which are cut off mid-way through an upload will also throw an error into the temporary file. Files that convert successfully will throw zero errors.

Just something to mess around with. So far I've ran it through about 20 videos which were uploaded and it has worked flawlessly. I'll report back if it turns out unsuccessful.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

prat

hey thexyd

I have put above code in videocrone.php but it is not working can you explain me in detailed where to add this code ??

Thx in advance
  •  

Similar topics (7)