How do I change a website video to m3U8 format? - m3u8

Can anyone walk me through the steps of taking a video from our website and changing it to a m3U8 so we can then insert it to our app dashboard to have video on our app?

Download FFMPEG
then download a http segmenter e.g. apple's one or the google one
Now run the command prompt using cmd.
Go to bin directory of the FFMPEG from the command prompt.
Type ffmpeg –h to find various option of the ffmpeg.
This sample code converts a mp4 to a ts file:
ffmpeg -i myvideo.mp4 -acodec libfaac -ar 48000 -ab 64k -s 320x320 -vcodec libx264 -vbsf h264_mp4toannexb -f mpegts myvideo.ts
then run the segmenter to break up the ts file into smaller segments
segmenter -i myvideo.ts -d 20 -o la -x test/myvideo.m3u8
add the following to your htaccess file if you are running on apache
.M3U8 application/x-mpegURL
.ts video/MP2T
that's about it

Use gstreamill, which can transcode video to m3u8 format.

Related

How Can i Download this video? Encrypted m3u8?

Hello everyone For almost a whole month now I have been trying to download a file from a specific site
This is the link to the video
https://www.karaoke.co.il/api_play.php?type=clip&id=58370&autoplay=undefined&referer=karaoketv
The M3u8 files are split into 2 parts.
Video file
https://www.video-cdn.com/video/encrypt/750802ea0bc2d02fac93adeaa1398ec2/750802ea0bc2d...2-57d9518fae69
And an audio file
https://www.video-cdn.com/video/encrypt/750802ea0bc2d02fac93adeaa1398ec2/750802ea0bc2d...2-57d9518fae69
As far as I know there is a Key that needs to be entered in order to download the file.
And when I run the command in ffmpeg
I encounter many errors like:
Unable to open key file
Anyone who can download it.
I would be very happy if he would write me a code that works and explain to me how to do it
These are all the codes I have already tried
ffmpeg -decryption_key https://www.video-cdn.com/video/key/750802ea0bc2d02fac93adeaa13cde64 -i https://www.video-cdn.com/video/encrypt/750802ea0bc2d02fac93adeaa1398ec2/750802ea0bc2d02fac93adeaa1398ec2/video_720p.m3u8?token=R915dD-72351a7c-3dd1-4e58-b6c2-9cc813eeb183 -vcodec libx264 {output_file}
ffmpeg -decryption_key {key} -i {file} -max_muxing_queue_size 9999 d.mp4
ffmpeg -allowed_extensions ALL -protocol_whitelist data, file, http, https, tcp, tls, crypto -i "https://www.video-cdn.com/video/encrypt/f242d2da41d03b3955fb866efc5dbd59/f242d2da41d03b3955fb866efc5dbd59/video_720p.m3u8?token=R915dD-a1430cfc-0bda-46a0-a7e9-b15308875dc7" c copy -bsf: a aac_adtstoasc test.mp4 -decryption_key C:\ ffmpeg\enc.key
hlsdl -K "1a9625fb34a4afe0d5446138e9543563" https://www.video-cdn.com/video/encrypt/f242d2da41d03b3955fb866efc5dbd59/f242d2da41d03b3955fb866efc5dbd59/video_720p.m3u8?token=R915dD-be07b7e6-08aa-441b-afbd-5c7876409878
enter image description here
key:
base64:zPfjh0/g09EKjPIS4w37Kg==
Hex:ccf7e3874fe0d3d10a8cf212e30dfb2a
ffmpeg -decryption_key "https://www.video-cdn.com/video/key/750802ea0bc2d02fac93adeaa13cde64" -i "https://www.video-cdn.com/video/encrypt/750802ea0bc2d02fac93adeaa1398ec2/750802ea0bc2d02fac93adeaa1398ec2/video_720p.m3u8?token=R915dD-72351a7c-3dd1-4e58-b6c2-9cc813eeb183" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4

How can I convert RTMP nginx livestream from Flv to mp4 file?

