Skip to content

Iphone video read output changes with FFMPEG 3.3 #252

Closed

Description

@chenliu0831

Recently we upgrade from FFMPEG 3.2 to 3.3. It seems imageio is giving out frames (mov and mp4s) from row-major to column-major. Not sure if this is an imageio or ffmpeg problem.. Anyone else seeing this?

Activity

  1. chenliu0831 commented on May 12, 2017

    @chenliu0831
    Author

    update: ffmpeg 3.3 dumps to pngs just fine. But it might be related to https://trac.ffmpeg.org/ticket/6370

  2. almarklein commented on May 20, 2017

    @almarklein
    Member

    Does it do this with this too:

    import imageio
    with imageio.get_reader('imageio:cockatoo.mp4') as reader:
        for im in reader:
            print(im.shape)
    

    I get the correct shape (720, 1280, 3) on Linux with the new binaries that I just uploaded (3.3.1).

  3. almarklein commented on May 21, 2017

    @almarklein
    Member

    Reading this again, I wonder whether you meant that the images were rotated, or whether the arrays where in F mode instead of C mode.

  4. chenliu0831 commented on May 30, 2017

    @chenliu0831
    Author

    @almarklein sorry I was on vacation. yeah I mean the shape appears to be correct, but the array seems to be filled in F mode.

  5. almarklein commented on May 30, 2017

    @almarklein
    Member

    No need to apologize for a vacation :)

    Interesting case. I am not sure whether imageio should take a stance on whether image data should be produced in C mode or F mode. Most libs that need either mode will convert if necessary. So if your code depends on the data being in C-mode, you should probably use something like:

    im = np.array(im, copy=False, order='C')

    which will convert if needed, or let the image pass through otherwise.

    @blink1073 what do you think? Also cc @kuchi

  6. blink1073 commented on May 30, 2017

    @blink1073

    Sounds fair to me.

  7. chenliu0831 commented on May 31, 2017

    @chenliu0831
    Author

    @almarklein Cool that's a great workaround. If you guys think the root cause might be in ffmpeg feel free to close this one. Thanks.

  8. chenliu0831 commented on Jun 1, 2017

    @chenliu0831
    Author

    Ah looks like it's not the byte order problem. For context, I got WARNING:root:Warning: the frame size for reading (1080, 1920) is different from the source frame size (1920, 1080). from an iphone mp4 (or .mov ). And with ffmpeg 3.2.4 I got correct image with dimension 1080 * 1920 but with ffmpeg 3.3.1 I got 1920 × 1080.

  9. almarklein commented on Jun 2, 2017

    @almarklein
    Member

    Ok, so this issue should be reopened?

  10. chenliu0831 commented on Jun 2, 2017

    @chenliu0831
    Author

    @almarklein I think so. Thanks

  11. almarklein commented on Jun 3, 2017

    @almarklein
    Member

    Can I get a (sample of) a video to reproduce this issue?

  12. chenliu0831 commented on Jun 4, 2017

    @chenliu0831
    Author

    @almarklein could you try this link?

  13. changed the title [-]imageio with FFMPEG 3.3 read video pixels in opposite order[/-] [+]Iphone video read output changes with FFMPEG 3.3[/+] on Jun 6, 2017
  14. almarklein commented on Jun 16, 2017

    @almarklein
    Member

    I get this (with ffmpeg 3.3.2):

    import imageio
    ims = imageio.mimread('c:/data/imageio_issue252.mp4')
    print(ims[0].shape)
    print(ims[0].flags)
    (1920, 1080, 3)
      C_CONTIGUOUS : True
      F_CONTIGUOUS : False
      OWNDATA : False
      WRITEABLE : True
      ALIGNED : True
      UPDATEIFCOPY : False
    
  15. chenliu0831 commented on Jun 19, 2017

    @chenliu0831
    Author

    @almarklein right and in mac finder it shows 1080*1920 and if I use raw ffempg (either 3.3 or 3.2) to dump individual frames as jpgs it looks correct.

  16. chenliu0831 commented on Jun 22, 2017

    @chenliu0831
    Author

    @almarklein any update on this? it seems you were testing it under windows? On mac/linux I'm still getting the incorrect shape with 3.3+

  17. almarklein commented on Jun 23, 2017

    @almarklein
    Member

    Are you sure that the shape is incorrect? In imageio, its typical for images stored in numpy arrays to have a shape that is (height, width). I suspect that Finder reports width*height. Maybe try this:

    import imageio
    ims = imageio.mimread('c:/data/imageio_issue252.mp4')
    print(ims[0].shape)
    print(ims[0].flags)
    
    import matplotlib.pyplot as plt
    plt.imshow(ims[0])
    plt.show()
    
    
  18. chenliu0831 commented on Jun 23, 2017

    @chenliu0831
    Author

    Yeah.... see below.
    figure_1

  19. chenliu0831 commented on Jul 13, 2017

    @chenliu0831
    Author

    @almarklein Just check in if you got any chance to look into this issue?

  20. almarklein commented on Jul 14, 2017

    @almarklein
    Member

    I'm not exactly sure what we can do. I guess we can start with posting a possible workaround here (i.e. how to correct the image). But I don't think that we can reliably detect the case (consider this a challenge to proof me wrong).

    Have you found a way to swizzle your image to make it correct again? If not, can you send me the image in npz format so I can have a go?

  21. chenliu0831 commented on Aug 25, 2017

    @chenliu0831
    Author

    @almarklein I'm closing this issue and for context I would recommend people either swizzle manually or use the default installation function built-in from imageio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions