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.91k stars 497 forks source link

Packaging input to TS for HLS produces negative timestamps which are then unsupported #1290

Open Hudayberdyyev opened 9 months ago

Hudayberdyyev commented 9 months ago

System info

Operating System: macOS Soroma, Ubuntu 20.04.

Shaka Packager Version: v2.6.1-634af65-release

Issue and steps to reproduce the problem

Packager Command:

packager \
'in=video_360p.mp4,stream=audio,segment_template=audio/$Number$.aac,playlist_name=audio/main.m3u8,hls_group_id=audio,hls_name=ENGLISH' \
  'in=video_360p.mp4,stream=video,segment_template=360p/$Number$.ts,playlist_name=360p/main.m3u8' \
  --segment_duration 6 \
  --hls_master_playlist_output master.m3u8

Extra steps to reproduce the problem? (1) Download attached video file https://github.com/shaka-project/shaka-packager/assets/72361135/ce3bb1de-83f8-46d7-bbac-47cd08dc3b7d (2) Try to run command above, inside folder where video downloaded:

What is the expected result? I should get folders: 360p, audio and master.m3u8 file as a transcoded HLS video.

What happens instead?

I've got an error like below:

[1019/174447:INFO:demuxer.cc(89)] Demuxer::Run() on file 'video_360p.mp4'.
[1019/174447:INFO:demuxer.cc(155)] Initialize Demuxer for file 'video_360p.mp4'.
[1019/174447:ERROR:pes_packet_generator.cc(91)] Seeing negative timestamp (9000,-6000) after applying offset 9000. Please check if it is expected. Adjust --transport_stream_timestamp_offset_ms if needed.
[1019/174447:ERROR:demuxer.cc(356)] Failed to process sample 256 11 (MUXER_FAILURE): Failed to add sample to PesPacketGenerator.
[1019/174447:ERROR:mp4_media_parser.cc(889)] Failed to process the sample.
[1019/174447:ERROR:packager_main.cc(554)] Packaging Error: 8 (PARSER_FAILURE): Cannot parse media file video_360p.mp4

Which references to this code.

And I found a solution like below by providing transport_stream_timestamp_offset_ms as 167:

packager --transport_stream_timestamp_offset_ms 167 \
'in=video_360p.mp4,stream=audio,segment_template=audio/$Number$.aac,playlist_name=audio/main.m3u8,hls_group_id=audio,hls_name=ENGLISH' \
  'in=video_360p.mp4,stream=video,segment_template=360p/$Number$.ts,playlist_name=360p/main.m3u8' \
  --segment_duration 6 \
  --hls_master_playlist_output master.m3u8

But I don't understand why ? Can anyone explain what happened here ? And how can i calculate the value of this option to get a successfully transcode process for another videos like this ? Thanks in advance!

Hudayberdyyev commented 8 months ago

Can anyone help me with this problem ? If something is unclear, I will be happy to explain in more detail.