我已經從我的 iPhone 上傳了我的圖片和電影到我的 CentOS 網路服務器,現在我想在我的主頁上顯示它們(我希望它們在本地托管 - 而不是通過 iCloud)。圖片沒問題,因為我可以通過 訪問他們的資料exif,但電影檔案似乎并不那么容易。
我的服務器是帶有Apache的CentOS ,我使用的是PHP 8.1,現在我計劃只包含來自我的 iPhone 的東西,但當然可以預期我稍后也會從其他相機上傳。
我需要方向的原因是我將把它封裝到Bootstrap 4.6中,讓它自動回應。我會做的:
橫向電影格式(注意16by9):
<div class='embed-responsive embed-responsive-16by9'>
<video poster='mythumbnail.jpg' controls preload='metadata'>
<source src='mymovie.mov' type='video/mp4' />
<span style='background-color:red;color:white;'>(your browser cannot show this video)</span>
</video>
</div>
人像影片格式(注意9by16):
<div class='embed-responsive embed-responsive-9by16'>
<video poster='mythumbnail.jpg' controls preload='metadata'>
<source src='mymovie.mov' type='video/mp4' />
<span style='background-color:red;color:white;'>(your browser cannot show this video)</span>
</video>
</div>
有沒有人有關于如何從MOV檔案中獲取方向的好主意?:-)
uj5u.com熱心網友回復:
直到有人提供更好和理想的原生 PHP 解決方案,然后我會根據@CBroe 的評論接受這個答案。
PHP 不容易提供查詢視頻檔案以獲取元資料的可能性,但CentOS(和其他 Linux 發行版)內部可能正在使用該mediainfo應用程式,該應用程式將能夠查詢大量檔案的媒體型別和一些元資料。資訊。這適用于圖片、視頻和音頻檔案,但也適用于 PDF 檔案和其他檔案。
要從 PHP 執行此操作,然后可以使用exec - 還要確保使用escapeshellarg轉義命令引數,以使其對 shell 安全:
$param = escapeshellarg("myfile.mov"); // make sure the argument is safe to pass
exec("mediainfo $param", $outputArray); // store line-by-line output in an array
將mediainfo給出類似這樣的輸出,并且此處的每一行都將位于$outputArray陣列變數中:
Array
(
[0] => General
[1] => Complete name : /myfolder/MVI_0447.mov
[2] => Format : MPEG-4
[3] => Format profile : QuickTime
[4] => Codec ID : qt 2007.09 (qt /CAEP)
[5] => File size : 163 MiB
[6] => Duration : 1 min 4 s
[7] => Overall bit rate : 21.1 Mb/s
[8] => Encoded date : UTC 2014-08-10 15:32:22
[9] => Tagged date : UTC 2014-08-10 15:32:22
[10] => CNTH : ?^P??#?k??T???o?2p com.apple.quicktime.make : Canon
[12] => com.apple.quicktime.model : Canon IXUS 135
[13] => com.apple.quicktime.rating.user : 0.000
[14] =>
[15] => Video
[16] => ID : 1
[17] => Format : AVC
[18] => Format/Info : Advanced Video Codec
[19] => Format profile : Baseline@L4.1
[20] => Format settings : 1 Ref Frames
[21] => Format settings, CABAC : No
[22] => Format settings, Reference frames : 1 frame
[23] => Format settings, GOP : M=1, N=12
[24] => Codec ID : avc1
[25] => Codec ID/Info : Advanced Video Coding
[26] => Duration : 1 min 4 s
[27] => Bit rate : 19.5 Mb/s
[28] => Width : 1 280 pixels
[29] => Height : 720 pixels
[30] => Display aspect ratio : 16:9
[31] => Frame rate mode : Constant
[32] => Frame rate : 25.000 FPS
[33] => Color space : YUV
[34] => Chroma subsampling : 4:2:0
[35] => Bit depth : 8 bits
[36] => Scan type : Progressive
[37] => Bits/(Pixel*Frame) : 0.848
[38] => Stream size : 151 MiB (93%)
[39] => Language : English
[40] => Encoded date : UTC 2014-08-10 15:32:22
[41] => Tagged date : UTC 2014-08-10 15:32:22
[42] => Color range : Full
[43] => Color primaries : BT.709
[44] => Transfer characteristics : BT.709
[45] => Matrix coefficients : BT.601
[46] => Codec configuration box : avcC
[47] =>
[48] => Audio
[49] => ID : 2
[50] => Format : PCM
[51] => Format settings : Little / Signed
[52] => Codec ID : sowt
[53] => Duration : 1 min 4 s
[54] => Bit rate mode : Constant
[55] => Bit rate : 1 536 kb/s
[56] => Channel(s) : 2 channels
[57] => Channel layout : L R
[58] => Sampling rate : 48.0 kHz
[59] => Bit depth : 16 bits
[60] => Stream size : 11.9 MiB (7%)
[61] => Language : English
[62] => Encoded date : UTC 2014-08-10 15:32:22
[63] => Tagged date : UTC 2014-08-10 15:32:22
[64] =>
[65] =>
)
然后,您可以解釋-并在使用各種相機源或媒體時處理不良元資料的多種可能性:-)例如,對于圖片檔案,我僅mediainfo用于確定它是圖片檔案,然后我通過exif_read_data傳遞資料,因為這更詳細。
不過有一個小提示 - 對于我的特定設定,丹麥國家字符似乎exec存在一些問題,因為它無法讀取內部包含這些字符的檔案。我希望這與某些字符編碼問題有關,但從未想過 - 查看PHP“exec”無法訪問具有丹麥國家字符的檔案名?詳情。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/507472.html
