プロジェクトでオーディオ データに取り組んでおり、mp3 ファイルの ID3 タグを書き込む必要がありますが、getId3 パッケージの WriteTags() を呼び出すとこのエラーが発生します。このパッケージを使用して id3 タグを書き込んでいます。誰もがそれを修正する方法について何らかの考えを持っています。
コードでこの出力を取得しています。
filepath : D:/xampp/htdocs/l8/public/storage/songs/newmp3.mp3
Failed to write tags!
Tag format "id3v2" is not allowed on "" files
私のmp3ファイルは変更されていません。
私のコントローラは次のようになります
<?php
namespace App\Http\Controllers\Artist;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use App\Models\Track;
use GetId3\GetId3Core as GetId3;
use GetId3\Lib\Helper;
use GetId3\Write\Tags;
class TrackController extends Controller
{
function test(Request $request) {
$getID3 = new GetId3();
$TaggingFormat = 'UTF-8';
$getID3->setOption(array('encoding' => $TaggingFormat));
$tagwriter = new Tags();
$tagwriter->filename = public_path('storage/songs/newmp3.mp3');
$tagwriter->filename = str_replace('\\', '/', $tagwriter->filename);
echo "filepath : " . $tagwriter->filename."<br>";
$tagwriter->tagformats = array('id3v2');
$tagwriter->overwrite_tags = true;
$tagwriter->overwrite_tags = false;
$tagwriter->tag_encoding = $TaggingFormat;
$tagwriter->remove_other_tags = true;
// populate data array
$TagData = array(
'title' => array('My Song'),
'artist' => array('The Artist'),
'album' => array('Greatest Hits'),
'year' => array('2004'),
'genre' => array('Rock'),
'comment' => array('excellent!'),
'track' => array('04/16'),
);
$tagwriter->tag_data = $TagData;
if ($tagwriter->WriteTags()) {
echo 'Successfully wrote tags<br>';
if (!empty($tagwriter->warnings)) {
echo 'There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings);
}
} else {
echo 'Failed to write tags!<br>'.implode('<br><br>', $tagwriter->errors);
}
}
}
どんな助けでも大歓迎です。