JuliaIO / VideoIO.jl

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

Cannot read video from IO Stream #291

Open galenlynch opened 3 years ago

galenlynch commented 3 years ago

The documentation and method signatures of AVInput and VideoReader suggests that it should be possible to read a video from a IO object. However, this only works for some kinds of videos, and doesn't seem to work for mp4 videos:

julia> using VideoIO, VideoIO.TestVideos

julia> vid_path = "/home/glynch/Documents/Code/VideoIO/videos" # wherever your videos directory is

julia> ogg_path = joinpath(vid_path, TestVideos.names()[1])
"/home/glynch/Documents/Code/VideoIO/videos/annie_oakley.ogg"

julia> io_ogg = open(ogg_path, "r")
IOStream(<file /home/glynch/Documents/Code/VideoIO/videos/annie_oakley.ogg>)

julia> v = openvideo(io_ogg) # This works
VideoReader(...)

julia> size(read(v)) # success!
(240, 320)

julia> mp4_path = joinpath(vid_path, TestVideos.names()[3])
"/home/glynch/Documents/Code/VideoIO/videos/ladybird.mp4"

julia> io_mp4 = open(mp4_path, "r")
IOStream(<file /home/glynch/Documents/Code/VideoIO/videos/ladybird.mp4>)

julia> v = openvideo(io_mp4) # No dice
ERROR: Unknown pixel format
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] VideoIO.VideoReader(::VideoIO.AVInput{IOStream}, ::Int64; transcode::Bool, transcode_interpolation::Int64, target_format::Int32) at /home/glynch/Documents/Code/VideoIO/src/avio.jl:272
 [3] VideoReader at /home/glynch/Documents/Code/VideoIO/src/avio.jl:262 [inlined] (repeats 2 times)
 [4] #VideoReader#5 at /home/glynch/Documents/Code/VideoIO/src/avio.jl:355 [inlined]
 [5] VideoReader at /home/glynch/Documents/Code/VideoIO/src/avio.jl:355 [inlined]
 [6] #openvideo#6 at /home/glynch/Documents/Code/VideoIO/src/avio.jl:491 [inlined]
 [7] openvideo(::IOStream) at /home/glynch/Documents/Code/VideoIO/src/avio.jl:491
 [8] top-level scope at REPL[5]:1

There does not seem to be a test that covers this use case.