Audio/video stream recording forums
|
Attention Visitor: |
You may have to register or log in before you can post:
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
f4f to f4v php code errorI get a Parse Error on Line 9 of this code.
I found this code on stackoverflow.com and would love to be able to take my .f4f generated files from Adobe Media Server 5.0 (interactive) and covert them to .f4v on the server on the fly to redistribute the content for video on demand. Is the script below able to be run from the command line? Is this why I'm getting these errors? Thanks in Advance. Code:
PHP Parse error: syntax error, unexpected '[' in /home/videos/f4ftof4v.php on line 9 Code:
<?php function ReadInt24($str, $pos) { return intval(bin2hex(substr($str, $pos, 3)), 16); } function ReadInt32($str, $pos) { return unpack("N", substr($str, $pos, 4))[1]; } echo "\nKSV Adobe HDS Downloader\n\n"; $flvHeader = hex2bin("464c5601050000000900000000"); $firstVideoPacket = true; $prevTagSize = 4; $fragCount = 0; isset($argv[1]) ? $baseFilename = $argv[1] : $baseFilename = ""; $baseFilename ? $outputFile = "$baseFilename.flv" : $outputFile = "Joined.flv"; while (true) { if (file_exists("$baseFilename" . $fragCount + 1 . ".f4f")) $fragCount++; else break; } echo "Found $fragCount fragments\n"; $flv = fopen("$outputFile", "wb"); fwrite($flv, $flvHeader, 13); for ($i = 1; $i <= $fragCount; $i++) { $frag = file_get_contents("$baseFilename$i.f4f"); preg_match('/(.{4})mdat[\x08\x09\x12]/i', $frag, $mdat, PREG_OFFSET_CAPTURE); $fragLen = ReadInt32($mdat[1][0], 0) - 8; $frag = substr($frag, $mdat[1][1] + 8, $fragLen); $pos = 0; while ($pos < $fragLen) { $packetType = $frag[$pos]; $packetSize = ReadInt24($frag, $pos + 1); $packetTS = ReadInt24($frag, $pos + 4); $totalTagLen = 11 + $packetSize + $prevTagSize; if (($packetType == "\x08" && $packetSize > 4) or ($packetType == "\x09" && $packetSize > 40) or ($packetType == "\x09" && $firstVideoPacket)) { if ($packetType == "\x09" && $firstVideoPacket) $firstVideoPacket = false; fwrite($flv, substr($frag, $pos, $totalTagLen), $totalTagLen); } $pos += $totalTagLen; } } fclose($flv); echo "Finished\n"; ?> |
#2
|
|||
|
|||
Re: f4f to f4v php code errorwhere did you find this ancient gem . it was the very first script i wrote for f4f fragment processing. it's for processing the client side fragments sent by server not server side .f4f files. simply renaming those f4f files to f4v or mp4 should work.
|
#3
|
|||
|
|||
Re: f4f to f4v php code error@KSV
So AdobeHDS.php that you've elegantly constructed will not flatten server side .f4f's to a single .f4v? The reason why I ask is the included tool with Adobe "f4vpp" Post Processing Tool will only output files to 2 gig. Simply renaming the .f4f to .f4v or .mp4 seems not to work with all the time certain players and especially iOS for HLS streaming. What could be changed or implemented into the AdobeHDS.php for it to recognize server side f4f's? Is it possible? And if it were, could it parse very large .f4f's? Thanks for your quick reply. |
#4
|
|||
|
|||
Re: f4f to f4v php code error@KSV
Would it be worth your while to accept a donation to make AdobeHDS.php script work for serve side .f4f's and flatten them into .flv? Please let me know. |
#5
|
|||
|
|||
Re: f4f to f4v php code errorclient side f4f fragment files can only contain four types of boxes (abst, asrt, afrt, mdat). i have never looked at server side f4f files so i can't be sure how hard or easy it will be to demux them. probably you can upload some small sample somewhere. there was some talk on ffmpeg irc channel few days ago about implementing servers side f4f processing. you can give it a shot at their irc channel. also you are using the paid professional product of adobe. why don't you kick the balls of their support team for having ridiculous limits of 2gb on video data.
|
Tags: f4f, f4m, f4v, f4x |
Thread Tools | |
Display Modes | |
|
|