I have an RTMP server running using nginx that records the livestream into flv files but what I want to do is record the files into a mp4 format... Here’s my nginx.conf file:
I want when I rtmp livestream going I can convert it from flv to an mp4 file... How can I do this? Here is my nginx.conf file:
​
user  www-data;
worker_processes auto;
rtmp_auto_push on;
events {
    worker_connections  1024;
}
rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        application s9-live {
            exec ffmpeg -i rtmp://localhost:1935/s9-rtmp/$name
            \-c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1280x720 -preset superfast -profile:v baseline rtmp://localhost:1935/s9-rtmp/$name;
            live on;
            meta copy;
            hls_cleanup off;
            record all;
            record_path /rec/videos;
            record_max_size 1k;
            record_unique on;
            record_suffix %y%m%d_%H%M%S.flv;
            exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;
        }
    }
}
http { 
    default_type application/octet-stream;
    server { 
        listen 8000; 
        location /tv { 
            root /tmp/hls; 
        }
\# This URL provides RTMP statistics
        location /stats {
            rtmp_stat all;
        }
        location /control {
            rtmp_control all;
        }
    }
    types {
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
        text/html html;
    } 
}
The application runs well without any issues at all the only if possible that I would like to know is how to get an mp4 or the recorded stream converted from the flv files.
You already have the command to convert flv to mp4 in your config:
exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;
While recording is on, you will only see an flv file. Once the recording is done, exec_record_done is triggered and the flv is converted to an mp4 file. You will then have an flv and a corresponding mp4 in your folder.

ffmpeg and nginx - restream with audio reencoding

I use nginx and ffmpeg to restream video from my provider. Previously I use ffmpeg with arguments where I reencoding video and reencoding audio, because my server is to slow I resigned from reencoding.
So now, I use that command :
ffmpeg -re -i http://link.somelink.com:6565/21d12d1/17233 -map 0 -c copy -bsf:a aac_adtstoasc -f flv -flvflags no_duration_filesize rtmp://test_ip/canal/stream
This works only when my provider streaming with aac audio codec, but sometimes my provider change audio codec to ac3. And then this doesn't work. I try something like this :
ffmpeg -thread_queue_size 32768 -re -i http://link.somelink.com:6565/21d12d1/17233 -c:v copy -c:a aac -f flv -flvflags no_duration_filesize rtmp://test_ip/canal/stream
And it all looks like it's all right in console with ffmpeg, but my restreaming video doesn't work. Ngnix throws 304 exception sometime.
Any suggestions?
Please help,
It's very important for me...
Ac3 is not in supported codecs list. You should encode your stream accordingly.
RTMP supports only a limited number of codecs. The most popular RTMP video codecs are H264, Sorenson-H263 (aka flv) and audio codecs AAC, MP3, Nellymoser, Speex. If your video is encoded with these codecs (the most common pair is H264/AAC) then you do not need any conversion. Otherwise you need to convert video to one of supported codecs.
https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp

What different video formats RTMP streaming support?

In almost all the online references related to FFMPEG and RTMP, I am getting -f as flv. Is there any other formats.
(I have tried avi, mpeg and h264, but no success.)
Currently, I am running following command -
ffmpeg -re -i video.mp4 -f s16le -ar 48000 -ac 2 -i audio.wav -c copy -f flv rtmp://192.168.0.1:1935/myapp/stream
The issues with -f flv in my case are -
It doesn't support 48k sample rate.
None of my input videos are in flv format (I have to convert it to flv externally).
P.S. - I am using VLC as RTMP player.
EDIT -
I am getting following error with 48k audio file -
[flv # 0x5650ba7afb80] FLV does not support sample rate 48000, choose from (44100, 22050, 11025)

Sometimes HLS chunks does not generate in /tmp/hls directory

I am working on an adaptive HLS solution using Nginx RTMP module as a streaming server and VideoJs as a client. I have completed the setup i.e. NGINX configurations and client sample in VideoJs.
NGINX Configurations:
nginx.txt
I am using this Ffmpeg command to generate stream:
ffmpeg -re -i /home/user/Downloads/test.mp4 -vcodec libx264 -vprofile baseline -g 30 -acodec aac -strict -2 -f flv rtmp://192.168.1.68/live
My problem is that sometimes the Nginx does not generate .ts and .m3u8 files in /tmp/hls directory when I issue the above ffmpeg command. I have also enabled the nginx-rtmp module logs but they are only giving me access information and I am not getting any logs in error logs.
Do let me know if more information is required. Any help will be appreciated.
Thanks,

Resources