[MPlayer-users] Watching a filmand recording it at the same time?

Laurent Dufréchou laurent.dufrechou at free.fr
Fri Nov 3 22:27:37 CET 2006


I think I get why mplayer can't read the file while it is recorded...

Here is avi_finish which is called at the end of the capture...

> void avi_finish(void)
> {
>     int i, movielen, filelen, off;
>     unsigned char hdr[1024 + 12];
>
>     movielen = lseek(avifd, 0, SEEK_CUR);
>
>     PUT_32(hdr, FOURCC("idx1"));
>     PUT_32(hdr + 4, lseek(idxfd, 0, SEEK_CUR));
>     write(avifd, hdr, 8);
>     if (stdt) fwrite_unlocked(hdr,1,8,stdout);
>     lseek(idxfd, 0, SEEK_SET);
>     while ((i = read(idxfd, hdr, sizeof(hdr))) > 0)
>         if (write(avifd, hdr, i) < 0) {
>             perror("Unable to write index data to AVI file");
>             exit(1);
>         }
>         if (stdt) fwrite_unlocked(hdr,1,i,stdout);
>     close(idxfd);
>

Index have been written....
and now...

>     filelen = lseek(avifd, 0, SEEK_CUR);
>
>     memset(hdr, 0, sizeof(hdr));
>     PUT_32(hdr, FOURCC("RIFF"));
>     PUT_32(hdr + 4, lseek(avifd, 0, SEEK_CUR) - 8);
>     PUT_32(hdr + 8, FOURCC("AVI "));
>     PUT_32(hdr + 12, FOURCC("LIST"));
>     PUT_32(hdr + 12 + 8, FOURCC("hdrl"));
>     PUT_32(hdr + 12 + 12, FOURCC("avih"));
>     PUT_32(hdr + 12 + 12 + 4, 64 - 8);
>     PUT_32(hdr + 12 + 12 + 8, std & V4L2_STD_NTSC ? 33366 : 40000);
>     PUT_32(hdr + 12 + 12 + 20, 2320);
>     PUT_32(hdr + 12 + 12 + 24, avi_frame_count);
>     PUT_32(hdr + 12 + 12 + 32, audfd < 0 ? 1 : 2);
>     PUT_32(hdr + 12 + 12 + 36, 128*1024);
>     PUT_32(hdr + 12 + 12 + 40, width);
>     PUT_32(hdr + 12 + 12 + 44, height);
>     off = 64;
>     off += add_video_stream_header(hdr + 12 + 12 + off);
>     if (audfd >= 0)
>         off += add_audio_stream_header(hdr + 12 + 12 + off);
>     PUT_32(hdr + 12 + 4, 12 - 8 + off);
>
>     PUT_32(hdr + 12 + 12 + off, FOURCC("JUNK"));
>     PUT_32(hdr + 12 + 12 + off + 4, 1024 - 12 - 12 - off - 8);
>     PUT_32(hdr + 1024, FOURCC("LIST"));
>     PUT_32(hdr + 1024 + 4, movielen - 1024 - 8);
>     PUT_32(hdr + 1024 + 8, FOURCC("movi"));
>     lseek(avifd, 0, SEEK_SET);
>     write(avifd, hdr, 1024 + 12);
>     close(avifd);
>
The head where if I have well understood sets the video type....is
written at the end of the capture ...
There is something wrong in how they've done this no?? :)

So this is not a mplayer problem...
I will try to modify my recorder program.

Thx for your help.
(If you want a liittle example of a caption during recording I can send
it to you If you want mplayer able to read this file with bruteforce :) )
mplayer --assume avi test.avi? :)



More information about the MPlayer-users mailing list