Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:41:39+00:00 2026-06-07T11:41:39+00:00

I have a small problem using the video creation capability of OpenCV. For the

  • 0

I have a small problem using the video creation capability of OpenCV.

For the same images, I get a weird output depending on the output size I want.

Here is an example of the results I can get.

http://www.youtube.com/watch?v=1wm8VjyfdyA&feature=youtu.be

I tried with several different sets of images, and on different computers.
It seems to run fine on Windows, and I have problems with the Opencv that ships in Ubuntu packages (current 2.3.1-7).

As the problem is not reproductible on my windows, I guess its was either fixed in the 2.4 or specific to Linux.

Here is a (python) test code that highlight the problem :

import os
import cv

in_dir = "../data/inputs/sample-test"
out = "output.avi"


# loading images, create Guys and store it into guys
frameSize = (652, 498)
#frameSize = (453, 325)
fourcc = cv.CV_FOURCC('F', 'M', 'P', '4')
my_video = cv.CreateVideoWriter(out, 
                              fourcc, 
                              15, 
                              frameSize,
                              1)

for root, _, files in os.walk(in_dir):
    for a_file in files:
        guy_source = os.path.join(in_dir, a_file)
        print guy_source
        image = cv.LoadImage(guy_source)

        small_im = cv.CreateImage(frameSize, 
                                  image.depth ,
                                  image.nChannels)        
        cv.Resize(image, small_im, cv.CV_INTER_LINEAR)
        cv.WriteFrame(my_video, small_im)

print "Finished !"

My concern is that depending on the output size, the video is fine (652, 498 is ok for example).
The behaviour is the same whatever codec I use.

If not a fix, I´d like some more information about the reason for this bug.
As I want to ship for Ubuntu, I´d better use their packaging system and keep the 2.3 for some time.

So I would like to know how I can wisely solve the problem, by choosing educated sizes.

Any information is welcome

Thx !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:41:41+00:00Added an answer on June 7, 2026 at 11:41 am

    This is a common problem in video coding. As you can see, the image is shifted with a small amount to left each row.

    As you may know, the image is saved as a long row of chars: BGRBGRBGR….
    It is also defined by its width and height, and by step – the distance, in bytes, between two consecutive rows. A naive supposition is that the step is 3(channels)*width. But in addition, for memory alignment reasons, the image rows are padded with some extra bits, in order to make the step value a multiple of 4 (usually) or 16. The reason is that hardware codec acceleration works with aligned data – 32bit architectures read 32bits at once, and for SIMD processing, aligned data is loaded faster.

    So the image will be represented as

    BGRBGR00
    BGRBGR00
    

    Now, if a codec does not know of this padding, it will read the width of the image as 2, and will interpret the data as follows:

    BGRBGR
    00BGRB
    0000BG // note the extra padding
    

    To make sure you do not experience this issue, you should select image width in such a way that the step value (channels*width) is a multiple of four. All of the standard resolutions have this property, and this is one of the reasons they were selected so:

    640x480
    1024x768
    etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem in my code. I'm using fetch_assoc to get data
I have a small problem... There are hundreds of images in a folder. they
I have a small problem, but I'm a bit stumped. I am using the
I have a small problem using log4j and FileAppender . When I am using
I am generating new xml file using perl script but I have small problem,
I have a small Problem using reg. expressions with scanner here's the code: String
I have a small problem by using PDO instead of mysql_fetch_object . I tried
I have a small problem trying to unzip a file using the 7za command-line
I'm using Eclipse Galileo and I have a small problem. Inside one of my
Hi I have a small problem in my ANTLR tree grammar. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.