pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<tfoot id='RNCmm'></tfoot>
    <bdo id='RNCmm'></bdo><ul id='RNCmm'></ul>
  • <i id='RNCmm'><tr id='RNCmm'><dt id='RNCmm'><q id='RNCmm'><span id='RNCmm'><b id='RNCmm'><form id='RNCmm'><ins id='RNCmm'></ins><ul id='RNCmm'></ul><sub id='RNCmm'></sub></form><legend id='RNCmm'></legend><bdo id='RNCmm'><pre id='RNCmm'><center id='RNCmm'></center></pre></bdo></b><th id='RNCmm'></th></span></q></dt></tr></i><div class="zsrxzpz" id='RNCmm'><tfoot id='RNCmm'></tfoot><dl id='RNCmm'><fieldset id='RNCmm'></fieldset></dl></div>

      <legend id='RNCmm'><style id='RNCmm'><dir id='RNCmm'><q id='RNCmm'></q></dir></style></legend>

      <small id='RNCmm'></small><noframes id='RNCmm'>

        查詢音頻/視頻文件的信息

        Querying an audio/video file for information(查詢音頻/視頻文件的信息)

          <tfoot id='P3mfa'></tfoot>
        • <small id='P3mfa'></small><noframes id='P3mfa'>

          • <legend id='P3mfa'><style id='P3mfa'><dir id='P3mfa'><q id='P3mfa'></q></dir></style></legend>

                <bdo id='P3mfa'></bdo><ul id='P3mfa'></ul>

                    <tbody id='P3mfa'></tbody>
                1. <i id='P3mfa'><tr id='P3mfa'><dt id='P3mfa'><q id='P3mfa'><span id='P3mfa'><b id='P3mfa'><form id='P3mfa'><ins id='P3mfa'></ins><ul id='P3mfa'></ul><sub id='P3mfa'></sub></form><legend id='P3mfa'></legend><bdo id='P3mfa'><pre id='P3mfa'><center id='P3mfa'></center></pre></bdo></b><th id='P3mfa'></th></span></q></dt></tr></i><div class="33wbxvj" id='P3mfa'><tfoot id='P3mfa'></tfoot><dl id='P3mfa'><fieldset id='P3mfa'></fieldset></dl></div>
                  本文介紹了查詢音頻/視頻文件的信息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想要一個 PHP 函數,它接收文件的路徑并返回有關它的信息數組.PHP文件可以調用FFmpeg.

                  I want a PHP function which receives the path to a file and returns an array of information about it. The PHP file can call FFmpeg.

                  返回的數據應該類似于

                  Array(
                      [mime]          => video/ogg
                      [container]     => Ogg
                      [video]         => Theora
                      [audio]         => Vorbis
                      [duration]      => 20.3 // in seconds
                  )
                  
                  Array(
                      [mime]          => audio/ogg
                      [container]     => Ogg
                      [video]         =>
                      [audio]         => FLAC
                      [duration]      => 3
                  )
                  
                  Array(
                      [mime]          => image/gif
                      [container]     => GIF
                      [video]         => Animated GIF
                      [audio]         =>
                      [duration]      => 2
                  )
                  
                  Array(
                      [mime]          => video/webm
                      [container]     => WebM
                      [video]         => VP8
                      [audio]         => Vorbis
                      [duration]      => 900.7
                  )
                  
                  false // not a media file
                  

                  我從未使用過 FFmpeg 或 PHP 的 shell_exec() 函數,但似乎 FFmpeg 會以一種相當難以解析的格式提供有關視頻(或音頻文件)的信息.不過,我認為這樣的事情是可能的.

                  I've never worked with FFmpeg or with PHP's shell_exec() function, but it seems that FFmpeg will give information about videos (or audio files) in a fairly hard-to-parse format. I assume that something like this is possible, though.

                  推薦答案

                  FFmpeg 幾乎可以做您想做的一切,但您說得對,它幾乎無法解析格式.如果您在基于 UNIX 的系統上使用操作系統和 FFmpeg 的功能進行解析,而不是讓 PHP 嘗試理解輸出,那么實際上會更快.幾個月前,我出于類似目的開發了以下 shell 命令.

                  FFmpeg can do just about everything you want, but you're correct that it's in a nearly impossible to parse format. It's actually quicker if you're on a UNIX-based system to use the Operating System and the features of FFmpeg to do the parsing rather than have PHP try to understand the output. I developed the following shell command several months ago for a similar purpose.

                  fulltime=`ffmpeg -i MOVIE.AVI 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//`;hour=`echo $fulltime | cut -d ':' -f 1`;minute=`echo $fulltime | cut -d ':' -f 2`;second=`echo $fulltime | cut -d ':' -f 3 | cut -d '.' -f 1`;echo `expr 3600 * $hour + 60 * $minute + $second`
                  

                  管道 (|) 告訴 UNIX 將前一個命令的輸出作為輸入傳遞給下一個命令.分號 (;) 告訴 UNIX 開始一個新命令.UNIX shell 還允許動態創建變量.要創建變量,您只需說var=value.要調用此變量,您必須使用美元符號,例如 $var.

                  The pipe (|) tells UNIX to pass the output of the previous command as the input to the next command. The semi-colon (;) tells UNIX to begin a new command. The UNIX shell also allows for on-the-fly variable creation. To create a variable you just say var=value. To recall this variable you must use a dollar-sign, such as $var.

                  我的命令基本上采用 ffmpeg -i MOVIE.AVI 2>&1 | 的輸出grep '持續時間' |剪切 -d ' ' -f 4 |sed s/,// 并將其存儲為 fulltime.此命令進一步細分:

                  My command essentially takes the output of ffmpeg -i MOVIE.AVI 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,// and stores it as fulltime. This command is further broken down:

                  ffmpeg -i MOVIE.AVI 2>&1 表示顯示 MOVIE.AVI 的信息(-i).2>&1 我相信將輸出重定向到管道而不是屏幕(這是很久以前做的,所以我不清楚)

                  ffmpeg -i MOVIE.AVI 2>&1 means to display info (-i) for MOVIE.AVI. The 2>&1 I believe redirected the output to a pipe rather than to the screen (made this forever ago, so I'm not clear on that)

                  grep 'Duration' 將獲取輸入(這是 ffmpeg -i MOVIE.AVI 2>&1 的輸出),找到單詞 'Duration', 并僅輸出包含該單詞的行.

                  grep 'Duration' will take the input (which was the output of ffmpeg -i MOVIE.AVI 2>&1), find the word 'Duration', and output only the line that contained that word.

                  cut -d ' ' -f 4 將獲取輸入(前一條語句的輸出),在每個空格處將其拆分(' '),然后只輸出其中的第四個.這是因為 FFmpeg 的輸出看起來像:

                  cut -d ' ' -f 4 will take the input (the output of the previous statement), split it up at every space (' '), and output only the fourth of these. This is because the output of FFmpeg looks something like:

                  MOVIE.AVI
                  video encoder, yada yada
                  audio encoder, yada yada
                  bitrates and stuff
                  Duration: hh:mm:ss fulltime: 00:30:00.1
                  

                  換句話說,包含持續時間"的行的第四個部分"是實際持續時間……以小時、分鐘和秒為單位(保留 1 個小數位).

                  In other words, the fourth "section" of the line containing "Duration" is the actual duration... In hours, minutes, and seconds (with 1 decimal place).

                  sed s/,// 表示將 ',' 替換為空.這可能是有充分理由的.

                  sed s/,// means to replace ',' with nothing. There was probably a good reason for this.

                  在此之后,我創建了三個變量 hourminutesecond:

                  After this I created the three variables hour, minute, and second:

                  hour=`echo $fulltime | cut -d ':' -f 1`;
                  minute=`echo $fulltime | cut -d ':' -f 2`;
                  second=`echo $fulltime | cut -d ':' -f 3 | cut -d '.' -f 1`;
                  

                  請注意,我正在為 echo $fulltime | 的輸出設置小時.cut -d ':' -f 1.如果我要在每個冒號(:)

                  Notice that I'm setting hour to the output of echo $fulltime | cut -d ':' -f 1. Grabbing the first portion if I were to split the time at every colon (:)

                  我對分鐘做了類似的處理,然后我對秒做同樣的處理,只是在最后去掉了任何小數點.如果您在 shell 中工作,則必須刪除這個小數點,因為 expr 命令(我曾經用它從小時、分鐘和秒計算秒)只執行整數數學運算.如果您希望在持續時間內保留小數,此時您必須將小時、分鐘和秒返回給 PHP 并在那里進行解析.將以上內容替換為:

                  I do similar with minutes, then I do the same with seconds only I chop off any decimal at the end. This decimal has to be removed if you're working in shell since the expr command (which I used to calculate seconds from hours, minutes, and seconds) only performs integer math. If you wish to keep the decimal for duration, you will at this point have to return the hours, minutes, and seconds to PHP and do the parsing there. This would be most easily done by replacing the above with:

                  echo $fulltime
                  

                  這將在您調用 shell_exec() 后向 PHP 返回一個字符串,例如00:30:00.1",然后您可以使用 explode(':',$string).

                  This will return a string such as "00:30:00.1" to PHP after you have called shell_exec(), which you can then easily parse using explode(':',$string).

                  繼續直接從 shell 獲取秒數:

                  To continue with getting the seconds directly from shell:

                  在得到小時、分鐘和秒后,出現了神奇的一行:

                  After getting the hours, minutes, and seconds came the magical line:

                  echo `expr 3600 * $hour + 60 * $minute + $second`
                  

                  expr 命令表示執行數學表達式.不幸的是,它相當愚蠢.首先,需要對特殊字符進行轉義(* 在 UNIX 中是通配符,因此必須使用 * 表示乘法).接下來,它只執行整數數學.如您所見,將小時乘以 3600,分鐘乘以 60,然后將它們加在一起是相當容易的.

                  The expr command says to perform a mathematical expression. Unfortunately it's rather stupid. First, special characters need to be escaped (* is a wildcard in UNIX, so you have to use * to mean multiply). Next, it only performs integer math. It was fairly easy, as you can see, to multiply hours by 3600, minutes by 60, and add them all together.

                  整個龐大命令的輸出將只是一個數字.視頻持續的秒數.它應該適用于所有視頻格式.

                  The output of this entire, massive command, will just be a single number. The number of seconds that the video lasts. It should work for all video formats.

                  請注意,這只是持續時間.至于視頻編碼器和音頻編碼器,您可能希望使用類似的方法,最后減去數學運算.一個通用的解決方案是:

                  Mind you this is just duration. As for video encoder and audio encoder you would want to use similar methods, minus the math at the end. A generic solution would be:

                  ffmpeg -i MOVIE.AVI 2>&1 | grep 'Something unique to the line you want' | cut -d ' ' -f <the "section" you want>
                  

                  這個輸出可以繼續在 shell 中解析(就像我在上面所做的那樣)或者它可以傳遞給 PHP.

                  The output of this can either continue to be parsed in shell (as I did above with the time) or it can be passed to PHP.

                  這篇關于查詢音頻/視頻文件的信息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                      <tbody id='1jUpO'></tbody>

                    1. <legend id='1jUpO'><style id='1jUpO'><dir id='1jUpO'><q id='1jUpO'></q></dir></style></legend>

                      • <small id='1jUpO'></small><noframes id='1jUpO'>

                          <bdo id='1jUpO'></bdo><ul id='1jUpO'></ul>
                          <i id='1jUpO'><tr id='1jUpO'><dt id='1jUpO'><q id='1jUpO'><span id='1jUpO'><b id='1jUpO'><form id='1jUpO'><ins id='1jUpO'></ins><ul id='1jUpO'></ul><sub id='1jUpO'></sub></form><legend id='1jUpO'></legend><bdo id='1jUpO'><pre id='1jUpO'><center id='1jUpO'></center></pre></bdo></b><th id='1jUpO'></th></span></q></dt></tr></i><div class="xmevce7" id='1jUpO'><tfoot id='1jUpO'></tfoot><dl id='1jUpO'><fieldset id='1jUpO'></fieldset></dl></div>
                            <tfoot id='1jUpO'></tfoot>
                            主站蜘蛛池模板: 圣才学习网-考研考证学习平台,提供万种考研考证电子书、题库、视频课程等考试资料 | elisa试剂盒-PCR试剂盒「上海谷研实业有限公司」 | 韦伯电梯有限公司| VI设计-LOGO设计公司-品牌设计公司-包装设计公司-导视设计-杭州易象设计 | 智慧食堂_食堂管理系统_食堂订餐_食堂消费系统—客易捷 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | 北京亦庄厂房出租_经开区产业园招商信息平台 | 德国UST优斯特氢气检漏仪-德国舒赐乙烷检测仪-北京泽钏 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 假肢-假肢价格-假肢厂家-河南假肢-郑州市力康假肢矫形器有限公司 | 二手光谱仪维修-德国OBLF光谱仪|进口斯派克光谱仪-热电ARL光谱仪-意大利GNR光谱仪-永晖检测 | BESWICK球阀,BESWICK接头,BURKERT膜片阀,美国SEL继电器-东莞市广联自动化科技有限公司 | 今日扫码_溯源二维码_产品防伪一物一码_红包墙营销方案 | 深圳装修_店面装修设计_餐厅设计_装修全包价格-尚泰装饰设计 | 无线讲解器-导游讲解器-自助讲解器-分区讲解系统 品牌生产厂家[鹰米讲解-合肥市徽马信息科技有限公司] | 祝融环境-地源热泵多恒系统高新技术企业,舒适生活环境缔造者! | 定坤静电科技静电消除器厂家-除静电设备| 中国品牌门窗网_中国十大门窗品牌_著名门窗品牌 | 山东锐智科电检测仪器有限公司_超声波测厚仪,涂层测厚仪,里氏硬度计,电火花检漏仪,地下管线探测仪 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 中山市派格家具有限公司【官网】 | 江西自考网| 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 搪瓷搅拌器,搪玻璃搅拌器,搪玻璃冷凝器_厂家-淄博越宏化工设备 | 异噻唑啉酮-均三嗪-三丹油-1227-中北杀菌剂厂家 | 基本型顶空进样器-全自动热脱附解吸仪价格-AutoHS全模式-成都科林分析技术有限公司 | 滚塑PE壳体-PE塑料浮球-警示PE浮筒-宁波君益塑业有限公司 | 苹果售后维修点查询,苹果iPhone授权售后维修服务中心 – 修果网 拼装地板,悬浮地板厂家,悬浮式拼装运动地板-石家庄博超地板科技有限公司 | 昆明化妆培训-纹绣美甲-美容美牙培训-昆明博澜培训学校 | 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | 北京发电车出租-发电机租赁公司-柴油发电机厂家 - 北京明旺盛安机电设备有限公司 | 派财经_聚焦数字经济内容服务平台| 高温高压釜(氢化反应釜)百科| 国际高中-国际学校-一站式择校服务-远播国际教育 | 山东包装,山东印刷厂,济南印刷厂-济南富丽彩印刷有限公司 | 层流手术室净化装修-检验科ICU改造施工-华锐净化工程-特殊科室建设厂家 | 成都竞价托管_抖音代运营_网站建设_成都SEM外包-成都智网创联网络科技有限公司 | 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 青岛代理记账_青岛李沧代理记账公司_青岛崂山代理记账一个月多少钱_青岛德辉财税事务所官网 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 |