How to use EXT-X-DISCONTINUITY-SEQUENCE when creating an infinite HLS stream that loops over same fragments - http-live-streaming

I am trying to create an infinite HLS stream. The idea is that the server sends the same fragments meaning that once the last fragment is sent the first one is sent again. As far as I know I have to use the EXT-X-DISCONTINUITY-SEQUENCE tag. Here is my initial manifest
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:NO
#EXT-X-VERSION:2
#EXT-X-TARGETDURATION:8
#EXTINF:8,
fragment0.ts
#EXTINF:8,
fragment1.ts
#EXTINF:8,
fragment2.ts
#EXTINF:8,
fragment3.ts
#EXTINF:8,
fragment4.ts
#EXTINF:8,
fragment5.ts
#EXTINF:8,
fragment6.ts
#EXTINF:4,
fragment7.ts
This is what it looks like once the stream starts and fragment 0 gets pushed to the bottom.
#EXTM3U
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:NO
#EXT-X-VERSION:2
#EXT-X-TARGETDURATION:8
#EXTINF:8,
fragment1.ts
#EXTINF:8,
fragment2.ts
#EXTINF:8,
fragment3.ts
#EXTINF:8,
fragment4.ts
#EXTINF:8,
fragment5.ts
#EXTINF:8,
fragment6.ts
#EXTINF:4,
fragment7.ts
#EXT-X-DICONTINUITY
#EXTINF:8,
fragment0.ts
Once fragment 0 comes to the top I increment EXT-X-DISCONTINUITY-SEQUENCE. This does not seem to work tho, does anyone have an idea why ?

Every time a fragment gets removed from the top the EXT-X-MEDIA-SEQUENCE must be incremented by 1. So after fragment0.ts drops out at the top it must say #EXT-X-MEDIA-SEQUENCE:1 in the playlist.
Note, that the #EXT-X-DICONTINUITY will end up at the top of the playlist after some time and when it drops out the EXT-X-DISCONTINUITY-SEQUENCE must be incremented by 1 as well.

Related

Why AWS MEDIACONVERT set EXTINF in m3u8 file equals to source video duration +1 sec?

