[Libav-user] Copy Image Data from Decode Frame To Encode Frame

Alex Cohn alexcohn at netvision.net.il
Sun Sep 15 09:15:26 CEST 2013


On Sat, Sep 14, 2013 at 10:12 PM, James Board <jpboard2 at yahoo.com> wrote:
>>> Also, if the input and output file have the same pixel format, is there a
>>> simple way to copy the data from one to the other?
>>>
>>> Thanks
>>You don't need to copy data between frames, you can reuse the decoder frame
>> as input for encoder.
>
> Okay.  I will try this  (actually, I tried it and it didn't work, but I
> probably didn't do it right).
>
> Also, I was able to figure out my main question with the scale functions.
>
> I have another question.  If my input frames are YUV422P compressed with
> ffvhuff
> and my output frames are also YUV422P compressed with ffvhuff, can I somehow
> copy them directly from input file to output file without decoding them?
> Maybe
> copy the packet directly?  I'm currently using AVI containers.  Is this
> dependent on
> what container I choose?  If so, is there some container that allows this?
>
> Thanks.

Generally speaking, the answer is yes, you can simply copy encoded
packets from demuxer to muxer, if you don't change them. I am sure AVI
container will not be upset, but out in the wild, there could be some
containers for which this trick may be less straightforward to
implement.

Generally speaking, the prerequisite is that you copy *all* frames
from input to output. If you want to "resample" the output (e.g.
convert 60 fps to 15 fps), or want to add some more frames (e.g. merge
two video streams into one), or otherwise manipulate the stream or the
frames in that stream, your mileage may vary.

Specifically for HuffYUV, every frame is intracoded, therefore the
above prerequisite is lifted.

BR,

Alex Cohn


More information about the Libav-user mailing list