How to make wowza generate random ts file name in HLS stream - wowza

Now I get the m3u8 contents like this
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:797
#EXTINF:2.0,
media-u2w5gbqf0_b2625536_797.ts
#EXTINF:2.0,
media-u2w5gbqf0_b2625536_798.ts
#EXTINF:2.0,
media-u2w5gbqf0_b2625536_799.ts
#EXTINF:2.0,
media-u2w5gbqf0_b2625536_800.ts
#EXTINF:2.0,
media-u2w5gbqf0_b2625536_801.ts
what I want to get is like this:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:797
#EXTINF:2.0,
media-LAJ123FMK.ts
#EXTINF:2.0,
media-KOAKS23W2.ts
#EXTINF:2.0,
media-JLASFK234.ts
#EXTINF:2.0,
media-SLFJAQ23D.ts
#EXTINF:2.0,
media-ALSF1234L.ts
Is this possible by any plugin in wowza, or doing this by some wowza server API?

You can custom the ID of your chunks in Wowza by creating a class that implements the IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler but the id must be a number (long), not letters.
long onAssignChunkId(com.wowza.wms.httpstreamer.cupertinostreaming.livestreampacketizer.HTTPStreamerCupertinoLiveStreamPacketizerChunkIdContext chunkIdContext)

Related

Google Speech to Text: InvalidArgument: 400 Must use single channel (mono) audio, but WAV header indicates 1 channels

I am using the Google Cloud Platform to convert some audio into text files through the Google Speech-to-Text API. I keep getting the error: google.api_core.exceptions.InvalidArgument: 400 Must use single channel (mono) audio, but WAV header indicates 1 channels.
Here is my code:
config_wave_enhanced = speech.types.RecognitionConfig(
#sample_rate_hertz=44100,
encoding = 'LINEAR16',
enable_automatic_punctuation=True,
language_code='en-US',
#use_enhanched=True,
model='video',
enable_separate_recognition_per_channel = True,
audio_channel_count = 2
)
operation = speech_client.long_running_recognize(
config=config_wave_enhanced,
audio=long_audi_wave
)
response = str(operation.result(timeout=90))
Can anyone help me solve this error? I'm going crazy here.
Setting audio_channel_count = 1 might help.
Convert your audio to 1-channel. You can do this using command line ffmpeg -i stereo.wav -ac 1 mono.wav. Also set audio_channel_count = 1 as Christian Adib mentioned.

Why can only download the first episode video on bilibili with youtube-dl?

