FLVTool2 broken

To make FLV's coming from flash streaming servers (FCS/FMS/Red5) properly work as a progressive download, it's often required to use a tool to inject 'missing' meta-data.

Up until now I used FLVTool2 for this, but it seems to load the entire FLV into memory (badd!), and now I'm getting nasty errors as well..

  1. ERROR: EOFError
  2. ERROR: /usr/local/lib/site_ruby/1.8/flv/amf_string_buffer.rb:37:in `read'
  3. ERROR: /usr/local/lib/site_ruby/1.8/flv/amf_string_buffer.rb:243:in `read__STRING'
  4. ERROR: /usr/local/lib/site_ruby/1.8/flv/audio_tag.rb:56:in `read_header'
  5. ERROR: /usr/local/lib/site_ruby/1.8/flv/audio_tag.rb:47:in `after_initialize'
  6. ERROR: /usr/local/lib/site_ruby/1.8/flv/tag.rb:56:in `initialize'
  7. ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:447:in `new'
  8. ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:447:in `read_tags'
  9. ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:58:in `initialize'
  10. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:272:in `new'
  11. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:272:in `open_stream'
  12. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:238:in `process_files'
  13. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:225:in `each'
  14. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:225:in `process_files'
  15. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:44:in `execute!'
  16. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2.rb:168:in `execute!'
  17. ERROR: /usr/local/lib/site_ruby/1.8/flvtool2.rb:228
  18. ERROR: /usr/bin/flvtool2:2:in `require'
  19. ERROR: /usr/bin/flvtool2:2

I wanted to try out FLVTool++ anyway, as it seems like a much more scalable solution.. This is how its installed on debian:

Grab the source:

  1. wget "http://rcdn.org:8080/images/4/44/Flvtool%2B%2B.tar.bz2"

Unpack

  1. tar xfvj Flvtool++.tar.bz2

Make sure you have a compiler installed (as root).

  1. apt-get install build-essential

Compiling

  1. make

AArrghh! It doesn't compile :(. This is the error it gave me:

  1. g++ -O2 -c -Wall -D_FILE_OFFSET_BITS=64 flvtool.cpp -o flvtool.o
  2. AMF.h:35: error: invalid pure specifier (only `= 0' is allowed) before ';' token
  3. flvtool.cpp: In function 'int main(int, char**)':
  4. flvtool.cpp:192: warning: too many arguments for format
  5. make: *** [flvtool.o] Error 1

Ok, lets dig into this code a bit.. the errors seems to give a few useful hints..

First thing I did was go to line 35 in AMF.h and change:

  1. virtual std::ostream& operator << (std::ostream& os) const = NULL;

into:

  1. virtual std::ostream& operator << (std::ostream& os) const = 0;

Next, open flvtool.cpp (line 192) and change:

  1. fprintf(stderr, "usage:\n", argv[0]);

Into:

  1. fprintf(stderr, "usage:\n");

Now, for some reason you also need to manually create the bin/ directory in your source directory, after that you can start compiling again.

  1. mkdir bin
  2. make

Success! Your bin/ directory will now contain the flvtool++ binary

  1. ./bin/flvtool++
  2. #outputs:
  3.  
  4. flvtool++ version 1640 2007/05/24 14:39:18
  5. usage:
  6. flvtool++ <input file> <output file> (<start time> <end time>)
  7. flvtool++ -i <input file>
 1

About

My name is Evert, and I've been writing semi-regularly on this blog since 2006.

I'm currently available for contract work.

more info.

Subscribe

Dropbox

Dropbox is a simple cross-platform online backup and sync application. The first 2GB of space is free, and both you and me get an extra 250MB extra space if you sign up through this link.