gpt4 book ai didi

php - 将属性/元数据(评论、标题等)写入视频 (PHP/cURL)

转载 作者:行者123 更新时间:2023-12-02 06:03:25 25 4
gpt4 key购买 nike

我想知道如何使用 PHP 将元数据/属性(具体注释和其他信息)写入视频文件(主要是 .mp4)。

Properties/metadata of a video file - Windows

这是我用来将远程文件 ($sourceURL) 下载到本地目标 ($destinationURL) 的函数。我可以使用 $destinationURL 重命名该文件(只需以/video.mp4 结尾)。我目前正在使用 cURL,但如果它只能通过 fopen()/fwrite() 之类的方法来完成,那么我愿意接受建议:)

function downloadFile( $sourceURL, $destinationURL ) {
$options = array(
CURLOPT_FILE => is_resource( $destinationURL ) ? $destinationURL : fopen( $destinationURL, 'w' ),
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_URL => $sourceURL,
CURLOPT_FAILONERROR => true,
);

$ch = curl_init();
curl_setopt_array( $ch, $options );
$return = curl_exec( $ch );

if ( $return === false ) {
return curl_error( $ch );
} else {
return true;
}
}
<小时/>

我尝试过的:

  1. getID3(): http://getid3.sourceforge.net/也许我遗漏了一些东西,但是当我尝试写入 mp4 文件时,它给了我这个错误:

Error message from getID3 - 1

将标记格式更改为“id3v1”也不起作用。

Error message from getID3 - 2

如果我没记错的话,标签格式“id3v2.3”和“id3v1”仅适用于 .mp3 文件。

  • 回答来自:writing exif data in php - 这些似乎只适用于图像文件
  • <小时/>

    非常感谢您抽出宝贵的时间,我期待收到任何评论/答复。

    亲切的问候

    约书亚·洛克纳

    最佳答案

    您可以使用ffmpeg从视频中提取/添加元数据,即:

    提取:

    ffmpeg -i video.mp4 -f video_metadata.txt 

    添加:

    ffmpeg -i video.mp4 -metadata title="my title" video_metadata.mp4
    <小时/>

    ffmpeg documentation

    关于php - 将属性/元数据(评论、标题等)写入视频 (PHP/cURL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52816497/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com