Skip to content

Can the AVformatContextInput::from_io_context interface add an optional AVdictionary parameter? #146

@ZKBL

Description

@ZKBL
pub fn open_memory_file(data: Arc<Vec<u8>>) -> Result<AVFormatContextInput> {
    let mut current = 0;
    let io_context = AVIOContextCustom::alloc_context(
        AVMem::new(1048576),
        false,
        vec![],
        Some(Box::new(move |_, buf| {
            let right = data.len().min(current + buf.len());
            if right <= current {
                return ffi::AVERROR_EOF;
            }
            let read_len = right - current;
            buf[0..read_len].copy_from_slice(&data[current..right]);
            current = right;
            read_len as i32
        })),
        None,
        None,
    );
    let input_format_context = match AVFormatContextInput::from_io_context(
        rsmpeg::avformat::AVIOContextContainer::Custom(io_context),
    ) {
        Ok(x) => x,
        Err(e) => {
            bail!("open file default:{}", e);
        }
    };
    Ok(input_format_context)
}

The above code will have the following output for some files

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffff0000f40] stream 0, offset 0x30: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffff0000f40] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709), 720x1280, 11185 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options

But if I use AVformatContextInput::open() to open a file that exists on disk it works fine.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions