Discussion:
[Libav-user] Libav* Video to JPG
Ali Osman ŞAHAN
2018-10-15 15:12:30 UTC
Permalink
Dear experts,


I need to decode (and export as jpg) H.264 and MPEG-2 I-pictures from within the source code of an application I'm writing in C. I linked against libavcodec in the hope that avcodec_decode_video() could do it but it seems that it only works for .mpg and not for raw elementary streams. I basically used the code from libavcodec's old apiexample.c (no AVPacket).

Using ffmpeg on the 2 samples provided, I can easily decode them:
ffmpeg -f h264 -i sample.264 -s 600x400 sample_%d.jpg
ffmpeg -f mpegvideo -i sample.mpeg2 -s 600x400 sample_%d.jpg

Can you please point out the function that I should use to achieve this using libavcodec?


Also same question in http://ffmpeg.org/pipermail/libav-user/2011-April/000053.html.But links missed.Can you help me?
Strahinja Radman
2018-10-17 06:05:38 UTC
Permalink
Maybe you should take a look at transcoding.c example. With it you will have a solid starting base which works. This will handle your input decoding and encoding. 
For the encoding part i think that you need to open jpg encoder and jpg muxer. For the muxer you should be able to just specify filename_%3d.jpg and probably it will work without any additional options.
This should be a step in a right direction.
-------- Original message --------From: Ali Osman ŞAHAN <***@hotmail.com> Date: 15/10/2018 17:12 (GMT+01:00) To: Libav-user-***@ffmpeg.org, libav-***@ffmpeg.org Subject: [Libav-user] Libav* Video to JPG


Dear experts,


I need to decode (and export as jpg) H.264 and MPEG-2 I-pictures from within the source code of an application I'm writing in C. I linked against libavcodec in the hope that avcodec_decode_video() could do it but it seems that it only works for .mpg and not for raw elementary streams. I basically used the code from libavcodec's old apiexample.c (no AVPacket).

Using ffmpeg on the 2 samples provided, I can easily decode them:
ffmpeg -f h264 -i sample.264 -s 600x400 sample_%d.jpg
ffmpeg -f mpegvideo -i sample.mpeg2 -s 600x400 sample_%d.jpg

Can you please point out the function that I should use to achieve this using libavcodec?



Also same question in http://ffmpeg.org/pipermail/libav-user/2011-April/000053.html.But links missed.Can you help me?
Carl Eugen Hoyos
2018-10-17 09:31:59 UTC
Permalink
Post by Ali Osman ŞAHAN
I need to decode (and export as jpg) H.264 and MPEG-2 I-pictures from within
the source code of an application I'm writing in C. I linked against
libavcodec in the hope that avcodec_decode_video() could do it but it seems
that it only works for .mpg and not for raw elementary streams.
The libavcodec H.264 decoder works neither on mpg nor elementary streams
but frames as provided by the H.264 parser, also part of libavcodec.
libavformat supports both mpg and elementary streams (and many other
file formats).

Carl Eugen
Steve Sisak
2018-10-24 12:51:48 UTC
Permalink
Post by Carl Eugen Hoyos
The libavcodec H.264 decoder works neither on mpg nor elementary streams
but frames as provided by the H.264 parser, also part of libavcodec.
libavformat supports both mpg and elementary streams (and many other
file formats).
Not to hijack a thread, but is there any documentation/sample code for using the H.264 parser on its own?

Wondering if I can use this in a macOS/iOS environment using Apple’s codecs.
Loading...