shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.98k stars 507 forks source link

Opus audio in WebM with negative timestamps is not supported #1218

Open Makio64 opened 1 year ago

Makio64 commented 1 year ago

System info

Operating System: MacOS 13.2 Shaka Packager Version: v2.6.1 - latest

Issue and steps to reproduce the problem

(1) encoded vp9 with ffmpeg 6.0, command argument bellow `

            '-crf', '35',
            '-b:v', '0',
            '-deadline', 'good',
            '-row-mt', '0',
            '-color_range', '1',
            '-c:a', 'libopus',
            '-c:v', 'libvpx-vp9',
            '-g', '30', 
            '-keyint_min', '30',
            '-r', '30',

(2) Fragment it with shaka classic command

What is the expected result? No problem fragmenting like with ffmpeg 5.x.x

What happens instead? Packaging Error: 8 (PARSER_FAILURE)

[0613/011030:WARNING:vp_codec_configuration_record.cc(45)] VPx video full range flag is inconsistent, 1 vs 0
[0613/011030:ERROR:representation.cc(39)] Unrecognized container type: 5
[0613/011030:ERROR:adaptation_set.cc(189)] Failed to initialize Representation.
[0613/011030:ERROR:mpd_notify_muxer_listener.cc(235)] Failed to notify MpdNotifier.
[0613/011030:ERROR:webm_cluster_parser.cc(329)] Got a block with a timecode before the previous block.
[0613/011030:ERROR:webm_cluster_parser.cc(329)] Got a block with a timecode before the previous block.
[0613/011030:ERROR:webm_cluster_parser.cc(329)] Got a block with a timecode before the previous block.
[0613/011030:ERROR:packager_main.cc(554)] Packaging Error: 8 (PARSER_FAILURE): Cannot parse media file /path/vp9_480p.webm
amlbj136 commented 1 year ago

same here, seems ffmpeg bug?

cosmin commented 11 months ago

Does it repro if you use mp4 as a container instead of webm?

vicwilliam commented 6 months ago

Hi, I've been through this and in my case it was an issue related to the audio track in the input file having a small negative padding. When you probe the input file you'll see the audio track negative timestamp

My way of "fixing" this is having audio encoded in a separate ouput file, and the video output file having no audio mapped. After applying this fix my media played without any issues. Just encode the video file with -an in ffmpeg.

andrewheadricke commented 2 months ago

Not sure if this is related but I had a similar problem (unrelated to shaka) and it turns out the ffmpeg encoder for webm+opus sometimes mucks up the order of the SimpleBlocks by timestamp. Chrome and Firefox both seem to play webm files like this no problem, but for Chrome MSE (appendBuffer) calls, it crashes out with Got a block with a timecode before the previous block error mentioned above.

If I re-order the SimpleBlocks to be in correct timestamp order before appendBuffer it plays just fine.