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

Failure with multiple slices per access unit (HEVC from Teradek) #1363

Open
Brainiarc7 opened this issue Mar 7, 2024 · 9 comments
Open

Failure with multiple slices per access unit (HEVC from Teradek) #1363

Brainiarc7 opened this issue Mar 7, 2024 · 9 comments
Labels
flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this priority: P2 Smaller impact or easy workaround type: bug Something isn't working correctly
Milestone

Comments

@Brainiarc7
Copy link
Contributor

System info

Operating System: Ubuntu 22.04LTS
Shaka Packager Version: git tip master

Issue and steps to reproduce the problem:

Packaging any UDP input from a Teradek encoder errors out with:

W0306 16:11:05.555587       7 es_parser_h26x.cc:272] Failure while parsing Mpeg2TS: EmitFrame(current_access_unit_position_, next_access_unit_position_ - current_access_unit_position_, current_video_slice_info_.is_key_frame, current_video_slice_info_.pps_id)
W0306 16:11:05.555622       7 es_parser_h26x.cc:255] Failure while parsing Mpeg2TS: EmitCurrentAccessUnit()
E0306 16:11:05.555645       7 mp2t_media_parser.cc:122] Parsing failed for pid = 100, type=3
W0306 16:11:05.555807       7 mp2t_media_parser.cc:246] Failure while parsing Mpeg2TS: it->second->PushTsPacket(*ts_packet)

If I re-encode the input stream on the fly via ffmpeg, shaka-packager works without a problem.
Softvelum's Nimble streamer is also able to package this content on the fly without transcoding, only Shaka, for some reason, rejects it.

I cannot share the stream specifics here as it's copy-righted.

Any pointers?

@cosmin
Copy link
Collaborator

cosmin commented Mar 7, 2024

I believe there is a problem with parsing HEVC with slices in TS, at least some hardware encoders. I think I've seen something similar previously using Nvidia encoded HEVC with slices turned on. From what I recall repackaging the input as fMP4 didn't have an issue so there was something specific in the interaction of TS + HEVC with slices. Turning off slices in the encoder by using a different preset also didn't have any issues. But I never had a chance to dig into it beyond that.

A file to reproduce the problem would really help though.

@Brainiarc7
Copy link
Contributor Author

Brainiarc7 commented Mar 8, 2024 via email

@Brainiarc7
Copy link
Contributor Author

See the linked sample, @cosmin

@Brainiarc7
Copy link
Contributor Author

Confirm you have access to the media sample.

@cosmin
Copy link
Collaborator

cosmin commented Mar 18, 2024

@Brainiarc7 unfortunately I was traveling last week with minimal connectivity and I was not able to download the file. I tried a couple of times but it eventually timed out before the download completed (as the file was a few hundred MB). I'm back to proper internet but the download link has expired. Could you please re-share it?

@Brainiarc7
Copy link
Contributor Author

Here goes, @cosmin . Thank you!

@cosmin
Copy link
Collaborator

cosmin commented Mar 19, 2024

@Brainiarc7 thank you, I was able to download the sample and can repro the problem locally. I'll follow up once I determine what the problem is.

@cosmin
Copy link
Collaborator

cosmin commented Mar 19, 2024

Ok, doing a little digging through the debugger I believe the problem lies within EsParserH26x::EmitFrame

It pops the current_timing_desc from timing_desc_list_ which works for the single slice per frame case, however when multiple slices are being used the TimingDesc has already been consumed it ends up returning false in the

  if (current_timing_desc.pts == kNoTimestamp)
    return false;

which then results in the errors seen

es_parser_h26x.cc:276] Failure while parsing Mpeg2TS: EmitFrame(current_access_unit_position_, next_access_unit_position_ - current_access_unit_position_, current_video_slice_info_.is_key_frame, current_video_slice_info_.pps_id)
es_parser_h26x.cc:255] Failure while parsing Mpeg2TS: EmitCurrentAccessUnit()

@cosmin
Copy link
Collaborator

cosmin commented Mar 19, 2024

I believe this might require some structural changes to es_parser_h26x.cc to handle the case of multiple slices per access unit before calling EmitFrame.

@cosmin cosmin added the flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this label Mar 19, 2024
@joeyparrish joeyparrish added priority: P2 Smaller impact or easy workaround type: bug Something isn't working correctly labels Mar 19, 2024
@joeyparrish joeyparrish changed the title HEVC encoded streams from Teradek cannot be packaged with shaka-packager Failure with multiple slices per access unit (HEVC from Teradek) Mar 19, 2024
@github-actions github-actions bot added this to the v3.0 milestone Mar 19, 2024
@cosmin cosmin modified the milestones: v3.0, v3.1 Apr 26, 2024
@cosmin cosmin removed this from the v3.1 milestone May 7, 2024
@github-actions github-actions bot added this to the v3.2 milestone May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this priority: P2 Smaller impact or easy workaround type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

3 participants