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

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

Open
ZKBL opened this issue Jan 23, 2024 · 1 comment
Assignees

Comments

@ZKBL
Copy link

ZKBL commented Jan 23, 2024

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.

@ldm0 ldm0 self-assigned this Jan 23, 2024
@sw-vish
Copy link

sw-vish commented Oct 7, 2024

Hi, just wondering if there's been any progress on this, since I've got a similar use case?

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

3 participants