JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
128 stars 53 forks source link

ERROR: `convert` has no method matching convert(::Type{AVFrame}) in v"0.4-dev" #48

Closed maxruby closed 9 years ago

maxruby commented 10 years ago

In julia dev v0.4.0, opencamera complains about "convert" of ::Type{AVFrame}.

julia> f = opencamera()
[avfoundation @ 0x7fd0fc89a200] Selected pixel format (yuv420p) is not supported by the input  
device.
[avfoundation @ 0x7fd0fc89a200] Supported pixel formats:
[avfoundation @ 0x7fd0fc89a200]   uyvy422
[avfoundation @ 0x7fd0fc89a200]   yuyv422
[avfoundation @ 0x7fd0fc89a200]   nv12 
[avfoundation @ 0x7fd0fc89a200]   0rgb
[avfoundation @ 0x7fd0fc89a200]   bgr0 
ERROR: `convert` has no method matching convert(::Type{AVFrame})

julia> close(f)
ERROR: f not defined
lucasb-eyer commented 10 years ago

Getting that in openvideo too (after fixing #49):

 julia> v = VideoIO.openvideo("/home/beyer/data/bbenfold/TownCentreXVID.avi")
ERROR: `convert` has no method matching convert(::Type{AVFrame})
 in VideoReader at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:303
 in VideoReader at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:281
 in VideoReader at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:364
 in openvideo at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:482
lucasb-eyer commented 10 years ago

I think it's because the function AVFrame is not defined for newer versions of ffmpeg. If I grep for it, all I find is:

><((("> ag 'function AVFrame'                                                                                                                                                 lb
src/libav/AVUtil/v53/LIBAVUTIL.jl
22:function AVFrame()

src/libav/AVCodecs/v54/LIBAVCODEC.jl
5:function AVFrame()

src/libav/AVCodecs/v53/LIBAVCODEC.jl
5:function AVFrame()

src/ffmpeg/AVUtil/v52/LIBAVUTIL.jl
26:function AVFrame()

src/ffmpeg/AVCodecs/v53/LIBAVCODEC.jl
7:function AVFrame()

compare to:

julia> VideoIO.versioninfo()
Using ffmpeg
AVCodecs version 56.1.100
AVFormat version 56.4.101
AVUtil version 54.7.100
SWScale version 3.0.100
AVDevice version 56.0.100
AVFilters version 5.1.100
maxruby commented 10 years ago

Actually, I find AVFrame() in

src/ffmpeg/AVUtil/v54/LIBAVUTIL.jl
src/ffmpeg/AVUtil/v52/LIBAVUTIL.jl

Now, the following sequence of calls for AVFrame()

using VideoIO 
     using AVUtil
           AVUtil/src/AVUtil.jl
                include(w("LIBAVUTIL.jl"))
                          => function AVFrame()

According to this, AVFrame() should be loaded. However, the conversion is still a problem with Type{AVFrame}, which we need to locate in the code.

maxruby commented 10 years ago

The error is most definitely at lines 296 and 299 in src/avio.jl

    # Type AVFrame is indeed defined in VideoIO
    julia> typeof(VideoIO.AVFrame)
    DataType

    # However, initializing it as a vector in function VideoReader() fails
    julia> aVideoFrame = [VideoIO.AVFrame()]
    ERROR: `convert` has no method matching convert(::Type{AVFrame})

    julia> aTargetVideoFrame = [VideoIO.AVFrame()]
    ERROR: `convert` has no method matching convert(::Type{AVFrame})

Something about the conversion of AVFrame in v0.4-dev is the source of the failure. Lets see if we can fix this.

maxruby commented 10 years ago

Sorry, I have 2 separate installations of VideoIO (one with v0.3 which works fine and a second one under v0.4-dev). The one associated with v0.4-dev was missing AVFrame(). I added AVFrame() alone to

 src/ffmpeg/AVUtil/v54/LIBAVUTIL.jl

This fixed the problem and now opencamera() works. Can you try it on your side with openvideo() to confirm this works for you too?

lucasb-eyer commented 10 years ago

I was about to suggest trying to call AVFrame() in the terminal :) Yes, that works. I didn't want to just copy-paste it over from v52 because I wonder

  1. Why it's not there in the first place; is it supposed to be added automatically by the wrapping script, or has it always been added manually?
  2. If it's to be added manually, isn't there a better place to add it, so it doesn't need to be duplicated code for all versions? I don't know much at all about VideoIO's internals.
maxruby commented 10 years ago

It should be relatively easy to reduce duplication in VideoIO but I would suggest to wait until #47 is processed. Regarding AVFrame, it is a custom function likely added manually to LIBAVUTIL.jl

kmsquire commented 9 years ago

Just to verify: yes, AVFrame was added by hand. I also added it by hand to src/ffmpeg/AVUtil/v54/LIBAVUTIL.jl, as @maxruby did above, and committed that change as part of 26b301cb. Can you run Pkg.update() and see if this is fixed?

@maxruby, sorry, this is going to screw up your pull request.

Since both of you have push access, please feel free to push fixes for things like these in the future. If you're unsure, you can always just make a pull request, but anything obviously wrong can be fixed again in the future.

(Obviously, if you don't have time for a fix, a bug report is still welcome!) Cheers, and sorry for the delay.

lucasb-eyer commented 9 years ago

It works, thanks.

I forgot I had push access, sorry^^

kmsquire commented 9 years ago

No worries--glad it's fixed!

Somewhat related, at some point, there was discussion of moving a few repositories to a JuliaImages (or some such) organization. I'll try to get that discussion going again this week.

lucasb-eyer commented 9 years ago

Sounds good, please ping when you do.