You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在CodeIgniter中使用FFmpeg生成视频缩略图时遇符号查找错误

Fixing FFmpeg Thumbnail Generation Error in CodeIgniter

Hey there, let's break down your problem into two key parts: resolving the libass symbol lookup error, and fixing the issues in your CodeIgniter code.

1. Fixing the FT_Outline_EmboldenXY Undefined Symbol Error

This error pops up because your libass.so.5 library is trying to access a function that either doesn't exist in your system's installed FreeType version, or there's a broken link between the libraries. Here's how to fix it:

  • Reinstall dependent libraries
    First, refresh your package lists and reinstall FreeType and libass to ensure they're properly linked and up-to-date:

    sudo apt update && sudo apt install --reinstall libfreetype6 libass5
    
  • Verify library dependencies
    You already ran ldd -r /usr/lib/x86_64-linux-gnu/libass.so.5 — check the output for any other undefined symbols tied to FreeType. To confirm exactly which FreeType library libass is using, run:

    ldd /usr/lib/x86_64-linux-gnu/libass.so.5 | grep freetype
    

    If it points to an outdated or non-system FreeType version, you’ll need to update FreeType to a release that supports FT_Outline_EmboldenXY (this function was added in FreeType 2.10.0+). If you compiled libass manually, recompile it against your system’s current FreeType library.

  • Test FFmpeg directly in the terminal
    Run ffmpeg -version to see if the error occurs outside your CodeIgniter code. If it does, the problem is system-wide — resolve the library issue first before debugging your application code.

2. Fixing Your CodeIgniter FFmpeg Execution

Your current code has a few critical issues that will block it from working even after fixing the library error:

  • Wrong FFmpeg path: You’re using /tagittty/ffmpeg.exe — this is a Windows executable path, but your server runs Linux. Run which ffmpeg on your server to get the correct path (usually /usr/bin/ffmpeg).
  • Incorrect video file path: You’re using $_FILES['userFile']['name'], which is the original filename from the user’s computer. The uploaded video lives on your server at $videoData['full_path'] (provided by CodeIgniter’s upload library).
  • Missing space after -i: Your command has -i' . $videoFile, which merges -i with the filename and breaks FFmpeg’s parsing.
  • Unescaped filenames: If the video has spaces or special characters, your command will fail. Use escapeshellarg() to safely escape file paths.
  • Output path permissions: Ensure your output file is saved to a directory with write permissions (using the upload directory from $videoData['file_path'] is a safe, reliable choice).

Corrected Code Example

if ($this->upload->do_upload('userFile')) {
    $videoData = $this->upload->data();
    
    // Full path to the uploaded video on your server
    $videoPath = $videoData['full_path'];
    // Path to save the thumbnail (inside the same upload directory)
    $thumbnailPath = $videoData['file_path'] . 'thumbnail_' . $videoData['raw_name'] . '.jpeg';
    
    // Get the correct FFmpeg path from your server (run `which ffmpeg` to confirm)
    $ffmpegPath = '/usr/bin/ffmpeg';
    
    // Build the FFmpeg command with safely escaped paths
    $command = sprintf(
        '%s -i %s -r 1 -ss 00:00:50 -vf scale=1024:-1 -vframes 1 %s 2>&1',
        escapeshellarg($ffmpegPath),
        escapeshellarg($videoPath),
        escapeshellarg($thumbnailPath)
    );
    
    // Execute the command and capture output/return code
    exec($command, $output, $returnCode);
    
    // Debug output
    echo "<pre>";
    echo "Executed Command: " . $command . "\n\n";
    echo "Return Code: " . $returnCode . "\n\n";
    echo "Output:\n";
    print_r($output);
    echo "</pre>";
    die();
}

3. Final Checks

After fixing the library issue and updating your code:

  1. Run the CodeIgniter script again and check the debug output. A return code of 0 means FFmpeg executed successfully.
  2. Verify the thumbnail file exists at the path you specified.
  3. If you still get errors, scan the FFmpeg output for specific issues (e.g., unsupported video codec, invalid timestamp for -ss).

内容的提问来源于stack exchange,提问作者Mr. Pyramid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:46:16