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 use BufferCallbackParams with gstreamer #1268

Closed
felibol opened this issue Sep 26, 2023 · 3 comments
Closed

How to use BufferCallbackParams with gstreamer #1268

felibol opened this issue Sep 26, 2023 · 3 comments

Comments

@felibol
Copy link

felibol commented Sep 26, 2023

System info

Operating System: 18.04.5 LTS (Bionic Beaver)
Shaka Packager Version: main branch cc9a691

Question

I am trying to integrate shaka packager to gstreamer pipeline with using c-api.
I have added gstreamer app sink and receiving encoded H265 video byte data. I have also configured shaka packager like below

    m_packaging_params.chunking_params.segment_duration_in_seconds = m_target_duration;
    m_packaging_params.output_media_info = true;

    m_packaging_params.hls_params.playlist_type = shaka::HlsPlaylistType::kLive;
    m_packaging_params.hls_params.master_playlist_output = pl_path;
    m_packaging_params.hls_params.target_segment_duration = m_target_duration;

    m_packaging_params.buffer_callback_params.read_func = [this](const std::string &name,
                                                                 void *buffer, uint64_t size) {
        return this->readInputBuffer(name, buffer, size);
    };

    shaka::StreamDescriptor stream_descriptor;
    stream_descriptor.input = "video";
    stream_descriptor.stream_selector = "video";
    stream_descriptor.output = video_folder + "init.mp4";
    stream_descriptor.skip_encryption = true;
    stream_descriptor.hls_playlist_name = "playlist.m3u8";
    stream_descriptor.hls_only = true;
    m_stream_descriptors.push_back(stream_descriptor);

Inside read_func, I am filling buffer and expecting packaging to produce fragmented mp4 HLS stream. But I am getting below error

[0925/201922:ERROR:demuxer.cc(205)] Failed to detect the container type from the buffer: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
[error] Packager running failed. 3 (INVALID_ARGUMENT): Failed to detect the container type.

As I understand packager expect already packaged content at the input not the raw encoded data. My question is can I use shaka packager to directly package raw encoded video and encoded audio data? If possible can you also share a minimal example to show buffer callback params usage?

Thanks.

@felibol
Copy link
Author

felibol commented Sep 27, 2023

I even tested with first muxing to mpegts at gstreamer and then fill buffer with the mpegts packets but still getting same error at packager.

@rantoniello
Copy link

Hi Felibol,

Recently I came across this issue, despite is a bit old: are you still trying to solve it?

Your code should work perfectly, just be careful your TS stream is standard thus having the necessary tables (PAT, PMT, ...), and in the implementation of the function 'readInputBuffer', respect the TS packet boundary (that is, do not "cut" de buffer in the middle of a TS packet). In consequence, for each input buffer, make sure you are synchronizing to TS packet boundary (start code 0x47) and you are sending entire TS packets (once synchronized, you should fill the buffer with a multiple of 188 bytes).
Using exactly the same code as yours, I can confirm this works.

Kind Regards.

@cosmin cosmin added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Apr 29, 2024
Copy link

github-actions bot commented May 6, 2024

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.

@github-actions github-actions bot closed this as completed May 6, 2024
@github-actions github-actions bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 6, 2024
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