4

As of Flash 10.1, they have added the ability to add bytes into the NetStream object via the appendBytes method (described here http://www.bytearray.org/?p=1689). The main reason for this addition is that Adobe is finally supporting HTTP streaming of video. This is great, but it seems that you need to use the Adobe Media Streaming Server (http://www.adobe.com/products/httpdynamicstreaming/) to create the correct video chunks from your existing video to allow for smooth streaming.

I have tried to do a hacked version of HTTP streaming in the past where I swap out the NetStream objects (similar to here http://video.leizhu.com/video.html), but there is always a momentary pause between the chunks. With the new appendBytes, I tried to do a quick mock up with the two sections of video from the preceding site, but even then, the skip still remains.

Does anyone know how the two consecutive .FLV files needs to be formated in order for the appendBytes method on the NetStream object to create a nice smooth video without a noticeable skip between the segments?

vipw
  • 7,593
  • 4
  • 25
  • 48
Scott
  • 16,711
  • 14
  • 75
  • 120
  • I have not received an answer yet that fully satisfies the requirement. Step 1 is to parse out video into chunks that are acceptable to the NetStream appentBytes(). Step 2 is actually piecing these chunks together into contiguous video. I have not found anywhere where someone has hacked this together. I know OSMF supports HTTP streaming, but haven't found in their code how they actually do it. – Scott Feb 16 '11 at 19:58
  • This is a thorny problem which no one has really produced a complete solution to. You might want to look at some code which LongTail (The JWPlayer people) have made public. My experiences of OSMF have been consistently poor for all forms of HTTP Streaming, so I recommend you look elsewhere. – Haqa Mar 16 '12 at 15:04

6 Answers6

9

I was able to get this working using Adobe's File Packager Tool which Samuel described. I didn't use the NetStream object but I used the OSMF Sample Player which I assume uses this internally. Here's how to do with without using FMS:

  1. Get Adobe's File Packager for Http Dynamic Streaming from http://www.adobe.com/products/httpdynamicstreaming/
  2. Run the File Packager on an existing MP4 file containing H.264/AAC like this: C:\Program Files\Adobe\Flash Media Server 4\tools\f4fpackager> f4fpackager.exe --input-file="MyFile.mp4" --segment-duration=30

This will result in 30 second long F4F files, also F4X and a F4M file. The F4F files are your correctly segmented (and fragmented) MP4 files that should play. If you want to test this using the OSMF Player also do the following:

  1. Get Apache Server
  2. Get Adobe's Http Origin Module for Apache from http://www.adobe.com/products/httpdynamicstreaming/
  3. Install the module according to http://help.adobe.com/en_US/HTTPStreaming/1.0/Using/WS8d6ed60bd880807c48597a9e1265edd6cc0-8000.html
  4. Put the F4F, F4X and F4M file into the vod directory under httpdocs
  5. Get the “OSMF Sample Player for HTTP Dynamic Streaming” from http://www.osmf.org/downloads/OSFMPlayer_zeri2.zip
  6. Put the Sample Player in the httpdocs directory
  7. Load the html file from the Sample Player in a browser eg http://localhost/OSMFPlayer.html
  8. Press the eject button and put in the URL of your F4M file, it should play

So to answer the original question Adobe's File Packager is the file splitter to use, you don't need to buy FMS to use it and it works for FLV and MP4/F4V files.

Grant
  • 1,608
  • 16
  • 14
1

I recently found a similar project for node.js to achieve m3u8 transcoding (https://github.com/andrewschaaf/media-server) but have yet to hear of one besides Wowza doing it outside of Origin module for Apache. Since the payloads are nearly identical you're better off looking for a good mp4 segmenting solution (plenty out there) than looking for f4m segmenting. The problem is moov atoms especially on larger mp4 video are difficult to manage and put in their proper initial (near beginning of file) location. Even using optimal ffmpeg settings and 'qtfaststart' you end up with noticeably slower seeking, inefficient bandwidth usage (usually greedy), and a few minor headaches relating to scrubbing/time that you don't get with flv/f4v playback.

In my player I have or intend to switch between HTTP Dynamic Streaming (HDS) and MP4 based on load and realtime log parsing Apache using awk/cron instead of licensing Adobe's Access product for stream protection .. both have unique 'onmetadata' handlers.. but in the end I receive sequenced time/byte hashes virtually equivalent. Just MP4 is slower. So mod_origin is just a synchronizer / request router for Flash clients (over http). I'm still looking for ways to speed up mp4-container-based playback. One incredible solution I read this recently and was rather awestruck by it http://zehfernando.com/2011/flash-video-frame-time-woes/ where a video editor (guy) and flash developer came up with their own mp4 timecoding solution that literally added (via Adobe Premiere script) about 50 pixels to the bottom of every video frame with a visual 'binary' stamp like a frame barcode.. and those binary values translate into highly-accurate timecode values. So Flash could analyze the video frames as they were painted (realtime) and determine precisely where the player was and what bytes were needed from any kind of mp4 byte-segmenting-friendly webserver. The thing is (and perhaps I'm wrong here) Flash seems to arbitrarily choose when it gets to moov data, especially on large video files (.5-1.5gigs). Even if you make sure to run your mp4 through MP4Box (i.e. MP4Box -frag 10000 -inter 0 movie.mp4) I guess this has been a problem OSMF and HDS have worked on quite well now, though it is annoying that you need Apache and a proprietary closed-source module to use it imo. Its probably just a matter of time before open source implementations arrive as HDS is only 1-2 years old, and it just needs a little reverse engineering like that Andrew Chaaf guy with node.js + mpegts streaming (live or not). In the end I may just end up using OSMF exclusively beneath my UI as it seems to have similar virtues to HDS if not more so i.e. Strobe if you need sick extensible HDS or MP4 open player platform to hack from to realize your own custom player.

Scott
  • 16,711
  • 14
  • 75
  • 120
Peter Herz
  • 11
  • 2
  • There are a lot of stand alone segmenting solution, but I'm looking for a library (preferably java or with java hook) that I can use to dynamically segment/split video. I have not seen anything like this. Also, the HDS support from adobe requires their proprietary format. I just want to play two video clips one after another that have been split, and with no visible hiccups from flash. – Scott Apr 09 '12 at 23:42
1

You don't need to use their server. Wowza supports Adobe's version of HTTP Streaming and you can implement it yourself by segmenting the videos properly and loading all the segments on a standard HTTP server.

Links to all the specs for Adobe's HTTP Streaming are here:

http://help.adobe.com/en_US/HTTPStreaming/1.0/Using/WS9463dbe8dbe45c4c-1ae425bf126054c4d3f-7fff.html

Trying to hack the client to do some custom style http streaming will be a lot more troublesome.

Note that HTTP Streaming does not support streaming several different videos but streams a single file that was broken off into separate segments.

File Packager

A command-line tool that translates on-demand media files into fragments and writes the fragments to F4F files. The File Packager is an offline tool. You can use the File Packager to encrypt files for use with Flash Access. For more information, see Packaging on-demand media.

The File Packager is available from adobe.com and is installed with Adobe® Flash® Media Server to the rootinstall/tools/f4fpackager folder.

Packager download link is on right here: Download File Packager for HTTP Dynamic Streaming

http://www.adobe.com/products/httpdynamicstreaming/

Community
  • 1
  • 1
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
  • The problem is that I don't know how to split up the video for HTTP streaming. If I just take two consecutive video files, it isn't working correctly. I need to do some things low level where we are storing snippets of video ourselves. – Scott Dec 14 '10 at 22:45
  • You can't use it to just play two consecutive videos. They have to be segments of videos. – Samuel Neff Dec 15 '10 at 02:45
  • That's where I'm a bit confused, what do you mean by segments of video? How can I create these segments. I've seen where sites like slot3.com create files with .seg files, but these do not appear to be FLV files and I'm not sure how it fits in. Net question is how do I split one video file into 2, then how do I play them consecutively with no gap. I only want to use the appendByte method on the NetStream object and no back end media server at all (i.e. just load the two files and throw them in the NetStream). – Scott Dec 15 '10 at 16:20
  • @Scott, I updated my answer to include info on the packager and a link to Adobe's command line packaging too. – Samuel Neff Dec 15 '10 at 18:27
  • Thanks for the feedback, but it seems that I need to install their server to use the packager. I'm trying to find something simple (and free) that will allow me to break apart video into segments (just 2 for a proof of concept). Then I want to use appendBytes on the NetStream to tie those two together. I can find how to inject bytes into the NetStream, but can't find how to make those bytes compliant so there is no skipping. – Scott Dec 28 '10 at 20:07
1

You could use F4Pack, it's a GUI around the commandline-tool from Adobe, that lets you process your flv/f4v file so they can be used for HTTP Dynamic Streaming.

Tha Narie
  • 11
  • 1
  • 2
1

The place in the OSMF code where this happens is the timer-fired state machine inside of the HTTPNetStream class implementation... might be an informative read. I think I even put some helpful comments in there when I wrote it.

As far as the general question:

If you read an entire FLV file into a ByteArray and pass it to appendBytes, it will play. If you break that FLV file in half, and pass the first half as a byte array and then the second half as a byte array, that will play as well.

If you want to be able to switch around between bitrates without a gap, you need to split up your FLV files at matching keyframe points... and remember that only the first call to appendBytes has the initial FLV file header ('F', 'L', 'V', flags, offset)... the rest just expect a continuation of the FLV byte sequence.

  • the problem I've run into when splitting into different files is that when there is a switch between the two bytearrays, there is a noticeable jump by the player – Scott Jul 15 '11 at 22:36
0

Adobe's F4F format is based on MP4 files, are you able to use F4V or MP4 instead of FLV files? There are plenty of MP4 file splitters around but you would need to make sure the timestamps in the files are continuous, maybe the pause happens when it sees a zero timestamp within the audio or video stream inside the file.

Grant
  • 1,608
  • 16
  • 14
  • Yes, using MP4 containers with h.264 encoded video is fine. I have not been able to find anyplace to ensure it is splitting the file correctly. I have the code to enqueue them in the NetStream, but it seems that the NetStream still jumps between the files. Have you been able to do this method? – Scott Feb 20 '11 at 23:35
  • The FLV file format has timestamps too, and they also need to be continuous. The FLV fileformat is really simple and open: http://www.adobe.com/devnet/f4v.html. You could try to write your own splitter. – Luzifer42 Feb 21 '11 at 12:44
  • I'd rather not write my own splitter if according to @Grant there are 'plenty of MP4 file splitters'. There has to be some kind of reference where someone has tried to do this before. The pieces for recombining the stream are now available in Flash 10.1 with the addition of the appendByte method. The only thing left is to figure out how to send in split video so that it recombines without skipping. – Scott Feb 21 '11 at 20:20