[Ffmpeg-devel] Copying frames from MS formats (WMV) creates unplayable files?

SyRenity Now neosyrenity
Tue Aug 8 21:21:44 CEST 2006


Hi.

I encountered a problem where newly created MS media files, which include
frames from other MS files, are only partly playable by any player (VLC,
WMP, MPC...).

For example, I copy frames from one WMV to another, by simply reading frames
from the old file and writing them to the new one. The size of the new files
increases as expected. WMP then plays to the point where the old file ends,
and then throws the "unrecognized format" error. VLC and MPC players act the
same way.

Here is a bit of code that I'm using (taken from the excellent Martin B?hme
tutorial + some ffmpeg.c code):

    AVFormatContext *inctx, *outctx;
    AVPacket packet;
    AVOutputFormat *format;
    AVStream *stream;

    //Create new file
    outctx = (AVFormatContext *)av_mallocz(sizeof(AVFormatContext);

    format = guess_format( NULL, filenamenew, NULL);
    outctx ->oformat = format;
    stream = av_new_stream(outctx, 0);
    av_set_parameters(outctx , NULL);

   //Encoder setup goes here - uses the same settings as the old file

   url_fopen(&outctx->pb, filenamenew, URL_WRONLY)
   av_write_header(outctx)


    //Open old file
    av_open_input_file(&inctx,filenameold, NULL, 0, NULL);

    while(av_read_frame(inctx, &packet) >= 0)
    {
        av_write_frame(outctx;, &packet);

        av_free_packet(&packet);
    }

    av_close_input_file(inctx);


    //Close the new file
    av_write_trailer(outctx);
    url_fclose(&outctx->pb);
    av_free(outctx);


Anyone can help?

Thanks a lot,
Sunny.




More information about the ffmpeg-devel mailing list