Log in

View Full Version : Decode image sequence with libavcodec


rick666
25th August 2006, 16:06
Hi man,
I've successfully encoded a bitmap sequence with libavcodec into a mp4 file.
Now I want to encode every image and then decode to obtain the initial sequence but when I've tryed to encode and decode I've founded that the image decoded wasn't equal to the original, infact I've some images good (I think these are keyframes) and some others appear greyscaled like there are only difference between one frame and the following.
I simply encode and decode, nothing more nothing less, in this way:

/* encode the image */
out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture);


/*decode the image*/
int got_picture;
long test =avcodec_decode_video(d, pictureDecode,&got_picture,video_outbuf, out_size);


Someone knows the answer for this (I think) stupid question?

Sharktooth
26th August 2006, 13:33
mpeg-4 has different kinds of frame types.
what you experienced are techniques used in MPEG-4 standard to rise compression.
If you want to decode pure pictures you'll need to:
1 - Use a MPEG-4 compilant decoder (or write your own)
2 - Encode with Keyframes (aka I-Frames) ONLY.

GodofaGap
27th August 2006, 09:12
MPEG4 ASP is inherently lossy, so you cannot obtain the original sequence.

You could use MPEG4 AVC q0 (for example with x264), but your sequence must be downsampled to YV12 then, which is lossy too.

(If you were not talking about compression artifacts, please ignore this post)

Sharktooth
27th August 2006, 16:06
he's talking about getting partial frames (probably P or B-Frames).

rick666
28th August 2006, 09:34
ok, maybe I'm doing some error here.
The aim of my test is to compress every bitmap image with mpeg4 and then send it to a remote client that must visualize every decoded frame in a sequence like a video. Is it possible to just add the frame difference to the keyframes and so correctly visualize the sequence?And ,if yes, how can I do that?
Thank's and regards.

Sharktooth
28th August 2006, 12:34
get a reference decoder and the MPEG documentation and look at how the frames are reconstructed.

nm
28th August 2006, 13:58
Libavcodec should do that for him. I'd suggest taking a look at ffplay or some other simple player that uses the library.