hls aes encrypted video not playing after EXT-X-DISCONTINUITY tag on ios - ios

It looks like the ios doesn't like hls m3u8 files that mixes encrypted .ts files with the EXT-X-DISCONTINUITY tag.
Here is a test play list, it's a mix of two video. a preroll ad un encrypted and the main encrypted video. Both plays well separatly but when I put them together in a single m3u8, separated by a EXT-X-DISCONTINUITY, only the preroll is played and then the player stop.
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/vig_400-0.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/vig_400-1.ts
#EXT-X-DISCONTINUITY
#EXTINF:10,
#EXT-X-KEY:METHOD=AES-128,URI="http://ixemes-ppweb.ixemes.com/prerollmain/113760.key"
http://ixemes-ppweb.ixemes.com/prerollmain/02-0.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-1.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-2.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-3.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-4.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-5.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-6.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-7.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-8.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-9.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-10.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-11.ts
#EXTINF:2,
http://ixemes-ppweb.ixemes.com/prerollmain/02-12.ts
#EXT-X-ENDLIST
I have tryed with two un-encrypted videos and it works. And I see nothing in the HLS specs that says it's forbidden to use the EXT-X-DISCONTINUITY tag with encrypted videos : https://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming-08#section-6.3.3
So I guess it's apple implementation of it's own specs that is wrong, but maybe it's me doing it wrong.
I have made a quick html page to test it (open it in safari on any ios5 device) : http://ixemes-ppweb.ixemes.com/prerollmain/index.html

I noticed your EXT-X-KEY doesn't have an IV term, a.k.a. an initialization vector. This is supported by the standard, e.g.:
#EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=52",IV=0x9c7db8778570d05c3177c349fd9236aa
If this is missing, here's how https://developer.apple.com/library/ios/technotes/tn2288/_index.html says the player should pick the IV:
The default Initialization Vector for media encryption (if none is
specified) is the sequence number of the media file. You should
specify an Initialization Vector value, and not rely on sequence
numbers. The main reason for this is portability. For example, if you
change where the segment appears in the playlist (e.g. inserting an
ad), that changes its sequence number, requiring a re-encrypt.
On my team we were having trouble figuring out why encrypted content with inserted ads weren't playing. We had an example of encrypted content that played:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=AES-128,URI="http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key"
#EXTINF:11,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-1.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-2.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-3.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-4.ts
#EXTINF:10,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-5.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-6.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-7.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-8.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-9.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-10.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-11.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-12.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-13.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-14.ts
#EXTINF:5,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-15.ts
#EXT-X-ENDLIST
You can try this at http://demo.theplatform.com/dev/m3u8/encrypted.m3u8. But then when we inserted content before it, like this, it didn't play:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=NONE
#EXTINF:10.01,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00001.ts
#EXTINF:5.088,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00002.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=AES-128,URI="http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key"
#EXTINF:11,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-1.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-2.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-3.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-4.ts
#EXTINF:10,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-5.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-6.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-7.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-8.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-9.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-10.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-11.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-12.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-13.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-14.ts
#EXTINF:5,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-15.ts
#EXT-X-ENDLIST
This URL is http://demo.theplatform.com/dev/m3u8/mix.m3u8. The problem, we figured out, was because we added two segments, the media sequence number was now off by 2. If you explicitly set the IV to "0x00000000000000000000000000000001", like this:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=NONE
#EXTINF:10.01,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00001.ts
#EXTINF:5.088,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00002.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=AES-128,URI="http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key",IV=0x00000000000000000000000000000001
#EXTINF:11,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-1.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-2.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-3.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-4.ts
#EXTINF:10,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-5.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-6.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-7.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-8.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-9.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-10.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-11.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-12.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-13.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-14.ts
#EXTINF:5,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-15.ts
#EXT-X-ENDLIST
Then it works. You can try this as http://demo.theplatform.com/dev/m3u8/mix_fixed.m3u8. So maybe that was the issue you were running into.

Ok it looks like it's not related to the encrytion of the main video but more how the main video is encoded. I don't have control on how the main video is encoded. I only encoded (and chuncked) myself the preroll video for testing purpose.
If i mix the preroll with the same main video but un encrypted, it doesn't work also.
if i mix two video encoded by the same exteral encoder, encrypted (or not) it doesn't work.
Don't know whats wrong with then encoding parameters of the external encoder, but the discontinuity tag doesn't works it.
But if i encode myself both video (preroll and main), encrypt the main one, and put them in a single m3u8 file using the discontinuity tag, it works.
So there is still something wrong of how ios handles the discontinuity tag and doesn't fully reset the player parameters, but at least it's possible to insert a un encrypted preroll video before an encrypted one.

