video flips after being copied

For the developers that use FFmpeg in their software.
gavlig
Posts: 10
Joined: Fri Jun 22, 2012 3:27 pm

video flips after being copied

Post by gavlig » Fri Jun 22, 2012 3:50 pm

Hello everybody!

I'm writing an application which cuts videos in pieces by copying needed frames to separate file with or without transcoding.

I have solved a lot of issues since i started writing it, but for now i have one that i can't solve by myself.

There is one RAW video with BGR24 pix_fmt and when i try to cut it(just copy frames without transcoding), the result file gets flipped upside down. I have no idea why this is happening, because any other video works great with the exact same conditions.

the code looks pretty much like this http://www.pasteall.org/33146/cpp

Main part is in Videocut::cutVideo method (sounds silly, i know) and it goes from line 472. The part about transoding can be ignored, so, basically, all is left:

Code: Select all

while (timeStampCounter < clipLength) {
          if (av_read_frame(input_, &packet))
              break;
 
            /* skipping packet if its not video */
            if (packet.stream_index != input_video_stream_num_) {
                av_free_packet(&packet);
                continue;
            }
            ......
            out = writePacket(&packet, timeStampDiff, output_);
            ......
}
Maybe this issue is cause by wrong output AVFormatContext opening, but i don't know where do i need to look for it.
One thing i've noticed is that AVFormatContext->extradata of the input file contains "BottomUp", i tried to copy it into the output file, but it didn't help.

So, this is it. Hope to hear from you guys soon :)
Thanks in advance!

rogerdpack
Posts: 1877
Joined: Fri Aug 05, 2011 9:56 pm

Re: video flips after being copied

Post by rogerdpack » Fri Jun 22, 2012 4:24 pm

what output "raw" format are you using?

gavlig
Posts: 10
Joined: Fri Jun 22, 2012 3:27 pm

Re: video flips after being copied

Post by gavlig » Fri Jun 22, 2012 4:26 pm

if you mean container, then it's avi by default.

gavlig
Posts: 10
Joined: Fri Jun 22, 2012 3:27 pm

Re: video flips after being copied

Post by gavlig » Fri Jun 22, 2012 4:37 pm

I attached a screenshot of AVFormatContext contents, where you can find codec_id, where it says that it's RAW :) (just in case i understood your question wrong)
Attachments
raw.png

rogerdpack
Posts: 1877
Joined: Fri Aug 05, 2011 9:56 pm

Re: video flips after being copied

Post by rogerdpack » Fri Jun 22, 2012 4:41 pm

What are you using to display the output to know that it is "raw"
And what does raw output even mean for BMP, does it still have BMP headers on it?
-roger-

gavlig
Posts: 10
Joined: Fri Jun 22, 2012 3:27 pm

Re: video flips after being copied

Post by gavlig » Fri Jun 22, 2012 4:45 pm

To display the output i use the same video player. By "raw", i mean that the video is not compressed, its' codec_id is CODEC_ID_RAWVIDEO.

And about that BMP thing - i don't know what is BMP, sorry :) Is it bitmap?

rogerdpack
Posts: 1877
Joined: Fri Aug 05, 2011 9:56 pm

Re: video flips after being copied

Post by rogerdpack » Fri Jun 22, 2012 4:57 pm

yeah bitmap/dip headers. I *think* the headers have a flip bit in them...

gavlig
Posts: 10
Joined: Fri Jun 22, 2012 3:27 pm

Re: video flips after being copied

Post by gavlig » Fri Jun 22, 2012 6:28 pm

Cool! Is there any way to access to them?

rogerdpack
Posts: 1877
Joined: Fri Aug 05, 2011 9:56 pm

Re: video flips after being copied

Post by rogerdpack » Fri Jun 22, 2012 6:37 pm

no idea, but http://stackoverflow.com/questions/4669 ... 75_4669130 seems to imply that you can use a negative height and it work.

ramiro
Posts: 157
Joined: Tue May 10, 2011 12:56 am

Re: video flips after being copied

Post by ramiro » Sat Jun 23, 2012 6:36 am

negative height should work. you may also try setting the BottomUp extradata (kind of like here: http://git.videolan.org/?p=ffmpeg.git;a ... 29;hb=HEAD ).

Post Reply
'