I can download the first episode of a series.
yutube-dl https://www.bilibili.com/video/av90163846?p=1
Now I want to download all episodes of the series.
for i in $(seq 1 55)
do
yutube-dl https://www.bilibili.com/video/av90163846?p=$i
done
All other episodes except the first can't be downloaded ,both of them contains same error info such as below:
[BiliBili] 90163846: Downloading webpage
[BiliBili] 90163846: Downloading video info page
[download] 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识-90163846.flv has already been downloaded
Please have a try and check what happens,how to fix then?
#Christos Lytras,strange thing happen with your code:
for i in $(seq 1 55)
do
youtube-dl https://www.bilibili.com/video/av90163846?p=$i -o "%(title)s-%(id)s-$i.%(ext)s"
done
It surely can download video on bilibili,but all of downloaded video have different name and same content,all the content are the same as the first episode,have a try and check ,you will find that fact.
This error occurs because youtube-dl ignores URI parameters after ? for the filename, so the next file it tries to download has the same name with the previous one and it fails because a file already exists with that name. The solution is to use the --output template filesystem option to set a filename which it'll have an index in its name using the variable i.
Filesystem Options
-o, --output TEMPLATE Output filename template, see the "OUTPUT
TEMPLATE" for all the info
OUTPUT TEMPLATE
The -o option allows users to indicate a
template for the output file names.
The basic usage is not to set any template arguments when downloading
a single file, like in youtube-dl -o funny_video.flv "https://some/video". However, it may contain special sequences that
will be replaced when downloading each video. The special sequences
may be formatted according to python string formatting operations. For
example, %(NAME)s or %(NAME)05d. To clarify, that is a percent symbol
followed by a name in parentheses, followed by formatting operations.
Allowed names along with sequence type are:
id (string): Video identifier
title (string): Video title
url (string): Video URL
ext (string): Video filename extension
...
For your case, to use the i in the output filename, you can use something like this:
for i in $(seq 1 55)
do
youtube-dl https://www.bilibili.com/video/av90163846?p=$i -o "%(title)s-%(id)s-$i.%(ext)s"
done
which will use the title the id the i variable for indexing and the ext for the video extension.
You can check the Output Template variables for more options defining the filename.
UPDATE
Apparently, bilibili.com has some Javascript involved to setup the video player and fetch the video files. There is no way so you can extract the whole playlist using youtube-dl. I suggest you use Lux which supports Bilibili playlists out of the box. It has installers for all major operating systems and you can use it like this to download the whole playlist:
lux -p https://www.bilibili.com/video/av90163846
of if you want to download only until 55 video, you can use -end 55 cli option like this:
lux -end 55 -p https://www.bilibili.com/video/av90163846
You can use the -start, -end or -items option to specify the download
range of the list:
-start
Playlist video to start at (default 1)
-end
Playlist video to end at
-items
Playlist video items to download. Separated by commas like: 1,5,6,8-10
For bilibili playlists only:
-eto
File name of each bilibili episode doesn't include the playlist title
If you want to only get information of a playlist without downloading files, then use the -i command line option like this:
lux -i -p https://www.bilibili.com/video/av90163846
will output something like this:
Site: 哔哩哔哩 bilibili.com
Title: 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识 P1 【001】Parts of Plants
Type: video
Streams: # All available quality
[64] -------------------
Quality: 高清 720P
Size: 308.24 MiB (323215935 Bytes)
# download with: lux -f 64 ...
[32] -------------------
Quality: 清晰 480P
Size: 201.57 MiB (211361230 Bytes)
# download with: lux -f 32 ...
[16] -------------------
Quality: 流畅 360P
Size: 124.75 MiB (130809508 Bytes)
# download with: lux -f 16 ...
Site: 哔哩哔哩 bilibili.com
Title: 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识 P2 【002】Life Cycle of a Plant
Type: video
Streams: # All available quality
[64] -------------------
Quality: 高清 720P
Size: 227.75 MiB (238809781 Bytes)
# download with: lux -f 64 ...
[32] -------------------
Quality: 清晰 480P
Size: 148.96 MiB (156191413 Bytes)
# download with: lux -f 32 ...
[16] -------------------
Quality: 流畅 360P
Size: 94.82 MiB (99425641 Bytes)
# download with: lux -f 16 ...

Using powershell to download an embedded video

I need to download a monthly broadcast automatically (will set a scheduled task) using powershell.
Here is the embedded URL: https://www.jw.org/download/?fileformat=MP4&output=html&pub=jwb&issue=201601&option=TRGCHlZRQVNYVrXF&txtCMSLang=E
The only thing that changes each month is the 201602, 201603, etc. Once I have able to pull the 720p video file, I will work on programmatically adding that part of the URL, based on the current system clock (I can manage this)
I have tried these without success:
Attempt 1:
$source = "https://www.jw.org/download/?fileformat=MP4&output=html&pub=jwb&issue=201601&option=TRGCHlZRQVNYVrXF&txtCMSLang=E"
$destination = "c:\broadcasts\test.mp4"
Invoke-WebRequest $source -OutFile $destination
Attempt 2:
$source = "https://www.jw.org/download/?fileformat=MP4&output=html&pub=jwb&issue=201601&option=TRGCHlZRQVNYVrXF&txtCMSLang=E"
$dest = "c:\broadcasts\test.mp4"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($source, $dest)
Attempt 3:
Import-Module BitsTransfer
$url = "https://www.jw.org/download/?fileformat=MP4&output=html&pub=jwb&issue=201601&option=TRGCHlZRQVNYVrXF&txtCMSLang=E"
$output = "c:\broadcasts\test.mp4"
Start-BitsTransfer -Source $url -Destination $output
Both of these end up with a test.mp4 that is basically just an empty file.
Then I found the another page that holds the video (and the download links for different qualities) and tried to pull these links using the following (I know I could have used $webpage.links):
Attempt 4:
$webpage=Invoke-webrequest "http://tv.jw.org/#en/video/VODStudio/pub-
jwb_201601_1_VIDEO"
$webpage.RawContent | Out-File "c:\scripts\webpage.txt" ASCII -Width 9999
And found that the raw content doesn't have the mp4 visible. My idea was to pull the raw content, parse it with regex and grab the 720p URL, save it in a variable and then send that to a BitsTransfer bit of code.
Please help?