Related

How to create an index of songs in the Songs package using Texmaker?

I cannot install the package with the MikTex setup and I have tried to add some "own" songs to the sample document, as instructed in the guide. My songs and authors do not get included though - even if I build more than once.
How do I (from scratch) get an index of songs (maybe also authors) included in my document? And while we are at it, how do I include a table of contents that contains the song sections and an ordered list of the songs in each song section, in order as they appear in the song book?
I have the following structure of the tex file:
\documentclass[a5paper,twoside,article, landscape, twocolumn]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage[T1]{fontenc}
\usepackage[lyric]{songs}
\usepackage[bookmarks]{hyperref}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\textwidth}{7in}
\setlength{\topmargin}{0in}
\setlength{\topskip}{0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textheight}{4.1in}
\settowidth{\versenumwidth}{1.\ }
\pagestyle{empty}
\begin{document}
\begin{songs}{}
\beginsong{Velkommen igen, Guds engle små}
[by={N F S Grundtvig, A P Berggreen}]
\beginverse
Velkommen igen, Guds engle små,
...
\endverse
\beginverse
Velkommen igen, Guds engle små,
...
\endverse
\beginverse
Vor hytte er lav og så vor dør,
...
\endverse
\endsong
\beginsong{Dejlig er den himmel blå}[by={Louis Bourgeois and Thomas Ken},
sr={Revelation 5:13},
cr={Public domain.}]
\beginverse
Dejlig er den himmel blå
...
\endverse
\beginchorus
Os fra jorden op til sig
Os fra jorden op til sig
\endchorus
\endsong
\end{songs}
\end{document}
Based on that how do I get a list of songs in the order of appearance in the document, like:
Velkommen igen, Guds engle små
Dejlig er den himmelblå
and at the end of the document, an index with the songs by alphabetical order, with page numbers

How to convert Rmarkdown file to working latex file

