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

Sound pops & clicks when playing HLS stream by using Safari native playback #1206

Open
emmitrin opened this issue May 10, 2023 · 1 comment
Labels
component: HLS The issue involves HLS output

Comments

@emmitrin
Copy link

System info

Operating System: macOS Ventura 13.2
Shaka Packager Version: packager-osx-x64 version v2.6.1-634af65-release

Issue and steps to reproduce the problem

I have the following input files:

  • video.mp4 – h264 video w\ sound or subtitle streams
  • audio0.m4a – first voice actor
  • audio1.m4a – second voice actor

I'm trying to make a HLS stream containing the video and two audio tracks:

Packager Command:

packager \
'in=video.mp4,stream=video,segment_template=720p/$Number$.ts,playlist_name=720p.m3u8,iframe_playlist_name=720p_iframe.m3u8' \
'in=audio0.m4a,stream=audio,segment_template=audio0/$Number$.ts,playlist_name=audio0/main.m3u8,hls_group_id=audio,hls_name=First_actor' \ 
'in=audio1.m4a,stream=audio,segment_template=audio1/$Number$.ts,playlist_name=audio1/main.m3u8,hls_group_id=audio,hls_name=Second_actor' \ 
--hls_master_playlist_output 720p_master.m3u8

The resulting stream is playing fine in hls.js-powered players, but I can constantly hear choppy clicking sound when trying to play the stream via Safari's native HLS playback.

When I switch the segment_template file extension for audio streams to .aac, everything is fine for both Safari and hls.js.

But I'm locked to MPEG-2 container for audio streams because I also need raw SAMPLE-AES encryption which is supported only for MPEG-2 TS in Hls.js.

Is this happening due to ID3 com.apple.streaming.transportStreamTimestamp tag getting lost when the audio is stored in .ts segments separated from the video?

Is there anything related to Shaka packager that may fix this issue?

@emmitrin
Copy link
Author

ffprobe for input audio file
{
    "streams": [
        {
            "index": 0,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "id": "0x1",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 70435824,
            "duration": "1467.413000",
            "bit_rate": "130085",
            "nb_frames": "68786",
            "extradata_size": 5,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "eng",
                "handler_name": "SoundHandler",
                "vendor_id": "[0][0][0][0]"
            }
        }
    ],
    "format": {
        "filename": "audio0.m4a",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "1467.413000",
        "size": "24677419",
        "bit_rate": "134535",
        "probe_score": 100,
        "tags": {
            "major_brand": "M4A ",
            "minor_version": "512",
            "compatible_brands": "M4A isomiso2",
            "title": "testvideo",
            "encoder": "Lavf59.27.100"
        }
    }
}

@cosmin cosmin added the component: HLS The issue involves HLS output label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: HLS The issue involves HLS output
Projects
None yet
Development

No branches or pull requests

2 participants