[Libav-user] Some input files decoded upside down.

Alex Cohn alexcohn at netvision.net.il
Fri Jul 26 21:01:58 CEST 2013


On Jul 26, 2013 9:53 PM, "Jason Cipriani" <jason.cipriani at gmail.com> wrote:
>
> On Fri, Jul 26, 2013 at 2:40 PM, Alex Cohn <alexcohn at netvision.net.il>
wrote:
>>
>> On Jul 23, 2013 7:52 PM, "Jason Cipriani" <jason.cipriani at gmail.com>
wrote:
>> >
>> > Hello,
>> >
>> > I'm learning how to use libav. I'm following the tutorial at
http://dranger.com/ffmpeg/tutorial01.html and have been able to read files,
decode them, and save each frame to an image just fine. However, certain
input files lead to the frames being decoded upside down (the input files
play correctly in, say, mplayer).
>> >
>> > I have one input file that uses a rawvideo codec. This is decoded
upside down. I have another input file that uses h264, this is decoded in
the correct orientation.
>> >
>> > My question is, is there a flag in some *Context somewhere that
indicates that the video frames are bottom-up, so that I can flip
vertically if necessary when processing the frames after decoding?
>> >
>> > Also, then, it's easy enough for me to process an image upside down if
necessary, but can sws_scale (or something similar) flip an image
vertically so I can do the flip and RGB conversion all in one step?
>> >
>> > Thanks!
>> > Jason
>>
>> Yes, you can perform flip and color conversion in one step with
sws_scale. You can find the answer in this thread:
http://ffmpeg-users.933282.n4.nabble.com/Flip-in-sws-scale-td939665.html
>>
>> BR,
>> Alex
>>
>>
>
>
> Thanks! That answers my sws_scale question.
>
> My remaining problem is: How can I tell if the video needs to be flipped
vertically or not? Is there a flag in one of the context structures
somewhere? I have some input files that end up vertically flipped, and some
that do not, but I'm sure the information exists somewhere because when I
play those files in media players, the players are able to play them all in
the correct orientation.
>
> Thanks again for your time,
> Jason

I don't think there may be such info for rawvideo codec. I bet you don't
really need to worry about this for "true" codecs.

As for players that handle this file correctly - please check if there are
dome command line parameters that control the flip, but maybe the player
applies some heuristics to row video.

BR,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130726/d7d90998/attachment.html>


More information about the Libav-user mailing list