if(!empty($fullnewname)) { // gif to video conversion using ffmpeg for smaller filesizes $video_url_sql = ''; if (function_exists('shell_exec')) { // Force a file path search using "type". // "which" may be empty if you not modified $PATH // Returns filepath for ffmpeg, just some safecheck since ffmpeg alone may not always work on every system $ffmpeg_path = trim(shell_exec('type -P ffmpeg')); if (!empty($ffmpeg_path)) { // We can convert gif. Png aint possible due transparency, jpg possible but many color jpg's get blurry due mp4 max 258 colors or so if ($extension == 'gif') { // Get the filename without extension // Based on $upload_mode, $newname can be different names $ffmpeg_image = basename($newname, ".{$extension}"); // mp4 url $ffmpeg_mp4_url = "{$CONF['list_url']}/images/users/mp4/{$ffmpeg_image}.mp4"; $video_url_sql = $DB->escape($ffmpeg_mp4_url, 1); $video_url_sql = ", mp4_url = '{$video_url_sql}'"; // actual convert command // (-y) - Disable confirm promts when overwriting files // (-movflags faststart) - Make video playable and load quicker under html5 // (-pix_fmt yuv420p) - Set pixel format. H.264 video is safe across browsers. If not available -pix_fmt auto picks best value for encoder in use // (-preset veryslow) - Longer convert time, but better compression // (-vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2') - MP4 videos using H.264 need to have a dimensions that is divisible by 2. This option ensures that's the case for the filtergraph frame conversion // (/dev/null 2>&1) - Redirect stdin/stdout/stderr into nothingness and make it a background process shell_exec("{$ffmpeg_path} -y -i \"{$CONF['path']}/images/users/{$ffmpeg_image}.{$extension}\" -movflags faststart -pix_fmt yuv420p -preset veryslow -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' \"{$CONF['path']}/images/users/mp4/{$ffmpeg_image}.mp4\" /dev/null 2>&1"); } } } $DB->query("UPDATE {$CONF['sql_prefix']}_sites SET banner_url = '{$fullnewname}', banner_width = {$banner_width}, banner_height = {$banner_height} {$video_url_sql} WHERE username = '{$TMPL['username']}'", __FILE__, __LINE__); } if(!empty($avatar_url)) { $DB->query("UPDATE {$CONF['sql_prefix']}_sites SET avatar_url = '{$avatar_url}', avatar_width = {$avatar_width}, avatar_height = {$avatar_height} WHERE username = '{$TMPL['username']}'", __FILE__, __LINE__); }