[FFmpeg-user] Alter YUV values of AVFrames

killkenny64 kennethjjgibson at gmail.com
Wed Feb 1 02:46:23 CET 2012


I'm trying to apply an effect to a video by altering the YUV values using
FFMpeg programmatically in C.

Let's say I want to increase the luminescence of each pixel of each frame by
100.

I tried just altering the first frame of a video stream. I decoded the
frame, added 100 to each Y value in the AVFrame->data[0], encoded the frame
again and saved it into the video.

However when I play the video back, it is not only the first frame that has
been altered, but the first 30 frames.

Why are the other frames effected when I only change the AVFrame->data of
the first frame?

I tried again by changing all the Y, U and V values in AVFrame->data to 0
for only the first frame.

When I play back the video, it starts off completely green like expected,
after the first frame the video stays green for 30 frames. I can see the
other frames start to come slowly through the green for 30 frames and then
suddenly the green disappears and the video plays as normal. Why is it not
just the first frame that is green?

My method is as follows:

Video Stream

 |
 |     *(Get a frame)*
 |
 v
AVPacket (encoded data)

 |
 |     *(Decode the frame)*
 |
 v
AVFrame (raw data) -------------------------------------------------->
AVFrame (raw data)

                                 *(Edit AVFrame->data values)*

                                                                                                    
|
                                                                                                    
|     *(encode frame)*
                                                                                                    
|
                                                                                                    
V
                                                                                     
AVPacket (encoded data)

                                                                                                    
|
                                                                                                    
|     *(save frame)*
                                                                                                    
|
                                                                                                    
V
                                                                                           
Video Stream

Am I doing something obviously wrong?

How can I change just one frame without effecting the others?

--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Alter-YUV-values-of-AVFrames-tp4346567p4346567.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.


More information about the ffmpeg-user mailing list