It works fine on localhost, but when I upload the script to the server, I get the same error every time I run the script
Apr 8, 2024
11
Level 1
There are no commands defined in the "update" namespace.
Hi, my console script is giving me an error that says:
There are no commands defined in the "update" namespace. {"exception":"[object] (Symfony\Component\Console\Exception\NamespaceNotFoundException(code: 0): There are no commands defined in the \"update\" namespace. at /var/www/faketube_cz/FakeTube/vendor/symfony/console/Application.php:669)
[stacktrace]
#0 /var/www/faketube_cz/FakeTube/vendor/symfony/console/Application.php(720): Symfony\Component\Console\Application->findNamespace()
#1 /var/www/faketube_cz/FakeTube/vendor/symfony/console/Application.php(266): Symfony\Component\Console\Application->find()
#2 /var/www/faketube_cz/FakeTube/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
#3 /var/www/faketube_cz/FakeTube/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\Component\Console\Application->run()
#4 /var/www/faketube_cz/FakeTube/artisan(35): Illuminate\Foundation\Console\Kernel->handle()
#5 {main}
"}
There is my code (text is in Czech):
<?php
namespace App\Console\Commands;
use App\Models\Video;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use ProtoneMedia\LaravelFFMpeg\Exporters\HLSExporter;
use Illuminate\Support\Facades\Log;
use FFMpeg\Filters\Video\PadFilter;
use FFMpeg\Coordinate\Dimension;
use function League\Flysystem\Local\filesize;
class ZpracujVideo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:zpracuj-video';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Zpracuje čekající videa';
/**
* Execute the console command.
*/
public function handle()
{
try {
Log::info('Příkaz zpracování videa byl spuštěn.');
$ffmpeg = \FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
));
$ffprobe = \FFMpeg\FFProbe::create();
// Zde načtěte videa, která mají stav_zpracovani "in_queue"
$videos = Video::where('stav_zpracovani', 'in_queue')->get();
if (!$videos->isEmpty()) {
foreach ($videos as $video) {
Log::info('Zpracovávám video ' . $video->nazev);
if (!is_dir(storage_path('app/public/videos/' . $video->video_id))) {
mkdir(storage_path('app/public/videos/' . $video->video_id), 0777, true);
}
$filePath = storage_path('app/public/videos/') . $video->nazev_souboru;
Log::info("Cesta ke zpracovávanému souboru: " . $filePath);
$media = $ffmpeg->open($filePath);
$duration = $ffprobe->format($filePath)->get('duration');
$durationFormatted = gmdate('i:s', $duration);
$dimensions = $ffprobe->streams($filePath)->videos()->first()->getDimensions();
$width = $dimensions->getWidth();
$height = $dimensions->getHeight();
$container = $ffprobe->streams($filePath)->videos()->first()->get('format_name');
$bitrate = $ffprobe->streams($filePath)->videos()->first()->get('bit_rate');
$format = new \FFMpeg\Format\Video\X264('aac', 'libx264');
$format->setKiloBitrate(1000);
// Upravit náhledový snímek pro video na výšku s černým okolím
if ($height > $width) {
$padFilter = new PadFilter(
new Dimension($width, $height),
null,
null,
null,
'#000000'
);
$media->addFilter($padFilter);
}
// Vytvoření náhledového snímku v rozlišení 1280x720
$frameMaxRes = $media->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(1));
$frameMaxRes->save(storage_path('app/public/videos/' . $video->video_id) . '/maxresdefault.jpg');
// uložení videa
$media->save($format, storage_path('app/public/videos/' . $video->video_id) . '/index.mp4');
$video->container = mime_content_type($filePath);
$video->velikost_souboru = Storage::size('public\videos\' . $video->nazev_souboru);
$video->delka_ms = $duration * 1000;
$video->bitrate_bps = $bitrate;
$video->chyby_zpracovani = json_encode([]);
$video->varovani_zpracovani = json_encode([]);
$video->napovedy_zpracovani = json_encode([]);
$video->video_streams = json_encode([$container]);
$video->audio_streams = json_encode([]);
$video->naplanovany_konec = date('Y-m-d H:i:s', strtotime($video->skutecny_start) + ($duration * 1000) / 1000);
$video->skutecny_konec = date('Y-m-d H:i:s', strtotime($video->skutecny_start) + ($duration * 1000) / 1000);
$video->delka = $durationFormatted;
$video->rozmery = $width . "x" . $height;
$video->kvalita = $video->rozmery >= '1280x720' ? 'hd' : 'sd';
$video->stav_zpracovani = "succeeded";
if ($video->save()) {
Log::info('Video zpracováno');
} else {
Log::warning('Uložení videa se nezdařilo');
}
}
} else {
Log::info('Nebylo nalezeno žádné video čekající na zpracování (in_queue)');
}
Log::info('Zpracování videí bylo dokončeno');
} catch (\Exception $e) {
Log::error('Chyba při zpracování videí: ' . $e->getMessage());
}
}
}
But I don't know where the problem is (after 2 days of searching). Can anyone help me find where the problem is?
Level 1
I modified the script to a different form specifically for Laravel FFMpeg and not just for PHP FFMpeg and it works now.
Although I didn't find out why it was writing an error and not working before, but now it works. So hopefully it will work for a long time
Please or to participate in this conversation.