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
I want encrypt & decrypt Video file With FFMPEG oflfine mode in hard disk.
I encrypt a Video File (mp4 Extention) by ffmpeg.exe Tools by this Command:
ffmpeg -i SampleVideo_1280x720_1mb.mp4 -vcodec copy -acodec copy
-encryption_scheme cenc-aes-ctr -encryption_key
76a6c65c5ea762046bd749a2e632ccbb -encryption_kid
a7e61c373e219033c21091fa607bf3b8 SampleVideo_1280x720_1mb_encrypted.mp4
for decryption :
i want decrypt and play video file (encrypted.mp4) in my player source c++
(ffmpeg base) and *now i dont wnat use decrypt file with command line with
ffplay.exe *like this :
ffplay SampleVideo_1280x720_1mb_encrypted.mp4 -decryption_key
76a6c65c5ea762046bd749a2e632ccbb
how i can do decrypt with Write programing code that use FFMPEG api?
thanks in advance.
I am doing a project with encrypting
video and I have a few questions for the procedure.
I used a command to transcode mp4 to HLS with a ts segment duration of ~10 seconds.
First, I need to encrypt those videos with a key from database. However,
I have no idea for the encryption whether working with ffmpeg or not.
Second, if the encryption can work without ffmpeg, so what should I do? I have searched in google which includes something like openssl / aes but
there is no a detailed step for me to follow, even the ffmpeg link:
http://www.ffmpeg.org/ffmpeg-all.html#srtp
Could anyone give me a hand, teaching me how to encrypt a video? Thanks to you.
Yes, you can do it with ffmpeg. You need to write the key from the database to a file, let's say video.key.
You need a second file, let's name it key_info which is the key info file. It has the following format:
key URI
key file path
IV (optional)
Eg:
http://example.com/video.key
video.key
You tell ffmpeg to use it to encrypt your segments with the hls_key_info argument:
ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -hls_time 10 -hls_key_info_file key_info playlist.m3u8
This will encrypt your segments with AES-128 in CBC mode and add the relevant tags to your playlist:
#EXT-X-KEY:METHOD=AES-128,URI="http://example.com/video.key"
You can also manually encrypt the segments if you want with openssl. Here's an example script, where each IV is equal to the segment index:
#!/bin/bash
ts_dir=/path/to/ts/
key_file=video.key
openssl rand 16 > $key_file
enc_key=$(hexdump -v -e '16/1 "%02x"' $key_file)
pushd $ts_dir
ts_cnt=$(ls *.ts | wc -l)
((ts_cnt--))
i=0
for i in $(seq -f "%01g" 0 $ts_cnt); do
iv=$(printf '%032x' $i)
ts_file=segment-$i.ts
echo [$i] $ts_file
openssl aes-128-cbc -e -in $ts_file -out encrypted_${ts_file} -nosalt -iv $iv -K $enc_key
done
popd
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.
I trying to decrypt AES-128 encrypted m3u8 video files such as this one :
the m3u8 file :
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:NO
#EXT-X-VERSION:2
#EXT-X-FAXS-CM:MII6lAYJKoZIhvcNAQcCoII6hTCCOoECAQExCzAJBgUrDgMCGgUAM... very long key...
#EXT-X-KEY:METHOD=AES-128,URI="faxs://faxs.adobe.com",IV=0X99b74007b6254e4bd1c6e03631cad15b
#EXT-X-TARGETDURATION:8
#EXTINF:8,
video.mp4Frag1Num0.ts
#EXTINF:8,
video.mp4Frag1Num1.ts
...
I've tried with openssl :
openssl aes-128-cbc -d -kfile key.txt -iv 99b74007b6254e4bd1c6e03631cad15b -nosalt -in video_enc.ts -out video_dec.ts
key.txt contains the very long key
-->
bad decrypt
1074529488:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:evp_enc.c:539:
What am-I doing wrong ?
This might be a bit of a hack, but given a URL to an .m3u8 file, it will download and decrypt the files that make up the stream:
#!/usr/bin/env bash
curl "$1" -s | awk 'BEGIN {c=0} $0 ~ "EXT-X-KEY" {urlpos=index($0,"URI=")+5; ivpos=index($0,"IV="); keyurl=substr($0, urlpos, ivpos-urlpos-2); iv=substr($0, ivpos+5); print "key=`curl -s '\''"keyurl"'\'' | hexdump -C | head -1 | sed \"s/00000000//;s/|.*//;s/ //g\"`"; print "iv="iv} $0 !~ "-KEY" && $0 ~ "http" {printf("curl -s '\''"$0"'\'' | openssl aes-128-cbc -K $key -iv $iv -d >seg%05i.ts\n", c++)}' | bash
This script generates a second script that extracts keys and initialization vectors and uses them to decrypt while downloading. It needs curl, awk, hexdump, sed, and openssl to run. It'll probably choke on an unencrypted stream, or on a stream that uses something other than AES-128 (is any other encryption supported?).
You'll get a bunch of files: seg00000.ts, seg00001.ts, etc. Use tsMuxeR (https://www.videohelp.com/software/tsMuxeR) to merge these into a single file (simple concatenation didn't work for me...it's what I tried first):
(echo "MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr --vbv-len=500"; (echo -n "V_MPEG4/ISO/AVC, "; for i in seg*.ts; do echo -n "\"$i\"+"; done; echo ", fps=30, insertSEI, contSPS, track=258") | sed "s/+,/,/"; (echo -n "A_AAC, "; for i in seg*.ts; do echo -n "\"$i\"+"; done; echo ", track=257") | sed "s/+,/,/") >video.meta
tsMuxeR video.meta video.ts
(Track IDs and framerate may need adjustment...get the values to use by passing one of the downloaded files to tsMuxeR.)
Then use ffmpeg to remux to something a bit more widely understood:
ffmpeg -i video.ts -vcodec copy -acodec copy video.m4v
In order to decrypt encrypted video stream you need encryption key.
This key is not part of the stream. It should be obtained separately.
EXT-X-FAXS-CM header contains DRM meta-data and not the key.
This is excert from Adobe Media Server developer guide:
The Adobe Access Server protected variant playlist also needs to include the #EXT-X-FAXS-CM tag. The value of #EXT-X-FAXS-CM tag in variant playlist is the relative URI referring to the DRM metadata of one of the individual streams.At the client, the #EXT-X-FAXS-CM tag in variant playlist will be used to create the DRM session. The same DRM session will be used for all encrypted M3U8 files inside the variant playlist.
Full guide can be found here:
http://help.adobe.com/en_US/adobemediaserver/devguide/WS5262178513756206-4b6aabd1378392bb59-7fe8.html
There is also mention that faxs://faxs.adobe.com URI is for local key serving.
So key obtained locally from a device.
While some of the bash scripts in the existing answers get you part (or even all) of the way, depending which site you're trying to download from, you might hit other obstacles (different auth method, custom license server mount, etc.)
I've found streamlink to be the most robust solution for this, which also lets you stream directly (rather than download), if that's what you're after, and it has all the site-specific work already done for you for a long list of sites (see plugins section, but keep in mind it's under active development and the latest release was in June, so for some of the newer ones you'll have to git clone and install from source).
In many cases, VLC will happily convert an .m3u8 video to an unencrypted .ts or .mp4. In the VLC graphical interface, go to Media > Convert/Save.
Even through this file includes AES encrypted data, openssl don't know the m3u8 format. However FFmpeg might be able to handle it.