Change category title in OpenCart

I am running an online store based on OpenCart and I want to add something more to the category titles. For example, right now I have a category called Electronics. The title is simple: Electronics. I want to add, for example, the text "Buy" in the title, in front of the category name.
Anyone has an idea about how I can achieve that ?
if you have a multi language use these steps:
Edit: "/catalog/language/"languageFolder"/product/category.php" add this>
$_['text_buy'] = 'Buy ';
Edit: "/catalog/controller/product/category.php"
after
$data['text_sale'] = $this->language->get('text_sale');
(line 120)
$data['text_buy'] = $this->language->get('text_buy');
Edit the template file category.tpl located at catalog/view/theme/default/template/product/
Open file in step 1 in editor and locate around line 17
Replace line in step 2 with <h2><?php echo $text_buy . $heading_title; ?></h2>
or <h2><b><?php echo $text_buy ?></b><?php echo $heading_title; ?></h2>
Edit the template file category.tpl located at catalog/view/theme/default/template/product/
Open file in step 1 in editor and locate <h2><?php echo $heading_title; ?></h2> around line 17
Replace line in step 2 with <h2><?php echo 'Buy ', $heading_title; ?></h2>
Save file and test

Not able to change H264 profile to High from Main using FFMPEG API

I am using QtFFMPEG wrapper(https://code.google.com/p/qtffmpegwrapper/) with Qt 5.4 and MSCV 2012. I want to encode a mp4 video from image files at 25 fps and high profile.
I used the createFile() and encodeImage() functions from here
I am using the below parameters:
pCodecCtx=pVideoStream->codec;
pCodecCtx->codec_id = pOutputFormat->video_codec;
pCodecCtx->codec_type = ffmpeg::AVMEDIA_TYPE_VIDEO;
pCodecCtx->profile=FF_PROFILE_H264_HIGH;
pCodecCtx->bit_rate = Bitrate;
pCodecCtx->width = getWidth();
pCodecCtx->height = getHeight();
pCodecCtx->time_base.den = fps;
pCodecCtx->time_base.num = 1;
pCodecCtx->gop_size = 10;
pCodecCtx->pix_fmt = ffmpeg::PIX_FMT_YUV420P;
pCodecCtx->qmin = 10;
pCodecCtx->qmax = 51;
The FFMPEG variables are:
License: %s
GPL version 3 or later
AVCodec version %d
3476480
AVFormat configuration: %s
--disable-static --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
Now I currently get a video with below properties:
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main#L3.2
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Format settings, GOP : M=1, N=10
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 4s 320ms
I want the profile to be "High" and the CABAC to be yes with 3 ReFrames. How do I achieve that? I tried setting the profile, coder_type and max_b_frames but did not help. At times the generated file did not even play. Can anyone help please. Thanks.
I also tried using the av_opt_set() way but could not find that function. Only function I have is av_opt_set_dict(), am I missing something - outdated FFMPEG or missing #include.
Tried this too, didnt help-
ffmpeg::AVDictionary *opt = NULL;
int iRes = av_dict_set(&opt, "profile", "high", 0);
av_opt_set_dict(pFormatCtx->priv_data, &opt);
av_opt_set_dict(pFormatCtx, &opt);
Please help.
EDIT:
I got a high quality mp4 by changing the qmin and qmax values and then reencoding the big sized output via command line. I will try to upgrade the FFMPEG as suggested by Ronald below. Please consider the question closed for now.
AVCodec version %d
3476480
That version (libavcodec 53.12.0) is from October 2011, please update to something newer. As you can see from the H264 encoding wiki docs, your settings will work with recent versions of ffmpeg. (Also please share the rest of your code, you're just showing the code that sets your settings, but not any other part of your code, so I can't reproduce anything.)