{"id":158,"date":"2019-01-08T09:27:29","date_gmt":"2019-01-08T09:27:29","guid":{"rendered":"https:\/\/www.laptoparena.net\/blog\/?p=158"},"modified":"2019-01-08T09:27:32","modified_gmt":"2019-01-08T09:27:32","slug":"how-to-download-streaming-video-from-internet-f4f-format-flv-mp4","status":"publish","type":"post","link":"https:\/\/www.laptoparena.net\/blog\/how-to-download-streaming-video-from-internet-f4f-format-flv-mp4\/","title":{"rendered":"How to download streaming video from internet f4f format, flv, mp4"},"content":{"rendered":"\n<p>F4F is Adobe&#8217;s fragmented MP4 file format for&nbsp;<em>HTTP Dynamic Streaming<\/em>.<\/p>\n\n\n\n<p>Check out this&nbsp;<a href=\"http:\/\/bit.ly\/2eLnd5m\">video converter<\/a><\/p>\n\n\n\n<p>To save the video we will use the fact that the browser has to download to temp the video and will do so in f4f format.<\/p>\n\n\n\n<p>1. First download and run CCleaner &#8211; run it click&nbsp;<strong>Analyze&nbsp;<\/strong>then right click on Firefox &#8211; Internet Cache and select Clean. (it will ask to close firefox to analyze it in the first place)<\/p>\n\n\n\n<p>3. Download&nbsp;<a href=\"http:\/\/www.nirsoft.net\/utils\/video_cache_view.html\">VideoCacheView<\/a><\/p>\n\n\n\n<p>2. Open the video you want to download and let it play from start to finish. Close firefox and open VideoCacheView (must first close firefox to be able to access the video fragments)<\/p>\n\n\n\n<p>-Sort by Last Accesedd Date and you will se in the download someurl.mp4Seg1-Frag1 Frag2 etc<\/p>\n\n\n\n<p>Select all the fragments and save them to a folder.<\/p>\n\n\n\n<p>Then export first column with the name of the filenames of the fragments to a.csv and save it in the same folder with the fragments.<\/p>\n\n\n\n<p>Now all we need to do is combine the fragments and get the original video.<\/p>\n\n\n\n<p>&nbsp;Install php as explained in this post :&nbsp;<a href=\"http:\/\/s86d.blogspot.ro\/2014\/08\/install-php-in-windows.html\">Install PHP in windows to run from cmd<\/a><\/p>\n\n\n\n<p>Run the next script in the same folder with the video fragments.<\/p>\n\n\n\n<p>Press SHIFT and then right click on the folder &#8211; select &#8211; Open command window here.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&lt;?php<br>\u00a0 function ReadInt24($str, $pos)<br>\u00a0\u00a0\u00a0 {<br>\u00a0\u00a0\u00a0\u00a0\u00a0 return intval(bin2hex(substr($str, $pos, 3)), 16);<br>\u00a0\u00a0\u00a0 }<br>\u00a0 function ReadInt32($str, $pos)<br>\u00a0\u00a0\u00a0 {<br>\u00a0\u00a0\u00a0\u00a0\u00a0 return unpack(&#8220;N&#8221;, substr($str, $pos, 4))[1];<br>\u00a0\u00a0\u00a0 }<br><\/p><p>\u00a0 echo &#8220;\\nKSV Adobe HDS Downloader\\n\\n&#8221;;<br>\u00a0 $flvHeader\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = hex2bin(&#8220;464c5601050000000900000000&#8221;);<br>\u00a0 $firstVideoPacket = true;<br>\u00a0 $prevTagSize\u00a0\u00a0\u00a0\u00a0\u00a0 = 4;<br>\u00a0 $fragCount\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = 0;<br>\u00a0 $outputFile = &#8220;Joined.flv&#8221;;<br>\u00a0<br>\u00a0 $flv = fopen(&#8220;$outputFile&#8221;, &#8220;wb&#8221;);<br>\u00a0 fwrite($flv, $flvHeader, 13);<br><br>\u00a0 \/\/ here read filenames<br>\u00a0 $csv = array_map(&#8216;str_getcsv&#8217;, file(&#8216;a.csv&#8217;));<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;Found $fragCount fragments\\n&#8221;;<br>\u00a0\u00a0\u00a0 foreach($csv as $file)<br>\u00a0\u00a0\u00a0 {<br>\u00a0\u00a0\u00a0\u00a0\u00a0 $frag = file_get_contents($file[0]);<br>\u00a0\u00a0\u00a0\u00a0\u00a0 preg_match(&#8216;\/(.{4})mdat[\\x08\\x09\\x12]\/i&#8217;, $frag, $mdat, PREG_OFFSET_CAPTURE);<br>\u00a0\u00a0\u00a0\u00a0\u00a0 $fragLen = ReadInt32($mdat[1][0], 0) &#8211; 8;<br>\u00a0\u00a0\u00a0\u00a0\u00a0 $frag\u00a0\u00a0\u00a0 = substr($frag, $mdat[1][1] + 8, $fragLen);<br>\u00a0\u00a0\u00a0\u00a0\u00a0 $pos\u00a0\u00a0\u00a0\u00a0 = 0;<br>\u00a0\u00a0\u00a0\u00a0\u00a0 while ($pos &lt; $fragLen)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $packetType\u00a0 = $frag[$pos];<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $packetSize\u00a0 = ReadInt24($frag, $pos + 1);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $packetTS\u00a0\u00a0\u00a0 = ReadInt24($frag, $pos + 4);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $totalTagLen = 11 + $packetSize + $prevTagSize;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (($packetType == &#8220;\\x08&#8221; &amp;&amp; $packetSize > 4) or ($packetType == &#8220;\\x09&#8221; &amp;&amp; $packetSize > 40) or ($packetType == &#8220;\\x09&#8221; &amp;&amp; $firstVideoPacket))<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ($packetType == &#8220;\\x09&#8221; &amp;&amp; $firstVideoPacket)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $firstVideoPacket = false;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fwrite($flv, substr($frag, $pos, $totalTagLen), $totalTagLen);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $pos += $totalTagLen;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br>\u00a0\u00a0\u00a0 }<br><br>\u00a0 fclose($flv);<br>\u00a0 echo &#8220;Finished\\n&#8221;;<br>?> <\/p><\/blockquote>\n\n\n\n<p>and press ENTER.<\/p>\n\n\n\n<p>Write : php join_f4f_to_flv.php<\/p>\n\n\n\n<p>Befor running the command copy the following code in a file named&nbsp;&nbsp;<em>join_f4f_to_flv.php<\/em>&nbsp;in the same folder :<\/p>\n\n\n\n<p>&nbsp; Finally you can use any software to convert the .flv file to any desired format.<\/p>\n\n\n\n<p><strong>Please leave a comment with a url with f4f steaming so I can improve the script\/method as I can&#8217;t seem&nbsp; to find some content to practice.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>F4F is Adobe&#8217;s fragmented MP4 file format for&nbsp;HTTP Dynamic Streaming. Check out this&nbsp;video converter To save the video we will use the fact that the browser has to download to temp the video and will do so in f4f format. 1. First download and run CCleaner &#8211; run it click&nbsp;Analyze&nbsp;then right click on Firefox &#8211; &#8230; <a title=\"How to download streaming video from internet f4f format, flv, mp4\" class=\"read-more\" href=\"https:\/\/www.laptoparena.net\/blog\/how-to-download-streaming-video-from-internet-f4f-format-flv-mp4\/\" aria-label=\"Read more about How to download streaming video from internet f4f format, flv, mp4\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":1,"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/posts\/158\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laptoparena.net\/blog\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}