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

Strange "noise points"? #243

Closed yiyuezhuo closed 4 years ago

yiyuezhuo commented 4 years ago

I found that read generates some "noise points" in the right region. More weirdly, it gives different results on Windows and Linux.

ffmpeg result (reference, both on Windows and Linux):

image

VideoIO on linux: image

VideoIO on Windows: image

Test video: https://drive.google.com/file/d/1ThCzT_1PMkspxAktCY1bkvFFsG_IsNHc/view?usp=sharing

ffmpeg command:

ffmpeg -i out.mp4 frame%04d.png

VideoIO script:

using VideoIO
using FileIO

function fmt(x)
    s = string(x)
    "0"^(4-length(s)) * s
end

function split_frame(fname)
    io = VideoIO.open(fname)

    f = VideoIO.openvideo(io)

    img = read(f)

    let i=1
        while !eof(f)
            save("frame" * fmt(i) * ".png", img)
            i += 1
            read!(f, img)
        end
        save("frame" * fmt(i) * ".png", img)
    end
end

split_frame("out.mp4")

Do I need some extra options to avoid this? Or is there a "standard" format to make VideoIO work without such problems (The test video self is generated by ffmpeg with default parameter.)?

yiyuezhuo commented 4 years ago

I had a hard time to debug this and figure it out that it's due to avpicture deprecated problem (also see SO quesion). I compared VideoIO with PyAV, which returned the correct result, and finally got a solution. Maybe I will create a pull request to fix this, but it's not that minor though.

IanButterworth commented 4 years ago

A PR would be very welcome!