Commit Graph

1118 Commits

Author SHA1 Message Date
Joey Parrish 3fdc807ed3
feat: Add option to ignore HTTP output failures (#1449)
When uploading a live stream, if a single segment upload fails, we shouldn't give up.

This adds an option to ignore HTTP output failures so that a single failed upload does not result in a hung stream.  See https://github.com/shaka-project/shaka-streamer/issues/195 for details.
2024-11-11 10:00:09 -08:00
Joey Parrish 0957309dc2
chore: Fix "potentially uninitialized variable" errors in IAMF (#1445)
These errors were specifically coming up in Windows builds and in Linux release builds.  This initializes those variables.

This also fixes errors in IAMF tests like "offset 2 out of bounds", which some compilers raise when you try to statically initialize a vector, then add to it later.
2024-10-25 16:36:16 -07:00
Felicia Lim dc6196d3d1
feat: Add IAMF support (#1415) (#1416) 2024-10-25 09:56:28 -07:00
SteveR-PMP d88ed2798c
feat: EXT-X-SESSION-KEY support (#36) (#1427) 2024-10-25 09:55:27 -07:00
Joey Parrish ddeacb2525
feat(http): Add DELETE method support (#1442)
When we try to remove an old segment from a live stream we uploaded via HTTP, we need to send DELETE requests.
2024-10-24 20:13:04 -07:00
Joey Parrish 2c9d100d44
fix(http): Fix "Failed sending data to the peer" errors (#1443)
Upgrading curl fixes errors like "Failed sending data to the peer" flooding the log.  This is described upstream in https://github.com/curl/curl/issues/10591 and fixed in curl 8.2.0.  Here we upgrade to curl 8.9.1 (latest as of today).

This required updating the way we attach c-ares to libcurl and updating CURLOPT_PUT (deprecated) to CURLOPT_UPLOAD (compatible equivalent AFAICT).
2024-10-24 13:53:39 -07:00
Joey Parrish f07fd0d997
fix: Embed full python protobuf library (#1438)
This embeds the full python protobuf library into the output in pssh-box-protos, which is used by installation targets and Docker images.  Without this, the installed pssh-box.py tool would depend on a separate installation of the python protobuf library.

Closes #1436
2024-10-02 08:31:04 -07:00
John Laurin 9cb00e91ab
fix: Add Missing Dash Roles to RoleFromString function (#1418) (#1419)
As per issue #1418, several Dash roles are missing from the
RoleFromString function, making them unusable in practice. This update
should enable them for use.

---------

Co-authored-by: John Laurin <john.laurin@svt.se>
2024-08-28 18:59:57 -07:00
zaki699 b5c2cb8b73
fix: Break header installation for the shared library (#1407)
include/file.h is breaking header installation for the shared library build.  macros/classes.h must be included to the public headers.

Closes #1406

Co-authored-by: Zaki Ahmed <zaki.ahmed.perso@gmail.com>
Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2024-05-30 21:16:05 -07:00
Cosmin Stejerean a99cfe036f
feat: support Dolby Vision profile 8.x (HEVC) and 10.x (AV1) in HLS and DASH (#1396)
Support Dolby Vision profile 8.1, 8.2, 8.4, 10.1, 10.4 signaling in HLS
and DASH.

Adds new option `--use_dovi_supplemental_codecs` (off by default) to use
SUPPLEMENTAL-CODECS in HLS and `scte214:supplementalCodecs` and
`scte214:supplementalProfiles` for DASH.

To maintain compatibility with existing players the current behavior of
using two entries in the manifest remains the default. This will be
changed in a future version where `use_dovi_supplemental_codecs` will
become on by default.

Adds Dolby Vision compatible brands, 'db1p', 'db2g', 'db4g', 'db4h',
'dby1' based on https://mp4ra.org/#/brands

---------

Co-authored-by: Xingzhao Yun <xyun@dolby.com>
2024-05-10 17:42:34 -07:00
Cosmin Stejerean f6f60e5fff
fix: set yuv full range flag to 1 for VP9 with sRGB (#1398)
If color_space is VPX_COLOR_SPACE_SRGB, the specs says that color_range
should be 1 i.e. yuv_full_range = true. 

However, yuv_full_range was initialized as false and wasn't set in the branch for color_space
is VPX_COLOR_SPACE_SRGB.

Fixes #990

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2024-05-10 17:41:30 -07:00
Cosmin Stejerean 98b44d01df
fix: escape media URLs in MPD (#1395)
Currently `media_info.media_file_url()` is not escaped when placed into
MPD for things like BaseURL. This for example breaks when trying to us a
file name that contains special characters like &. Since these are
supposed to be URLs let's URL encode them.

Fixes #1107

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2024-05-10 17:27:13 -07:00
Cosmin Stejerean 94db9c9db3
fix: adaptation set IDs were referenced by lowest representation ID (#1394)
After change to add forced command line ordering adaptation set IDs in
places were referenced by their sort index (the minimum representation
index they contained).

Instead always refer to adaptation sets by their own ID, and use the
index only as an optional sort key.

Fixes #1393
2024-05-10 17:24:04 -07:00
sr90 a54e745cf8
refactor: merge Period::ProtectedAdaptationSetMap into AdaptationSet (#844)
---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-05-02 19:11:04 -07:00
sr90 bb104fef5d
feat: get start number from muxer and specify initial sequence number (#879)
Set the start number in representation to the segment index that is sent by muxer.

With this enhancement, you can now specify the initial sequence number
to be used on the generated segments when calling the packager.
With the old implementation, it was always starting with "1".

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-05-02 13:25:49 -07:00
Cosmin Stejerean fe885b3ade
feat: add missing DASH roles from ISO/IEC 23009-1 section 5.8.5.5 (#1390)
Fixes #1149

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2024-04-30 14:10:23 -07:00
Torbjörn Einarson 4b5e80d02c
feat: teletext formatting (#1384)
This PR adds parsing of teletext styling, and rendering of the styling
in output TTML and WebVTT subtitle tracks.

Beyond unit tests, I've used the sample
https://drive.google.com/file/d/19ZYsoeUfH85gEilQkaAdLbPhC4CxhDEh/view?usp=sharing
which has rather advanced subtitling with two separate rows at the same
time, where one is left aligned and another is right aligned. This
necessitates two parallel cues to be rendered. It also has some colored
text.

Solve #1335.

## parse teletext styling and formatting

Extend the teletext parser to parse the teletext styling and formatting.
This includes translating rows into regions, calculating alignment
from start and stop position of the text, and extracting text and
background colors.

The colors are limited to full lines.
Both lines and regions are propagated in the TextSample structures.
This is because the number of lines may differ from different sources.
For teletext, there are 24 rows, but they are essentially always
used with double height, so the number of output lines is 12
from 0 to 11.
There are also corresponding regions are denoted "ttx_R",
where R is an integer row number. A renderer can use either
the line number or the region ID to render the text.

## ttml generation for teletext to EBU-TT-D

Add support to render teletext input in EBU-TT-D (IMSC-1) format.
This includes appropriate regions ttx_0 to ttx_11 signalled
in the TextSamples, alignment and text and background colors.

The general TTML output has been changed to always include
metadata, layout, and styling nodes, even if they are empty.

EBU-TT-D is detected by the presence of "ttx_?" regions in the
samples. If detected, extra TTML elements will be added and
the EBU-TT-D linePadding used as well.

Appropriate styles for background and text colors are generated
depending on the color and backgroundColor attributes in the
text fragments.

## adapt WebVTT output to teletext TextSample.

Teletext input generates both a region with prefix ttx_
and a floating point line number (e.g. 9.5) in the
range 0 to 11.5 (due to input 0-23 as double lines).

The output is adopted to drop such regions
and convert the line number to an integer
since the standard only used floats for percent
values but not for plain line numbers.
2024-04-29 10:33:03 -07:00
Cosmin Stejerean 84009d82ef
build: turn on integration tests in ctest by default (#1381)
They can still be skipped by passing `-DSKIP_INTEGRATION_TESTS=ON` for
the build configuration. Fix integration tests so they run correctly when building out of tree.

Use FindPython3 in CMake to fix build and integration tests on Windows.
2024-04-19 07:56:49 -07:00
Cosmin Stejerean 90c3c3f9b3
fix: BaseURL missing when MPD base path is empty (#1380)
The check for `!mpd_dir.empty()` is not needed because MakePathRelative
handles the case where the parent path is empty. As a result of this
check the base url, segment url, or segment template URLs were all
missing in cases where the mpd output was in the current working
directory.

Fixes #1378
2024-03-27 12:03:10 -07:00
Cosmin Stejerean b7dd8562cf
test: fix TTML integration test where ordering was changed by #1364 (#1379) 2024-03-25 12:31:21 -07:00
Joey Parrish d83c7b1d45
fix: Fix tags in official Docker images and binaries (#1370)
The release workflows did not run checkout with `fetch-tags: true`, so
the builds were unable to compute the correct release version number. I
audited all instances of `actions/checkout` to add `fetch-tags` where
needed and clean up unneeded options.

I also had to fix options to `docker/build-push-action`, which by
default ignores `actions/checkout` and tries to pull from git itself.
This led to the Docker build running in a context without the new tag.

Finally, to make verification easier and provide version info in the
build logs, this adds debugging info to the version-generation script
via stderr.

Closes #1366
2024-03-12 13:09:38 -07:00
Cosmin Stejerean 0fd815a160
fix: duplicate representation id for TTML when forced ordering is on (#1364)
Fixes #1362
2024-03-07 10:32:09 -08:00
Anthony Lu 56440413aa
fix: use a better estimate of frame rate for cases with very short first sample durations (#838)
Use the second sample in mp4 and webm formats. #835 had issues with
merging due to golden file conflicts. Because we cannot make dependent
pull requests, this is a replica of #835.

---------

Signed-off-by: Cosmin Stejerean <cstejerean@meta.com>
Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-28 15:53:06 -08:00
Cosmin Stejerean 4d22e99f8e
fix: Restore support for legacy FairPlay system ID (#1357)
Fixes #1356 which was caused by the fix in #1281 which updated this to
use the correct FairPlay system ID. However since old versions
recognized the previous system ID this restores support for it to avoid
breaking clients.
2024-02-28 15:45:03 -08:00
Joey Parrish 9be7c2b1ac
feat: Portable, fully-static release executables on Linux (#1351)
This adds the option FULLY_STATIC to create fully-static executables.

To create portable, fully-static release executables on Linux, we need
to use musl instead of glibc. Static executables from glibc are not
portable.

The popular musl-gcc wrapper does not support C++, so instead we use a
full musl cross-compiler toolchain in the build workflow.

To build FULLY_STATIC, the user must point to the appropriate
cross-compiler, as we do in the workflow. On systems where musl is the
native libc (such as Alpine Linux), this is not necessary.

I have also read that musl's allocator is not very fast in
multi-threaded applications. So when FULLY_STATIC is enabled, we will
also enable mimalloc, a replacement allocator that is very fast.

I tested a very basic packaging command to compare speeds of dynamic
glibc, static musl, and static musl+mimalloc:

dynamic glibc:
runs: 2.527, 2.798, 2.703, 2.756, 2.959
avg = 2.749, std dev = 0.156s

static musl:
runs: 2.813, 2.920, 3.129, 3.003, 2.738
avg = 2.921s, std dev = 0.154s

static musl+mimalloc:
runs: 2.291, 2.034, 2.415, 2.303, 2.265
avg = 2.262s, std dev = 0.140s

The mimalloc build is 82% faster than musl default allocator, 77% faster
than glibc, and has more consistent runtime characteristics (lower
standard deviation).
2024-02-27 10:47:04 -08:00
Cosmin Stejerean 615720e7dd
fix: AudioSampleEntry size caluations due to bad merge (#1354)
from ALAC pull request
2024-02-27 08:57:48 -08:00
Joey Parrish 673e49d2bb
build: Disable warnings in third-party code (#1353)
We already disabled warnings-as-errors in third-party code, but this
goes futher to completely disable third-party warnings. They are mostly
noise, and distracting. If they aren't errors, we shouldn't have our
build logs flooded with them.
2024-02-26 19:57:13 -08:00
Joey Parrish 6276584de7
fix: Fix missing newline at the end of usage (#1352)
Without this, the command prompt will not appear on its own line after
running `packager` with no arguments.
2024-02-26 19:56:16 -08:00
wjywbs b68ec87f6a
feat: Add support for ALAC codec (#1299)
Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-26 13:39:30 -08:00
Joey Parrish 35c2f46428
fix: Always log to stderr by default (#1350)
This tweaks the default config for stderrthreshold from absl/log so that
we always get logs to stderr by default, as we did in v2. The --quiet
and --v flags that existed in v2 can still be used to modify the log
level, as well as the new --minloglevel from absl/log.

Issue #1325
2024-02-23 16:16:29 -08:00
Daniel Cantarín 89376d3c4d
feat: Allow LIVE UDP WebVTT input (#1349)
An updated version of PR #1027

That previous PR was done using 2021 code, and there were many changes
in the codebase from there, so a rebase was needed and also some minor
tweak here and there. But it's the same code, just reimplemented on a
newer codebase.

If you want to take a look at this in action, after building shaka
packager with this PR's code included, try this commands in 3 different
simultaneous bash sessions:

1. Video UDP input: `ffmpeg -f lavfi -re -i
"testsrc=s=320x240:r=30,format=yuv420p" -c:v h264 -sc_threshold 0 -g 30
-keyint_min 30 -r 30 -a53cc 1 -b:v 150k -preset ultrafast -r 30 -f
mpegts "udp://127.0.0.1:10000?pkt_size=1316"`
2. WebVTT UDP input: `for sec in $(seq 0 9999) ; do printf
"%02d:%02d.000 --> %02d:%02d.000\ntest second ${sec}\n\n" "$(( ${sec} /
60 ))" "$(( ${sec} % 60 ))" "$(( (${sec} + 1) / 60 ))" "$(( (${sec} + 1)
% 60 ))" ; sleep 1 ; done > /dev/udp/127.0.0.1/12345`
3. shaka packager command line: `timeout 60
path/to/build/packager/packager
'in=udp://127.0.0.1:10000?timeout=8000000,stream_selector=0,init_segment=240_init.m4s,segment_template=240_$Number%09d$.m4s,bandwidth=150000'
'in=udp://127.0.0.1:12345?timeout=8000000,stream_selector=0,input_format=webvtt,format=webvtt+mp4,init_segment=text_init.m4s,segment_template=text_$Number%09d$.m4s,language=eng,dash_roles=subtitle'
--mpd_output ./manifest.mpd --segment_duration 3.2
--suggested_presentation_delay 3.2 --min_buffer_time 3.2
--minimum_update_period 3.2 --time_shift_buffer_depth 60
--preserved_segments_outside_live_window 1 --default_language=eng
--dump_stream_info 2>&1`

Note the added `input_format=webvtt` to the shaka packager command's
second selector. That's new from this PR. If you don't use that, shaka's
format autodetection will not detect the webvtt format from the input,
as explained in
https://github.com/shaka-project/shaka-packager/issues/685#issuecomment-1029407191.
Try the command without it if you want to.

Fixes #685
Fixes #1017

---------

Co-authored-by: Daniel Cantarín <canta@canta.com.ar>
2024-02-23 16:02:19 -08:00
Cosmin Stejerean d23cce85b9
feat: add startwithSAP/subsegmentstartswithSAP for audio tracks (#1346)
Add startwithSAP/subsegmentstartswithSAP for aac, ac3, ec3 and ac4 audio tracks according to LIVE or VOD profile.

Replaces #1055
Partial solution for #364

---------

Co-authored-by: Xingzhao Yun <xyun@dolby.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
2024-02-23 15:45:46 -08:00
Cosmin Stejerean 71c175d4b8
feat: Add input support for EBU Teletext in MPEG-TS (#1344)
Replaces #1181

* Add support for EBU Teletext input following Level 1.5 of the core
specification ETSI EN 300 706 V1.2.1 (2003-04).
* Add support for webvtt in MP4 segments output.

Closes #272

---------

Co-authored-by: Marcus Spangenberg <marcus.spangenberg@eyevinn.se>
2024-02-23 15:31:48 -08:00
wjywbs 96efc5aa70
feat: Add PlayReady support in HLS. (#1011)
Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-23 15:29:13 -08:00
sr90 4aa4b4b9aa
feat: Add support for single file TS for HLS (#934)
This is based on comments at
https://github.com/google/shaka-packager/pull/891. The muxer is deciding
whether to write to a single file or a segment file based on the
configuration.

Example:
```
../packager 'in=TOS.ts,stream=video,output=tos_video.ts,playlist_name=tos_video.m3u8' \
            'in=TOS.ts,stream=audio,output=tos_audio.ts,playlist_name=tos_audio.m3u8' \
           --hls_master_playlist_output tos.m3u8
```
Tested the content using Exoplayer.

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-23 15:28:11 -08:00
Peter Zebühr 6acdcc394a
fix: http_file: Close upload cache on task exit (#1348)
In some cases it can happen that the http server responds with a
non-successful status code without reading the response body. In this
case curl may decide not to read from the cache since there is really no
point in sending data to the server. In case some other thread of shaka
has already called HttpFile::Flush it may end up deadlocked there
waiting for the cache to either close or become empty. Thus, we close
the cache when leaving the main thread as no data will be read by curl
after it has finished anyways.

Closes #1347
2024-02-23 09:30:21 -08:00
Marcus Wichelmann 76eb2c1575
feat: Add support for the EXT-X-START tag (#973)
adds an optional `--hls_start_time_offset` parameter, that, when
used, adds `EXT-X-START` tags to the HLS media playlists.

The EXT-X-START tag allows to specify the location where the player
starts playing, either from start (positive value) or from end (negative
value).
This is especially useful in case of livestreams where this tag can be
used to set the target latency of the playback.

Reference: https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.5.2

The RFC says, that the `EXT-X-START` tag could also be added to the
master playlist, but my tests have shown that most players only respect
it when it's in the media playlists.

Fixes #970

---------

Co-authored-by: Joey Parrish <joeyparrish@google.com>
2024-02-15 12:06:06 -08:00
Roy-Funderburk 07f780dae1
feat: This patch adds support for DTS:X Profile 2 audio in MP4 files. (#1303)
feat: Added audio specific configuration udts box to AudioSampleEntry
for MP4 input/output. DASH tags for DTS audio as specified in ETSI TS
103 491 and ETSI TS 102 114.

Closes #1301

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-14 23:03:03 -08:00
Marcus Wichelmann f7b3986818
fix: misleading log output when HLS target duration updates (fixes #969) (#971)
Minor fix. The parameters were swapped.
2024-02-14 22:46:02 -08:00
Marcus Wichelmann 270888abb1
fix: set array_completeness in HEVCDecoderConfigurationRecord correctly (#975)
ISO/IEC 14496-15 says about the `HEVCDecoderConfigurationRecord`:

> **array_completeness** when equal to 1 indicates that all NAL units of
> the given type are in the following array and none are in the stream; 
> when equal to 0 indicates that additional NAL units of the indicated type 
> may be in the stream; the default and permitted values are constrained 
> by the sample entry name;

This PR sets `array_completeness` to 0 if parameter NAL units may appear
in the stream when they are not stripped by
`--strip_parameter_set_nalus`.

This should increase player-compatibiltity for streams with mid-stream
SAR changes.

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-14 22:10:23 -08:00
Vishal Shah f73ad0d961
feat: HLS / DASH support forced subtitle (#1020)
Closes #988

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-14 20:27:57 -08:00
Joey Parrish e19d73321d
build: Only ever build static or shared libraries, but never both (#1343)
Closes #1341
2024-02-14 16:20:59 -08:00
Joey Parrish 1f71fa0a0e
build: Fix absl log flags being stripped (#1340)
According to a comment in
packager/third_party/abseil-cpp/source/absl/log/CMakeLists.txt, many
linkers will strip the contents of absl::log_flags because its symbols
symbols are only used in a global constructor, and that for now, clients
should link using
$<LINK_LIBRARY:WHOLE_ARCHIVE,absl::log_flags>.

Closes #1325
2024-02-14 13:59:18 -08:00
sr90 b1c5a7433e
feat(DASH): Add Label element. (#1175)
Add ability to set `Label` tag in MPD, see page 35 of DASH-IF IOP 4.3
https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf

Implements #881 

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-14 10:36:08 -08:00
SteveR-PMP aad2a12a9d
feat: order streams in manifest based on command-line order (#1329)
This will force the muxer to order streams in the order given on the
command-line.

Closes #560
Closes #1280
Closes #1313

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
2024-02-14 09:21:11 -08:00
Joey Parrish df04d0ed6e
chore: Unfork zlib (#1339)
The issues we had with zlib and CMake have been resolved upstream.
2024-02-12 14:10:51 -08:00
Michał Idzikowski 9193a90f5a
chore: upgrade to alpine 3.19 (#1327)
Co-authored-by: Joey Parrish <joeyparrish@google.com>
2024-02-10 09:25:37 -08:00
Joey Parrish 15b27549a8
chore: Upgrade absl and protobuf (#1337)
protobuf depends on absl, so both needed an update.

Updating absl fixes issues on Alpine 3.19 (see PR #1327), and also
removes the need for hacks around vlog flags.
2024-02-09 20:57:12 -08:00
Joey Parrish 9b384828c6
build: Do not treat third-party warnings as errors (#1338) 2024-02-09 19:10:08 -08:00
modernletter c09eb831b8
feat: Parse MPEG-TS PMT ES language and maximum bitrate descriptors (#369) (#1311)
Part of https://github.com/shaka-project/shaka-packager/issues/369

This adds read support for some MPEG-TS PMT elementary stream
descriptors:
- ISO639 Language Descriptor providing language code and audio type
- Maximum Bitrate Descriptor providing peak stream bandwidth

Those metadata are propagated to StreamInfo structures:
- StreamInfo.language field
- AudioStreamMetadata.max_bitrate field for audio streams
- audio type is currently not propagated - corresponding field has to be
added to AudioStreamMetadata

Test vector file containing those descriptors is provided.
2024-02-08 11:58:26 -08:00