I have a source mp4 file with duration=17sec (for example).
When i convert video to Apple HLS using AWS MediaConvert, i get the m3u8 file with duration 18sec .
I mean #EXTINF:18 tag in m3u8.
I use ABR mode.
SegmentControl settings are default
{
"OutputGroups": [
{
"Name": "Apple HLS",
"OutputGroupSettings": {
"Type": "HLS_GROUP_SETTINGS",
"HlsGroupSettings": {
"SegmentLength": 10,
"MinSegmentLength": 0,
"TargetDurationCompatibilityMode": "LEGACY",
"SegmentLengthControl": "GOP_MULTIPLE",
"SegmentControl": "SEGMENTED_FILES"
}
}
]
}
How to fix it? I tried to change different HlsGroupSettings but result remains the same
Thanks for your post. MediaConvert has a default setting to use whole integers for manifest durations. This means that if the source asset has even 1 extra frame of video or audio, the service will add a whole second to the segment duration. This may be why your output is appearing to be +1s longer than expected. You can change this segment duration setting to 'floating point' duration under "HLS Output Group / Avanced/ Manifest duration format". Try this and you might find the last segment is only slightly longer than expected.
You can ensure the source asset is exactly XX seconds long using the "input Clips" feature to specify a specific start + end timecode (HH:MM::SS:FF).
For the widest compatibility with streaming players we recommend using 1 second as the minimum segment duration. Very short segments (<1s) sometimes get skipped by some players or flagged by stream quality checking products. If a few extra frames of source content are found to exist, they will get added to the previous segment.
When measuring durations, be sure to check the actual media track durations and not just the file header metadata. Utilities such as ffprobe or mediainfo (use the --full flag) are helpful for this. The pts_time for each frame will indicate when it is supposed to start. The pkt_duration_time will indicate the duration of each frame.

How play mp3/audio files in Racket?

I intend on making a cli audio player for racket, as an exercise to learn Racket, and everything else that would entail this project. I am stuck though how to begin. I can't find any package to play sound files, so I am guessing I may have to make one. How would I go about it?
What you probably want is #lang video (website). It provides a high level interface into audio playback. Allowing you to do something like:
#lang video
(clip "file.mp3")
Since you want to make a little command line player you might also want to take a look at its small preview tool.
I ended doing this the hackish way by calling a shell script via racket, not ideal at all. For reference, putting the code here.
; This creates the initail rsound
; for a song, this rsound is passed around
; so the whole song doesn't have to be
; decoded from the file everytime.
(define (play filepath)
(cond [(string=? "mp3" (last (regexp-split #rx"\\." filepath)))
(system* "./mp3-hack" filepath)
(set! filepath "curr.wav")])
(define input-pstream (make-pstream))
(define input-rsound (rs-read filepath))
(pstream-play input-pstream input-rsound)
(values input-pstream input-rsound filepath))
And the mp3-hack file just uses ffmpeg
#!/bin/sh
ffmpeg -i $1 -acodec pcm_s16le -ac 1 -ar 44100 curr.wav
Yeah, I know. Inelegant, but at least I got it working. I needed it for my hackathon project MPEGMafia

Loop a Video on Echo Show

I'm building a skill for Echo Show and I've been trying to loop a video (mp4) file. I use the below code to play the video:
if (this.event.context.System.device.supportedInterfaces.VideoApp) {
this.response.playVideo(LINK);
} else {
this.response.speak("The video cannot be played on your device. " +
"To watch this video, try launching the skill from your echo show device.");
}
Unfortunately, regardless of which looping function I use, I either run into a general Amazon error or it simply plays the video once.
I've seen another post that kinda showed how to loop an audio file, but I haven't been able to apply similar logic to video.
Thanks in advance!
The problem is looping is not yet supported for VideoApp directive. You can use Video apl component to loop a video. https://developer.amazon.com/de/docs/alexa-presentation-language/apl-video.html

Vlc Check Stream Status

I am using VLC to rebroadcast a stream and this side of things is working very well. After a few hours however, I need to re authenticate and re-request the stream.
I have a script that simply needs to be run and this will handle the re-authentication and starting vlc.
The problem I am having is how to figure out if the stream is no longer working.
When using say:
pidof vlc
I get the pid of the process VLC. When checking top, I can see VLC running and consuming cpu. However, when I try to play the stream nothing happens. If I run my script again, the stream restarts and I can then watch it again.
So even if the stream has stopped, VLC continues to run giving me no indication of whether the stream itself is actually running or just VLC.
The only thing I have spotted so far is that when the stream is not running the CPU usage seems to spike according to top.
When the stream is running, the cpu usage is around the 1% mark, when it is not running it seems to spike past 40%. I have observed this a couple of times, but I can only assume that this would potentially be a way I could ensure the stream is running, but I am not 100% confident in the approach.
Does anyone have any knowledge on how I could confirm if the actual stream is running or if it is just the VLC process?
should give credits to #mundu
here is a script I created for checking if vlc is streaming.
// vlc_verify1.sh
#!/bin/bash
VLC_CONF="$1"
VLC_COMMAND="$2"
VLC_PASS="videolan"
echo "" > nohup.out
nohup vlc --intf telnet --vlm-conf $VLC_CONF --telnet-password $VLC_PASS &
vlc_pid=$!
echo "vlc has a pid of $vlc_pid"
sleep 5
echo "nc start"
nc localhost 4212 < $VLC_COMMAND
kill $vlc_pid
exit 0
// vlm-conf, you have to replace $url with the actual url
new channel1 broadcast enabled
setup channel1 input $url
control channel1 play
show
// command.txt
videolan
show
the vlc_verify1.sh would output the status of current playing as mentioned by #mundu. what I did is to grep the output and see if it's state is 'playing'.
Notice, I didn't specify the output like setup channel1 output #std{access=udp,mux=ts,dst=239.192.174.105:1234}.
a reason for that is sometime vlc would use 100% cpu time. I have no clue why so. but if I get rid of that, I didn't experience similar issues. a downside for this is that there will be a pop-up window playing the streamings. but I don't think it's a big deal.
Easy. Use the VLM interface.
vlc -I telnet --vlm-conf vlm.conf
Adapt your command line to place the sout in your vlm.conf like this example:
new channel1 broadcast enabled
setup channel1 input http://host.mydomain/movie.mpeg
setup channel1 output #std{access=udp,mux=ts,dst=239.192.174.105:1234}
control channel1 play
You can then login to the telnet interface and type show to see the current broadcasts and its status.
> show
show
media : ( 1 broadcast - 0 vod )
channel1
type : broadcast
enabled : yes
loop : yes
inputs
1 : http://host.mydomain/movie.mpeg
output : #std{access=udp,mux=ts,dst=239.192.174.105:1234}
options
instances
instance
name : default
state : playing
position : 0.058974
time : 6473336
length : 109766611
rate : 1.000000
title : 0
chapter : 0
can-seek : 1
playlistindex : 1
You can read more here https://wiki.videolan.org/Documentation:Streaming_HowTo/VLM/
PS: I would increase the log -v(vv) an perhaps use the syslog to save it and track any problems afterwards.

Determine the length of an audio recording?

How do I determine the length of an audio recording I am recording programaticaly? My current solution is to just time the start/stop recording events on the User Interface (literally the time the user hits record, then hits stop recording.) Given a .aac audio file, is there some library call in Objective-C or Python to determine its length?
On the iPad:
totalFrames = format->mFramesPerPacket * recordedPackets;
lengthInSeconds = totalFrames / format->mSampleRate

Resources