Hi all

I open this issue because I can't get auto generated thumbnails.. Searching a reason I found this :

Filenames of thumbnails are generated with a question mark at the end : .jpg?

This question mark is not visible in my ftp client.
So I can suppose that generated thumbs are OK while I use FTP...
But there are not usable... There is no way to open or move them and I get an issue in the log for the rest of processing thumbs...

BUT ... connecting in ssh the question mark is clearly visible :
Files are named like this : video-thumb-for-XXXX-X.jpg?
if I remove the question mark with mv the file can be edited and the thumb looks fine...

If somedody has a solution...

Comments

hypertext200’s picture

public function run_command($options) {
//    $command = $this->nice . ' ' . $this->params['cmd_path'] . ' ' . $options . '  2>&1';
    $command = $this->nice . ' ' . $options . '  2>&1';
    watchdog('video_ffmpeg', 'Executing command: ' . $command, array(), WATCHDOG_DEBUG);
    ob_start();
    passthru($command, $command_return);
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
  }

  public function generate_thumbnails($video) {
    global $user;
    // Setup our thmbnail path.
    $video_thumb_path = variable_get('video_thumb_path', 'video_thumbs');
    $final_thumb_path = file_directory_path() . '/' . $video_thumb_path . '/' . $video['fid'];

    // Ensure the destination directory exists and is writable.
    $directories = explode('/', $final_thumb_path);
    // Get the file system directory.
    $file_system = file_directory_path();
    foreach ($directories as $directory) {
      $full_path = isset($full_path) ? $full_path . '/' . $directory : $directory;
      // Don't check directories outside the file system path.
      if (strpos($full_path, $file_system) === 0) {
        field_file_check_directory($full_path, FILE_CREATE_DIRECTORY);
      }
    }

    // Total thumbs to generate
    $total_thumbs = variable_get('video_thumbs', 5);
    $videofile = escapeshellarg($video['filepath']);
    //get the playtime from the current transcoder
    $duration = $this->get_playtime($video['filepath']);

    $files = NULL;
    for ($i = 1; $i <= $total_thumbs; $i++) {
      $seek = ($duration / $total_thumbs) * $i - 1;  //adding minus one to prevent seek times equaling the last second of the video
      $filename = "/video-thumb-for-" . $video['fid'] . "-$i.jpg";
      $thumbfile = $final_thumb_path . $filename;
      //skip files already exists, this will save ffmpeg traffic
      if (!is_file($thumbfile)) {
        //setup the command to be passed to the transcoder.
        $options = $this->params['cmd_path'] . ' ' . t($this->params['thumb_command'], array('!videofile' => $videofile, '!seek' => $seek, '!thumbfile' => $thumbfile));
        // Generate the thumbnail from the video.
        $command_output = $this->run_command($options);
        if (!file_exists($thumbfile)) {
          $error_param = array('%file' => $thumbfile, '%cmd' => $options, '%out' => $command_output);
          $error_msg = t("Error generating thumbnail for video: generated file %file does not exist.<br />Command Executed:<br />%cmd<br />Command Output:<br />%out", $error_param);
          // Log the error message.
          watchdog('video_transcoder', $error_msg, array(), WATCHDOG_ERROR);
          continue;
        }
      }
      // Begin building the file object.
      // @TODO : use file_munge_filename()
      $file = new stdClass();
      $file->uid = $user->uid;
      $file->status = FILE_STATUS_TEMPORARY;
      $file->filename = trim($filename);
      $file->filepath = $thumbfile;
      $file->filemime = file_get_mimetype($filename);
      $file->filesize = filesize($thumbfile);
      $file->timestamp = time();
      $files[] = $file;
    }
    return $files;
  }

Here where the actual code to generate Thumbnails using FFMPEG, as far as I can see code is clean and working fine for me.

Can you please reset FFMPEG transcoder settings and try again?

joran lafleuriel’s picture

Hi heshan.lk

Thanks for your precious help and sorry for the delay.

I found the answer with your help and more google search about unix bad file names.
I learn that the question mark in in fact a gremlin character.
Using a ls -b unix command, the question mark is displayed as it really is : \r [ anti-slash r ]
A single carriage return character.

But who did put this return character ?
-> me

I put it while editing the video thumbs generation command line
in /admin/settings/video/transcoders > section > Video Thumbnails

You may had a filter to this input...for stupid newbies like me ! ;-)
Arrgghh !! I can't believe that I couldnt find it before !

Thank you very much for your module ! Very powerfull !

joran lafleuriel’s picture

Status: Active » Closed (fixed)