[Ffmpeg-user] Capture a frame in a JPEG ffile
Vlad GURDIGA
gurdiga at gmail.com
Thu Mar 22 11:32:05 CET 2007
Hello,
I apologize for previous disaster. I was so happy that i found someone
I can ask about this, that I did not read before post. :>
What i want to achieve using APIs, is the equivalent to this command line:
ffmpeg.exe -i test.avi -ss 0:0:5.0 -vframes 1 -vcodec png -y -f image2 \
frame.png
On 21/03/07, Michel Bardiaux <mbardiaux at mediaxim.be> wrote:
> Vlad GURDIGA wrote:
> > Hello,
> >
> > Here roughly is how I do now to capture X
X here is "an arbitrary number of"; for tests I use 10 now, but I
actually will need one in production.
> > frames to PPM files (of
> > course it is not the format I need, but I followed a tutorial a hoped
"a hoped" should be "and hoped"
>
> Please check what you post, some of your text is nearly incomprehensible.
>
> And you should never start with code; better rehearse what you want to
> do using the ffmpeg command line.
>
> > I'll find a way to convert PPM to JPEG):
> >
> > av_register_all();
> > av_open_input_file();
> > ... here I get an AVCodecContext ...
> > av_find_stream_info();
> > ... find the first video stream from the AVCodecContext ...
> > avcodec_find_decoder(); // I do not know the type of video until run time
> > avcodec_open();
> > ... here I get the AVCodec ...
> > avcodec_alloc_frame(); // here I get a pointer to a prepared memory block
> >
> > loop to read packets
> > av_read_frame(); // here I get the AVPachet
> > avcodec_decode_video();
> > ... now I get the AVFrame (in the second OUT argument) ...
> > avpicture_alloc(); // here I get a memory block to store AVPicture
> > img_convert(); //here I get the AVPicture (PPM) data from AVFrame
>
> Where did you get the idea that its a PPM at this point? img_convert
> just changes the color space. You DONT need that step, the decoded
> picture is already in the AVFrame.
>
> > // now I write a header and binary data in a file to disk
> > end loop
> >
> >
> > Guys on ffmpeg-devel told me that I should use avcodec_decode_video to
>
> avcodec_encode_video.
my mistake
>
> > get the job done, but I cannot clearly see how. Could you please give
> > me a hint about this? As far as I can see, the only argument of the
> > avcodec_encode_video() the has a "codec_id" member si AVCodecContext,
>
> Now this is gibberish.
>
> > which is the source codec context
>
> Of course not, you need and *output* file and *output* stream and
> *output* codec context. Better post the URL of that tutorial, either its
> very bad, or you dont know enough of the basics.
I guess the second.
>
> > and it seems to me improper to change
> > to CODEC_ID_MJPEG.
>
> Indeed!
>
> >
> > I use all these functions from C# (if it matters).
>
> Actually, it does, because it forces you to post pseudocode instead of
> code that people could compile and try.
>
> --
> Michel Bardiaux
> R&D Director
> T +32 [0] 2 790 29 41
> F +32 [0] 2 790 29 02
> E mailto:mbardiaux at mediaxim.be
>
> Mediaxim NV/SA
> Vorstlaan 191 Boulevard du Souverain
> Brussel 1160 Bruxelles
> http://www.mediaxim.com/
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
>
More information about the ffmpeg-user
mailing list