I was wondering how I can write metadata/properties (comments specifically and other information) to a video file (mainly .mp4), using PHP.
Here is my function that I use to download a remote file ($sourceURL) to a local destination ($destinationURL). I am able to rename the file with the $destinationURL (just end it with /video.mp4). I am currently using cURL, but if it can only be done by something like fopen()/fwrite(), then I am open to suggestions :)
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;
}
}
What I have tried:
Changing the tag format to "id3v1" doesn't work either.
If I'm not mistaken, the tag format's "id3v2.3" and "id3v1" only work with .mp3 files.
Thank you so much for your time and I look forward to any comments/answers I may receive.
Kind Regards
Joshua Lochner
You can use ffmpeg
to extract/add metadata from/to videos, i.e.:
To Extract:
ffmpeg -i video.mp4 -f video_metadata.txt
To Add:
ffmpeg -i video.mp4 -metadata title="my title" video_metadata.mp4
ffmpeg
documentation