Closed ar0ra1 closed 5 years ago
Update :
Got the basic command to work.
Just help me with Error: invalid option: --with-default-names
Ah, looks like brew
have removed the --with-default-names
option - https://github.com/Homebrew/homebrew-core/commit/43f2e19d93f04eddf24ec19187b3648f594b80e2
If you run brew install gnu-sed
it should also print some output telling you how to make them available with their default names (you can see it in that commit too). Think I preferred the old way, but meh.
I'll raise a task to update the README for modern brew
- if you could just confirm that the new way works for you?
If I install without the option :
brew install gnu-sed
==> Downloading https://homebrew.bintray.com/bottles/gnu-sed-4.7.mojave.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring gnu-sed-4.7.mojave.bottle.2.tar.gz
==> Caveats
GNU "sed" has been installed as "gsed".
If you need to use it as "sed", you can add a "gnubin" directory
to your PATH from your bashrc like:
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
&&
brew install grep
==> Downloading https://homebrew.bintray.com/bottles/grep-3.3.mojave.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring grep-3.3.mojave.bottle.2.tar.gz
==> Caveats
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
basically it is installed with a different name
Yep, that's expected, you now need to follow the steps in the caveat section:
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
so vi ~/.bashrc
and insert that line. Open a new terminal and you should now get the "correct" grep (if you do echo $PATH
you should see the gnubin entry in there).
Added gnubin
to PATH and replaced sed
with gsed
in the script.
The script was able to generate the key.
Surprisingly, Safari cannot play the encrypted stream now.
Will implement hls.js and update you anyway, even though it doesn't concern your repo directly (Unless it's a key issue)
You shouldn't have needed to replace sed
with gsed
, if you look in /usr/local/opt/grep/libexec/gnubin
you should (hopefully) see sed
and be able to use it directly.
Odd that Safari cannot play, are you getting output to suggest why? Please do let me know how you get on with hls.js
.
I first tried running the script without replacing the sed
with gsed
, but got this
sed: 1: "./output/test_file.mp4.m3u8": invalid command code .
Hmmm, that definitely suggests that the wrong sed is being used. If you do echo $PATH | grep gnubin
do you get any output? It might be that your bashrc
isn't getting loaded, this page suggests OS X is a bit stupid in that regard
Hi,
Slight change of plans here. Although I wasn't initially keen to have extra checks in there just for the sake of OS X, it does look like there's potential for quite a lot of inconsistency for Mac users (depending on which terminal they use) if they rely on brew
's new method of exposing default names.
So, I've written a check into the script so that it'll use ggrep
and gsed
if they exist. Would you mind pulling the latest revisions and giving it a test run for me? I don't have a Mac available to check with.
HLS-33 Refers to the changes (or will once the mirror updates later)
First I thought it was my dumb mistake not to include the PATH in .bashrc
but I just checked and and it definitely needs gsed
to work and not sed
.
I'm gonna pull the latest release and update you!
Also, just checked the new script.
Dropped back to default BASH, didn't have a .bashrc file so just added the PATH for the current session.
PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
echo $PATH
/usr/local/opt/grep/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin
Ran the script (updated one), works smoothly. Thank You!
PS - I even tried running the script without the PATH and it failed (just the encryption part though).
@bentasker
Hello, I'm back.. seems like the new script does not work.
It is basically suppressing the sed
error, i.e.,
sed: 1: "./output/dil.mp4.m3u8": invalid command code .
This is my m3u8 file created by the new script.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:101
#EXTINF:100.480000,
dil.mp4_00000.ts
#EXTINF:99.960000,
dil.mp4_00001.ts
#EXTINF:30.640000,
dil.mp4_00002.ts
#EXT-X-ENDLIST
I used the encrypted options -e
. But the key meta is missing from the file.
But it did generate a key file. Just the entry for the key file is missing here.
The code at line 280
for manifest in ${OUTPUT_DIRECTORY}/*.m3u8
do
# Insert the KEY at the 5'th line in the m3u8 file
sed -i "5i #EXT-X-KEY:METHOD=AES-128,URI="${KEY_PREFIX}${KEY_NAME}.key "$manifest"
done
This is not being executed.
Have you definitely got the newest revision? That should be
for manifest in ${OUTPUT_DIRECTORY}/*.m3u8
do
# Insert the KEY at the 5'th line in the m3u8 file
$SED -i "5i #EXT-X-KEY:METHOD=AES-128,URI="${KEY_PREFIX}${KEY_NAME}.key "$manifest"
done
(https://github.com/bentasker/HLS-Stream-Creator/blob/master/HLS-Stream-Creator.sh#L277)
Yup the newer file. I just copied wrong, was comparing. Didn't look that I copied the old one.
But the code doesn't work.
The only way for me to get it to work is to replace sed
with gsed
in the original script.
Hmm, can you provide the output of both of these for me?
command -v gsed
command -v sed
I suspect the first will fail when it should not. This is the test the script is using to identify whether gsed
is available or not
Thanks for your help on this, I don't have a Mac available to do this on
Here you go
$ command -v gsed
/usr/local/bin/gsed
$ command -v sed
/usr/bin/sed
Hmmm, that's odd. I wonder if it doesn't like the ternary operator, could you try pasting the following into a terminal and providing the output (or a screenshot if that's easier for you)
SED='sed'
command -v gsed >/dev/null 2>&1
if [ "$?" == "0" ]
then
SED='gsed'
fi
echo $SED
command -v foobar >/dev/null 2>&1
echo $?
command -v command >/dev/null 2>&1
echo $?
Thanks
Basically wrapped your code in a script file and ran it.
Tested on both ZSH and BASH (same output for both)
gsed
1
0
OK, so exit statuses are at least as would be expected.
Could you give the latest revision a try? I've swapped from using ternary's to an explicit if
on the exit status of command
. If it's not that, then I've obviously missed something somewhere :)
Recorded : https://youtu.be/UegO2bMzAlg
PS - Recorded this before you made latest changes (swapping ternary -> if)
Could you give the latest revision a try? I've swapped from using ternary's to an explicit
if
on the exit status ofcommand
. If it's not that, then I've obviously missed something somewhere :)
Just tested this. No luck!
OK, bear with me, I'm going to have to have a rethink on this one - clearly I'm missing something simple...
Take your time at least my work is not being held up.
I'm still happy running the original script (replacing sed with gsed).
Also, when I changed sed to gsed, I had to replace it 3 times. If that's what you are missing
I fixed it!
GREP="grep"
command -v ggrep >/dev/null 2>&1
if [ "$?" == "0" ]
then
SED="ggrep"
fi
Should be
GREP="grep"
command -v ggrep >/dev/null 2>&1
if [ "$?" == "0" ]
then
GREP="ggrep"
fi
OK, this should now be fixed. It was a small idiotic error - https://github.com/bentasker/HLS-Stream-Creator/commit/2114885fc19d3dd80db9cb89c40fbe1b0f4c756f
I've temporarily laid hands on a Mac running Mojave and it's working for me now
Sorry, I only just noticed your earlier message :) Yep that lines up exactly with my fix. Said it'd be something simple....
Thanks for your help. Im going to mark this fixed.
As I've been through the process now I've also updated the README with install steps for Macs
@bentasker I had a few questions. Could you spare few minutes?
Just used the basic command to check
./HLS-Stream-Creator.sh -i test_file.mp4 -s 60
I can see the files in the output directory, but I cannot play it on VLC/QuickTime.
Even tried running it on HTML
It still doesn't work.
Also,
I want to use encryption, since for OSX I had to install using
--with-default-names
. I get errorError: invalid option: --with-default-names
Running : Mojave, iTerm2, ZSH