Hello All,
Bit of a breakthrough, but not there yet...
If i changed this code on member.php
from
// Uplad thumb file
$new_thumb_name = "";
if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
$new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
if (!$new_thumb_name) {
$msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
@unlink(MEDIA_TEMP_PATH."/".$new_name);
$uploaderror = 1;
}
}
elseif (check_remote_thumb($remote_thumb_file)) {
$new_thumb_name = $remote_thumb_file;
}
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {
if ($direct_upload) {
$src = MEDIA_PATH."/".$cat_id."/".$new_name;
$dest = THUMB_PATH."/".$cat_id."/".$new_name;
}
else {
$src = MEDIA_TEMP_PATH."/".$new_name;
$dest = THUMB_TEMP_PATH."/".$new_name;
}
$do_create = 0;
if ($image_info = @getimagesize($src)) {
if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
$do_create = 1;
}
}
if ($do_create) {
require_once(ROOT_PATH.'includes/image_utils.php');
$convert_options = init_convert_options();
if (!$convert_options['convert_error']) {
$dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
$resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
$quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;
if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
$new_thumb_name = $new_name;
}
}
}
}
if (!$uploaderror) {
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
to
// Uplad thumb file
$new_thumb_name = "";
if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
$new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
if (!$new_thumb_name) {
$msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
@unlink(MEDIA_TEMP_PATH."/".$new_name);
$uploaderror = 1;
}
}
elseif (check_remote_thumb($remote_thumb_file)) {
$new_thumb_name = $remote_thumb_file;
}
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {
if ($direct_upload) {
$src = MEDIA_PATH."/".$cat_id."/".$new_name;
$dest = THUMB_PATH."/".$cat_id."/".$new_name;
}
else {
$src = MEDIA_TEMP_PATH."/".$new_name;
$dest = THUMB_TEMP_PATH."/".$new_name;
}
$do_create = 0;
if ($image_info = @getimagesize($src)) {
if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
$do_create = 1;
}
}
require_once(ROOT_PATH.'includes/image_utils.php');
$convert_options = init_convert_options();
if ($do_create) {
if (!$convert_options['convert_error']) {
$dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
$resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
$quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;
if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
$new_thumb_name = $new_name;
}
}
}
else {
if (Generate_VideoThumb($src, $dest)) {
return true;
}
else {
return false;
}
}
}
if (!$uploaderror) {
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
And It WORKS!! however as you can see from my server logs (and checking on the disk verifies this):
frame= 1 q=1.6 Lsize= 2kB time=0.0 bitrate= 426.6kbits/s
Stream #0.0 -> #0.0
Stream mapping:
Stream #0.0: Video: mjpeg, 352x288, 25.00 fps, q=2-31, 200 kb/s
Output #0, singlejpeg, to './data/thumbnails/4/gymnastics_3.mpg':
Stream #0.1: Audio: mp2, 44100 Hz, stereo, 128 kb/s
Stream #0.0: Video: mpeg1video, 352x288, 25.00 fps
Duration: 00:00:23.4, bitrate: 674 kb/s
Input #0, mpeg, from './data/media/4/gymnastics_3.mpg':
The problem as you can see is that the "$dest" variable i am passing the command has an extension of the file i.e. in this case $dest = "/data/thumbnails/4/gymnastics_3.mpg" and hence ffmpeg created a thumbnail with an mpg extension.
I think the best option would be in my code below:
function Generate_VideoThumb($src, $dest) {
global $convert_options;
$command = "C:\\WINDOWS\\SYSTEM32\\ffmpeg.exe -i ".$src." -f singlejpeg -t 0.001 ".$dest;
system($command);
return (file_exists($dest)) ? 1 : 0;
}
to insert a line of code that replaces the last 3 chars of $dest with "jpg"
Somebody able to help me with this?