Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to obtain frame data and side_data in decode() #377

Closed
zsz00 opened this issue Aug 4, 2022 · 1 comment
Closed

how to obtain frame data and side_data in decode() #377

zsz00 opened this issue Aug 4, 2022 · 1 comment

Comments

@zsz00
Copy link
Contributor

zsz00 commented Aug 4, 2022

I want to obtain frame data at ahead and behind line 446 in avio.jl

fret = avcodec_receive_frame(r.codec_context, graph_input_frame(r))

how to output the AVFrame data ? It's contain metadata and side_data what i want to get.

@zsz00
Copy link
Contributor Author

zsz00 commented Sep 28, 2023

I know what's going on.

modification: avio.jl # 301

opts = AVDict("flags2" => "+export_mvs") 
ret = avcodec_open2(codec_context, codec, opts)  # C_NULL

modification : avio.jl: # 449 decode()

frame = graph_input_frame(r)
fret = avcodec_receive_frame(r.codec_context, frame)  # 解码获取frame. 
if fret >= 0
    sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS)  
    if sd != C_NULL
        sd_1 = unsafe_load(sd)   # pointer(sd.data)
        size_1 = sd_1.size
        mvs = Ptr{AVMotionVector}(sd_1.data)
        mvs_num = Int(size_1 ÷ sizeof(AVMotionVector))
        for i in 1:mvs_num
            mv = unsafe_load(mvs, i)
            println("mv:", join((mv.source, mv.w, mv.h, mv.src_x, mv.src_y, mv.dst_x, mv.dst_y, mv.flags), ','))
        end
    end
end

@zsz00 zsz00 changed the title how to obtain frame data in decode() how to obtain frame data and side_data in decode() Sep 28, 2023
@zsz00 zsz00 closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant