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

Unable to play video with only one segment #173

Closed
kareldurdis opened this issue Sep 4, 2015 · 7 comments
Closed

Unable to play video with only one segment #173

kareldurdis opened this issue Sep 4, 2015 · 7 comments
Labels
status: archived Archived and locked; will not be updated

Comments

@kareldurdis
Copy link

I'm using 10 second segments for videos, which is perfectly fine for normal videos. However, I have a few videos that are 10 seconds long, therefore they have only one segment.

When I try to play them, shaka-player tries to fetch the second segment, but there's no second segment (to be precise, the server returns empty file with HTTP 304 Not Modified).

The MPD looks like this:

<MPD
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="urn:mpeg:dash:schema:mpd:2011"
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
  xmlns:cenc="urn:mpeg:cenc:2013"
  xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd"
  type="static"
  mediaPresentationDuration="PT10.053583S"
  maxSegmentDuration="PT11S"
  minBufferTime="PT10S"
  profiles="urn:mpeg:dash:profile:isoff-live:2011">
  <Period>
    <BaseURL>dash/</BaseURL>
    <AdaptationSet
      group="1"
      contentType="audio"
      minBandwidth="131424"
      maxBandwidth="131424"
      segmentAlignment="true"
      audioSamplingRate="44100"
      mimeType="audio/mp4"
      codecs="mp4a.40.2">
      <AudioChannelConfiguration
        schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
        value="2">
      </AudioChannelConfiguration>
      <SegmentTemplate
        timescale="44100"
        initialization="9d47cdd9-45b7-4656-b6e0-a77129f63d88-$RepresentationID$.dash"
        media="9d47cdd9-45b7-4656-b6e0-a77129f63d88-$RepresentationID$-$Number$.m4s"
        startNumber="1"
        duration="441000">
      </SegmentTemplate>
      <Representation
        id="audio=131424"
        bandwidth="131424">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      group="2"
      contentType="video"
      lang="en"
      par="16:9"
      minBandwidth="180000"
      maxBandwidth="2021000"
      minWidth="640"
      maxWidth="1280"
      minHeight="360"
      maxHeight="720"
      segmentAlignment="true"
      mimeType="video/mp4"
      codecs="avc1.4D401F"
      startWithSAP="1">
      <SegmentTemplate
        timescale="16000"
        initialization="9d47cdd9-45b7-4656-b6e0-a77129f63d88-$RepresentationID$.dash"
        media="9d47cdd9-45b7-4656-b6e0-a77129f63d88-$RepresentationID$-$Number$.m4s"
        startNumber="1"
        duration="160000">
      </SegmentTemplate>
      <Representation
        id="video_eng=180000"
        bandwidth="180000"
        width="640"
        height="360"
        scanType="progressive">
      </Representation>
    </AdaptationSet>

(I've skipped the remaining Representations in the 2nd Adaptation set as they're pretty much the same just with different bitrate).

The player just keeps buffering while trying to fetch the 2nd segment. Any idea why is that happening?

@tdrews
Copy link
Contributor

tdrews commented Sep 4, 2015

To clarify, is the player starting playback from the first segment and then failing when it attempts to fetch the non-existent second segment, or is the player trying and failing to start playback from the non-existent second segment to begin with?

@kareldurdis
Copy link
Author

He starts from the first, gets it and keeps trying to get the second.

@tdrews
Copy link
Contributor

tdrews commented Sep 4, 2015

So, the video doesn't start at all? If not, what happens if you call player.configure({'streamBufferSize': 5}); before player.load?

@kareldurdis
Copy link
Author

I was running 1.4.1 and with 5s buffer it doesn't try to load the second chunk, but it doesn't start to play either. I've just tried build from master (4d91772) - the video shows it's 20 seconds long, plays the 10 seconds, stops at 10s and tries to get the second chunk.

I'll get MPD for testing on Monday.

@kareldurdis
Copy link
Author

@tdrews I've sent you the MPD by email.

@tdrews
Copy link
Contributor

tdrews commented Sep 9, 2015

So, here's what's happening: because @mediaPresentationDuration is greater than 10 seconds and the MPD uses the SegmentTemplate + @duration MPD style, the player concludes that there must be at least two segments.

To resolve this the MPD should indicate @mediaPresentationDuration is only 10 seconds if there is only 1 segment that is 10 seconds long. Alternatively, the MPD can use the SegmentTemplate + SegmentTimeline MPD style to reduce segment start/end time ambiguity.

However, there is a small bug in the player as well: the player should assume the last segment does not extend past @mediaPresentationDuration or the Period's end. We can correct this, but @mediaPresentationDuration still needs to be accurate to ensure the player can deduce the correct number of segments.

@kareldurdis
Copy link
Author

Thanks for clarification. I did some deep digging into our tracks again:

Video track

# ffprobe -show_format -show_streams video_h264_720p_3000k.mp4
ffprobe version 2.7.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_h264_720p_3000k.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.36.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 2020 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2019 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Main
codec_type=video
codec_time_base=1/50
codec_tag_string=avc1
codec_tag=0x31637661
width=1280
height=720
coded_width=1280
coded_height=720
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=31
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=N/A
refs=3
is_avc=1
nal_length_size=4
id=N/A
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/12800
start_pts=0
start_time=0.000000
duration_ts=128000
duration=10.000000
bit_rate=2019267
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=250
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=VideoHandler
[/STREAM]
[FORMAT]
filename=video_h264_720p_3000k.mp4
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=10.000000
size=2525969
bit_rate=2020775
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:encoder=Lavf56.36.100
[/FORMAT]

Audio track

# ffprobe -show_format -show_streams audio_aac_128k.mp4
ffprobe version 2.7.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'audio_aac_128k.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf56.36.100
  Duration: 00:00:10.15, start: 0.046440, bitrate: 133 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/44100
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=44100
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=-2048
start_time=-0.046440
duration_ts=447488
duration=10.147120
bit_rate=131337
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=437
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=SoundHandler
[/STREAM]
[FORMAT]
filename=audio_aac_128k.mp4
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=-0.046440
duration=10.148000
size=169077
bit_rate=133288
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2mp41
TAG:encoder=Lavf56.36.100
[/FORMAT]

The video is exactly 10.000 seconds long. The audio is 10.148 long, because the AAC is padding to the closest block size. So the stream is correctly longer than 10 seconds. I guess that pretty much every video track that is aligned with segment length will have an additional audio segment.

That solves our mystery. Thanks a lot for assistance.

tdrews pushed a commit that referenced this issue Sep 25, 2015
For static content that uses SegmentTemplate + @duration, compress
the last SegmentReference so that it does not go beyond the
Period's duration.

Issue #173
Closes #187

Change-Id: Ifb9404ddfe267915541c035a5d6286f63f7bc032
tdrews pushed a commit that referenced this issue Oct 7, 2015
For static content that uses SegmentTemplate + @duration, compress
the last SegmentReference so that it does not go beyond the
Period's duration.

Issue #173
Closes #187

Change-Id: Ifb9404ddfe267915541c035a5d6286f63f7bc032
@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

No branches or pull requests

4 participants