phpでflv時間を取得! ソースコードあり!手に取って使用するだけです。とてもシンプルです。
<ol class="dp-c"> <li class="alt"><span><span><?php </span></span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">function</span><span> BigEndian2Int(</span><span class="vars">$byte_word</span><span>, </span> <span class="vars">$signed</span><span> = false) { </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$int_value</span><span> = 0; </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$byte_wordlen</span><span> = </span><span class="func">strlen</span><span>(</span><span class="vars">$byte_word</span><span>); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">for</span><span> (</span><span class="vars">$i</span><span> = 0; </span><span class="vars">$i</span><span> < </span><span class="vars">$byte_wordlen</span> <span>; </span><span class="vars">$i</span><span>++) </span></li><li> <span> </span></li><li class="alt"><span> { </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$int_value</span><span> += ord(</span><span class="vars">$byte_word</span><span>{</span><span class="vars">$ i</span><span>}) * pow(256, (</span><span class="vars">$byte_wordlen</span>) <span> - 1 - </span><span class="vars">$i</span><span>)); </span></li><li><span> </span></li><li class="alt"><span> } </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">if</span><span> (</span><span class="vars">$signed</span><span>) </span></li> <li><span></span></li> { <li class="alt"><span></span></li> <li><span></span></li> <li class="alt"><span>$ Sign_mask_bit</span><span class="vars"> = 0x80 << (8 * (</span><span>$byte_wordlen</span><span class="vars"> - 1)); </span><span></span></li> <li><span></span></li> <li class="alt"><span>if</span><span class="keyword"> (</span><span>$int_value</span><span class="vars"> & </span><span>$sign_mask_bit</span><span class="vars">) </span><span></span></li> <li><span></span></li> { <li class="alt"><span></span></li> <li><span></span></li> <li class="alt"><span>$int_value</span> <span class="vars"> = 0 - (</span><span>$int_value</span><span class="vars"> & (</span><span>$sign_mask_bit</span><span class="vars"> - 1)); </span><span></span></li> <li><span></span></li> } <li class="alt"><span></span></li> <li><span></span></li> } <li class="alt"><span></span></li> <li><span></span></li> <li class="alt"><span>戻る</span><span class="keyword"> </span><span>$int_value</span><span class="vars">; </span><span></span></li> <li><span></span></li> } <li class="alt"><span></span></li> <li><span></span></li> <li class="alt"><span>function</span><span class="keyword"> getTime(</span><span>$name</span><span class="vars">){ </span> <span></span></li> <li><span></span></li> <li class="alt"><span>if</span><span class="keyword">(!</span><span>file_exists </span><span class="func">(</span><span>$name</span><span class="vars">)){ </span><span></span></li> <li><span></span></li> <li class="alt"><span>return</span><span class="keyword">; </span><span></span></li> <li><span></span></li> } </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$flv_data_length</span><span>=</span><span class="func">filesize</span><span>(</span><span class="vars">$name</span><span>); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$fp</span><span> = @</span><span class="func">fopen</span><span>(</span><span class="vars">$name</span><span>, </span><span class="string">rb</span><span>); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$flv_header</span><span> = </span><span class="func">fread</span><span>(</span><span class="vars">$fp</span><span>, 5); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="func">fseek</span><span>(</span><span class="vars">$fp</span><span>, 5, SEEK_SET); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$frame_size_data_length</span><span> =BigEndian2Int(</span><span class="func">fread</span><span>(</span><span class="vars">$fp</span><span>, 4)); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$flv_header_frame_length</span><span> = 9; </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">if</span><span> (</span><span class="vars">$frame_size_data_length</span><span> > </span><span class="vars">$flv_header_frame_length</span><span>) { </span> </span></li> <li><span> </span></li> <li class="alt"> <span> </span><span class="func">fseek</span><span>(</span><span class="vars">$fp</span><span> , </span><span class="vars">$frame_size_data_length</span><span> - </span><span class="vars">$flv_header_frame_length</span><span>, SEEK_CUR); </span> </li> <li><span> </span></li> <li class="alt"><span> } </span></li> <li><span> </span></li> <li class="alt"> <span> </span><span class="vars">$duration</span><span> = 0; </span> </li> <li><span> </span></li> <li class="alt"> <span> </span><span class="keyword">while</span><span> ((</span><span class="func">ftell</span><span>(</span><span class="vars">$fp</span><span>) + 1) < </span><span class="vars">$flv_data_length </span><span>) { </span></li><li><span> </span></li><li class="alt"><span> </span> <span class="vars">$this_tag_header</span><span> = </span><span class="func">fread</span><span>(</span><span class="vars">$fp</span><span>, 16); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$data_length</span><span> = BigEndian2Int(</span><span class="func">substr</span><span>(</span><span class="vars">$this_tag_header</span><span>, 5, 3)); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$timestamp</span><span> = BigEndian2Int(</span><span class="func">substr</span><span>(</span><span class="vars">$this_tag_header</span><span>, 8, 3)); </span></li><li><span> </span></li><li class="alt"><span> </span><span class="vars">$next_offset</span><span> = </span><span class="func">ftell</span><span>(</span><span class="vars">$fp</span><span>) - 1 + </span><span class="vars">$data_length</span> <span>; </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">if</span><span> (</span><span class="vars">$timestamp</span><span> > </span><span class="vars">$duration</span><span>) { </span> </li> <li><span> </span></li> <li class="alt"> <span> </span><span class="vars">$duration</span><span> = </span><span class="vars">$timestamp</span> <span>; </span> </li> <li><span> </span></li> <li class="alt"><span> } </span></li> <li><span> </span></li> <li class="alt"> <span> </span><span class="func">fseek</span><span>(</span><span class="vars">$fp</span><span>, </span><span class="vars"> $next_offset</span><span>, SEEK_SET); <p align="left"></p> <div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/486304.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/486304.html</span><span id="genre" itemprop="genre">技術記事</span><span id="description" itemprop="description"> ?php function BigEndian2Int( $byte_word , $signed =false){ $int_value =0; $byte_wordlen = strlen ( $byte_word...</span> </div> <div class="art_confoot"></div></span> </li> </ol>