McMahon has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks...

After searching here and CPAN, I'm still deeply ignorant. I'm not sure if what I want to do is even possible, but here goes...

I have a source of continuous streaming video, compressed with a proprietary MPEG4-based codec. I would like to get the packets, write them to a file, and make the file recognizable to Windows Media Player. Getting the packets is easy:
#!/usr/bin/perl use warnings; use strict; use IO::Socket; my $data; open OUT, ">file.avi"; my $local = new IO::Socket::INET->new(LocalPort=>10000, Proto=>'udp'); while(1) { $local->recv($data,1024); print OUT "$data"; }
but the file doesn't play.

Looking at the contents of a legitimate .avi file, I find certain header information and what may be EOF characters.

Is there any convenient way to generate valid Windows .avi header/trailer information for a collection of video packets turned into a file?

Is there anything else I would have to do to my collection of packets to turn it into a legitimate .avi file?

(Or am I completely deluded?)

Replies are listed 'Best First'.
Re: Turn network video stream into playable .avi file?
by Joost (Canon) on Aug 27, 2004 at 11:44 UTC
Re: Turn network video stream into playable .avi file?
by Grygonos (Chaplain) on Aug 26, 2004 at 20:03 UTC

    Just off the cuff here, if you can create an avi template, (i.e. the basic headers/footers) you should be able to paste,(ie. write in binmode), the packet data("actual data", not including the headers (if applicable)) in the appropriate section of that .avi template

    That would be my approach. Also, I notice you're using UDP. I don't know if that's the standard protocol for streaming or not, but it would seem to me that TCP would be a lot more reliable. IE. if you're listening on a UDP port, you don't always know where the traffic comes from (to the best of my memory).

      hi

      UDP is preferred over TCP for multimedia because of throughput and because if a packet or two is lost, we don't want to be waiting for a retransmission of the packets... which may cause 'jittery' video/sound. If there is a bit of garbage in the video file, most of the 'modern' video players will attempt to jump past the garbage.. No guarantees though.

      For the avi header... it will have to be generated. GFF Format Summary: Microsoft RIFF contains the AVI header info

      jason

      No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

        For the avi header... it will have to be generated.

        I just wondered if anyone had scratched this particular itch before. Apparently not?