I have written a manuscript I would like to submit to a journal in Rmarkdown. The journal accepts word and latex files, so I am looking for a way to generate a working .tex file out of my .Rmd file.
I have read some posts that allude to this being possible (e.g., How to generate LaTeX file without preamble in R markdown?) and this is getting me some of the way, but I am still having problems.
For example, using the method mentioned in the post above, I can convert a test .Rmd into something with a .tex filetype. This is the test Rmarkdown (just the usual template for new files):
---
title: "Test document"
author: "Me"
date: "23 7 2020"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
This compiles fine to PDF as it should. Then, in the console I run:
knitr::knit("test.Rmd")
to get a markdown file test.md in my working directory, and then I can apparently convert this .md file to .tex with
rmarkdown::pandoc_convert("test.md", to = "latex", output = "test.tex")
This produces a .tex file that, when I double click on it, pops up a PDF view of the file that looks fine. Taking a look at the file though, it is incomplete or at least unfamiliar to me:
\hypertarget{r-markdown}{%
\subsection{R Markdown}\label{r-markdown}}
This is an R Markdown document. Markdown is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents. For more details on
using R Markdown see \url{http://rmarkdown.rstudio.com}.
When you click the \textbf{Knit} button a document will be generated
that includes both content as well as the output of any embedded R code
chunks within the document. You can embed an R code chunk like this:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{summary}\NormalTok{(cars)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
\end{verbatim}
\hypertarget{including-plots}{%
\subsection{Including Plots}\label{including-plots}}
You can also embed plots, for example:
\begin{figure}
\centering
\includegraphics{figure/pressure-1.png}
\caption{plot of chunk pressure}
\end{figure}
Note that the \texttt{echo\ =\ FALSE} parameter was added to the code
chunk to prevent printing of the R code that generated the plot.
As far as I can tell, it is missing the preamble, \begin{document}, \end{document}, and I have no idea what is going on with hypertarget bit of the section headers. Unsurprisingly, it does not "re-compile" when I hit run in MiKTeX. The verbatim bits for the code chunks look to be what I'm after, though.
So, is there a way to generate a .tex file that compiles out of an .Rmd file? Or will I have to manually write the preamble and all that? If the answer to my problem is "read up pandoc", then fair enough, I will have to bite the bullet and finally have a look at it. But I find it hard to imagine that there is no good (easy) way to prepare submittable manuscripts in Rmarkdown.
Pandoc generates LaTeX snippets by default, i.e., not a full document. This can be changed by calling pandoc with the --standalone option:
rmarkdown::pandoc_convert(
"test.md",
to = "latex",
output = "out.tex",
options = "--standalone"
)
You can let R do the work and shorten your commands to
render("test.Rmd", output_format = "latex_document")
A project of interest might be rticles.

Can a byte-range in a m3u8 playlist be length 0?

According to the HLS Pantos spec, a byte-range in a m3u8 playlist should look like #EXT-X-BYTERANGE:<n>[#<o>] where "n is a decimal-integer indicating the length of the sub-range in bytes".
However, this doesn't specify if "n" can be 0 or negative. This is a particular issue for caption playlists which may have a gap where no captions appear...
Is this a valid playlist?
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-VERSION:4
#EXTINF:10.0,
#EXT-X-BYTERANGE:100#0
media.ts
#EXTINF:10.0,
#EXT-X-BYTERANGE:0#100
media.ts
#EXTINF:10.0,
#EXT-X-BYTERANGE:50#100
media.ts
No, playlist entries with a byte-range length of 0 are NOT valid.
Byte-range can not be zero in any case. I don't think any streamer will send zero value for this.

Parsing Dublin Core data

How do I parse Dublin Core data in iOS? The data is like this:
dc:contributor Binder, Henry.
dc:creator Crane, Stephen, 1871-1900.
dc:date c1982
dc:description This stirring tale of action in the American Civil War captures the immediacies and experiences of actual battle and army life.
dc:format ix, 173 p. ; 22 cm.
dc:identifier 0393013456
dc:identifier 9780393013450
dc:identifier 0380641135 (pbk.)
dc:identifier 9780380641130 (pbk.)
dc:language eng
dc:publisher Norton
dc:subject Chancellorsville, Battle of, Chancellorsville, Va., 1863--Fiction.
dc:subject Virginia--History--Civil War, 1861-1865--Fiction.
dc:title The red badge of courage : an episode of the American Civil War
dc:type War stories.
dc:type Historical fiction.
dc:type Text
oclcterms:recordCreationDate 811217
oclcterms:recordIdentifier 81022419
oclcterms:recordIdentifier 8114241
It looks like your data structure structure has a predictable format, ie each line has a clear tag and then a tab-like space.
Hence if you are familiar with the tag names you can definitely create a small program to consume each line accordingly.

ANTLR on a noisy data stream

I'm very new in the ANTLR world and I'm trying to figure out how can I use this parsing tool to interpret a set of "noisy" string. What I would like to achieve is the following.
let's take for example this phrase : It's 10PM and the Lazy CAT is currently SLEEPING heavily on the SOFA in front of the TV
What I would like to extract is CAT, SLEEPING and SOFA and have a grammar that match easily the following pattern : SUBJECT - VERB - INDIRECT OBJECT... where I could define
VERB : 'SLEEPING' | 'WALKING';
SUBJECT : 'CAT'|'DOG'|'BIRD';
INDIRECT_OBJECT : 'CAR'| 'SOFA';
etc.. I don't want to ends up with a permanent "NoViableException" as I can't describe all the possibilities around the language structure. I just want to tear apart useless words and just keep the one that are interesting.
It's more like if I had a tokeniser and asked the parser "Ok, read the stream until you find a SUBJECT, then ignore the rest until you find a VERB, etc.."
I need to extract an organized structure in an un-organized set... For example, I would like to be able to interpret (I'm not judging the pertinence of this utterly basic and incorrect view of 'english grammar')
SUBJECT - VERB - INDIRECT OBJECT
INDIRECT OBJECT - SUBJECT - VERB
so I will parse sentences like
It's 10PM and the Lazy CAT is currently SLEEPING heavily on the SOFA in front of the TV or It's 10PM and, on the SOFA in front of the TV, the Lazy CAT is currently SLEEPING heavily
You could create only a couple of lexer rules (the ones you posted, for example), and as a last lexer rule, you could match any character and skip() it:
VERB : 'SLEEPING' | 'WALKING';
SUBJECT : 'CAT'|'DOG'|'BIRD';
INDIRECT_OBJECT : 'CAR'| 'SOFA';
ANY : . {skip();};
The order is important here: the lexer tries to match tokens from top to bottom, so if it can't match any of the tokens VERB, SUBJECT or INDIRECT_OBJECT, it "falls through" to the ANY rule and skips this token. You can then use these parser rules to filter your input stream:
parse
: sentenceParts+ EOF
;
sentenceParts
: SUBJECT VERB INDIRECT_OBJECT
;
which will parse the input text:
It's 10PM and the Lazy CAT is currently SLEEPING
heavily on the SOFA in front of the TV. The DOG
is WALKING on the SOFA.
as follows:

Resources