# Modifying flvtool2 to work with .flv files recorded using Wowza Pro (fix)

**URL:** <https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36>\
**Category:** Wowza Streaming Engine\
**Created:** [September 13, 2007, 5:38am UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36 "2007-09-13T05:38:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [September 13, 2007, 5:38am UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/1 "2007-09-13T05:38:56Z")

</div>

**Problem**

The metadata generation tool **flvtool2** crashes when run on **.flv** files created using Wowza Media Server Pro.

**Solution**

There is a bug in **flvtool2 1.0.6** which causes a unrecoverable failure when run against a **.flv** recorded using Wowza Media Server Pro. This problem is easily fixed with a minor modification to the flvtool2 source code. The following instructions assume that flvtool2 is either going to be run on Linux or on Windows from within a Linux emulation environment like Cygwin or MinGW.

- Install the **ruby** and **ruby-devel** packages on your machine.

- Download and unzip the **flvtool2 1.0.6** source code ([flvtool2-1.0.6.zip](http://rubyforge.org/frs/download.php/17498/flvtool2-1.0.6.zip)).

- Change directory to **flvtool2-1.0.6/lib/flv** and open the file **audio\_tag.rb** in a text editor.

- Navigate to line 47 and change the code as follows:

- Change directory up two levels ( **cd …/…** ) and execute the following commands to rebuild and install the flvtool2 application:

- You are done. The tool should now function properly.

---

<div class="post-metadata">

**Author:** ![Noah\_Horton](https://avatars.discourse-cdn.com/v4/letter/n/e99b99/32.png) [@Noah\_Horton](https://community.wowza.com/u/Noah_Horton)\
**Post date:** [September 13, 2007, 6:37pm UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/2 "2007-09-13T18:37:01Z")

</div>

This change works wonderfully. Thanks so much!

---

<div class="post-metadata">

**Author:** ![Anton\_Jowa](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton\_Jowa](https://community.wowza.com/u/Anton_Jowa)\
**Post date:** [April 20, 2010, 2:07pm UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/3 "2010-04-20T14:07:29Z")

</div>

I have compiled the flvtool2 with the bugfix from Charlie.

When I cut a (by Wowza)H.264/FLV recorded file with flvtool2 with the next command:

_flvtool2 -CUa -i 10000 -o 20000 test\_1.flv test\_s1.flv_

The file becomes completely unplayable, for instance with the simplevideo player from Wowza.

Do I use the wrong command?

---

<div class="post-metadata">

**Author:** ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)\
**Post date:** [November 11, 2008, 3:48pm UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/4 "2008-11-11T15:48:00Z")

</div>

I don’t have one. I did my work on Linux.

Charlie

---

<div class="post-metadata">

**Author:** ![Marco\_Ghinolfi](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@Marco\_Ghinolfi](https://community.wowza.com/u/Marco_Ghinolfi)\
**Post date:** [November 11, 2008, 10:04am UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/5 "2008-11-11T10:04:17Z")

</div>

Hi all

There is no possibility to get my windows server ready for emulating linux as described.

Is there any way to compile the corrected source as a win32 binary in order to work with wowza recorded flv files?

Has anybody done this before or is there a way to download such an flvtool2.exe already?

Thanks for your help

Mierco

---

<div class="post-metadata">

**Author:** ![Jake\_Hilton](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jake\_Hilton](https://community.wowza.com/u/Jake_Hilton)\
**Post date:** [July 7, 2010, 11:35am UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/6 "2010-07-07T11:35:30Z")

</div>

Alternatively… I was able to get this working without having to recompile it… just edited the file: vi /usr/lib/ruby/site\_ruby/1.8/flv/audio\_tag.rb and then re-ran the command… and it worked! I didn’t have to download the source and recompile…

good luck!

Jake

---

<div class="post-metadata">

**Author:** ![rak\_rak](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rak\_rak](https://community.wowza.com/u/rak_rak)\
**Post date:** [June 18, 2009, 2:16pm UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/7 "2009-06-18T14:16:43Z")

</div>

> Hi all
> 
> There is no possibility to get my windows server ready for emulating linux as described.
> 
> Is there any way to compile the corrected source as a win32 binary in order to work with wowza recorded flv files?
> 
> Has anybody done this before or is there a way to download such an flvtool2.exe already?
> 
> Thanks for your help
> 
> Mierco

Hi Mierco

i would like to know if you have got the binaries of the FLVtool2 which has changes as charlie pointed out so that it wud edit the flv files streamed from the FMS server

---

<div class="post-metadata">

**Author:** ![a\_b](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@a\_b](https://community.wowza.com/u/a_b)\
**Post date:** [June 19, 2009, 10:39am UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/8 "2009-06-19T10:39:34Z")

</div>

I am also interested in the Win32 binary with the changes.

I cannot get the flvtool2 source to compile using ruby on my windows machine. :rolleyes:

edit: I finally got it compiled, but now it says “program too big to fit in memory” when I run it. I am at a loss.

---

<div class="post-metadata">

**Author:** ![a\_b](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@a\_b](https://community.wowza.com/u/a_b)\
**Post date:** [July 7, 2009, 6:28am UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/9 "2009-07-07T06:28:48Z")

</div>

Can anyone upload the windows binary?

edit: nevermind, got around the error by using yamdi instead:

[http://yamdi.sourceforge.net/](http://yamdi.sourceforge.net/)

Much better than flvtool2!

---

<div class="post-metadata">

**Author:** ![Sander\_Kruger](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@Sander\_Kruger](https://community.wowza.com/u/Sander_Kruger)\
**Post date:** [November 14, 2011, 11:01pm UTC](https://community.wowza.com/t/modifying-flvtool2-to-work-with-flv-files-recorded-using-wowza-pro-fix/36/10 "2011-11-14T23:01:36Z")

</div>

I used the fix but still ran into problems with a ffmpeg h264-encoded stream. I went through the ruby code to see where it went wrong, and in fact it’s where the code tries to extract the width and height from each video frame. The code was written before h264 was added to the FLV spec. So, I wrote a fix for it and decided to share it here.

In the file (video\_tag.rb), in the function read\_header, after parsing the codec\_id, check if it equals H263 or SVC and only read further if it does.

```auto
      bit_sequence = data_stream.read(9).unpack('B72').to_s

```

becomes:

```auto
      if @codec_id == H263VIDEOPACKET || @codec_id == SCREENVIDEOPACKET
        bit_sequence = data_stream.read(9).unpack('B72').to_s
      end

```
