No download button on the screen to download it can not teach you show this operation.

1, using the tools introduced

chrome browser (or other browsers)

安装chrome浏览器或者其他浏览器都可以,目的是要打开视屏链接。
复制代码

ffmpeg tool

ffmpeg Profile

FFmpeg是一个自由软件,可以运行音频和视频多种格式的录影、转换、流功能,包含了libavcodec——这是一个用于多个项目中音频和视频的解码器库,以及libavformat——一个音频与视频格式转换库。  
**主要参数**  
\-i——设置输入档名。  
\-f——设置输出格式。  
\-y——若输出文件已存在时则覆盖文件。  
\-fs——超过指定的文件大小时则结束转换。  
\-t——指定输出文件的持续时间,以秒为单位。  
\-ss——从指定时间开始转换,以秒为单位。  
\-t从-ss时间开始转换(如-ss 00:00:01.00 -t 00:00:10.00即从00:00:01.00开始到00:00:11.00)。  
\-title——设置标题。  
\-timestamp——设置时间戳。  
\-vsync——增减Frame使影音同步。  
\-c——指定输出文件的编码。  
\-metadata——更改输出文件的元数据。  
\-help——查看帮助信息。

ffmpeg的官网地址是:[https://www.ffmpeg.org/](https://www.ffmpeg.org/)  
ffmpeg的Github项目地址是:[https://github.com/FFmpeg/FFmpeg](https://github.com/FFmpeg/FFmpeg)
更多详细内容请参考[维基百科](https://zh.wikipedia.org/wiki/FFmpeg)。
复制代码

windows installation

  • Download compiled Windows version: ffmpeg.zeranoe.com/builds/ (synchronized with the official website)

    Write pictures described here

    FFmpeg is divided into three versions: Static, Shared, Dev

    The first two versions can be used directly from the command line. It contains three exe: ffmpeg.exe, ffplay.exe, ffprobe.exe

    Exe larger volume Static version, it is because the relevant Dll have been compiled into the exe inside.
    Shared version exe a lot of volume is relatively small, because of the time they also need to run the relevant dll function call corresponding
    Dev version for developers, which contains the header files and libraries xxx.lib xxx.h

  • Configuration environment variable

    1, ffmpeg unzip the downloaded to the specified directory, bloggers decompress: G: \ [1] Software (has been tested) directory;
    2, right-click Computer -> Properties -> Advanced System Settings - > environment variables. Add the path in the path variable decompression system variables in.
    For example: G: \ [1] software (which had been tested) \ FFmpeg-4.0-Win64-static \ FFmpeg-4.0-Win64-static \ bin
    . 3, the configuration operation cmd, input FFmpeg, if the following screen is displayed, configuration is successful.

    Write pictures described here

mac installation

复制代码

Download Video Player

ts encrypted files can not be directly merged or play, you need to use the key to decrypt the file for each ts.

Divided into two cases:
(1) If the file has been fully downloaded ts good, you can decrypt the local ffmpeg fast merge directly.
(2) If the file is not downloaded ts well, you can download the entire video via vlc directly, or converted by ffmpeg and download.

In either case, you have to go to the video source address m3u8 download files. If you can download key (some sites more rigorous encryption, not so easy to get to the key), the key file download good.

Download file is m3u8 to the source address of the site, press F12 to find m3u8 file, or from the right -> page source code to find the address. Both approaches to try.

For example, looking from the F12 browser:

Here you can find two m3u8 and a key file, download all good. Notepad to open two m3u8, one of which contains ts file list, the file is m3u8 we need. For example I have here is HdNz1kaz.m3u8 file, the following is a small part.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:13
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="/20180125/NfJJpxIH/1482kb/hls/key.key"
#EXTINF:12.5,
/20180125/NfJJpxIH/1482kb/hls/GBDYO3576000.ts
#EXTINF:12.5,
/20180125/NfJJpxIH/1482kb/hls/GBDYO3576001.ts
#EXTINF:12.5,
/20180125/NfJJpxIH/1482kb/hls/GBDYO3576002.ts
复制代码

1. a situation: ts files have been downloaded well

If I download all of ts files, placed in e: \ under 20,180,125 \ directory.

Also assume that key files have been downloaded well, also in e: \ under 20,180,125 \ directory.

Ts path uri path and file modification m3u8 file key of a local path. Here is a small part of the file content HdNz1kaz.m3u8

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:13
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="e:/20180125/key.key"
#EXTINF:12.5,
e:/20180125/GBDYO3576000.ts
#EXTINF:12.5,
e:/20180125/GBDYO3576001.ts
#EXTINF:12.5,
e:/20180125/GBDYO3576002.ts
复制代码

Then merge with ffmpeg.

ffmpeg -allowed_extensions ALL -i HdNz1kaz.m3u8 -c copy new.mp4
复制代码

I usually will file download ts good as Download Download tool (such as Thunder) much faster than ffmpeg or vlc download speed, because these two tools are serial download.

2. Case 2: ts file was not downloaded

Similarly, good m3u8 download the file (key available for download from time to download, because you can specify the key directly in the path of the network uri m3u8 file).

Modify uri path m3u8 file key and the ts. Here is a small part of the HdNz1kaz.m3u8 file modifications.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:13
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="http://www.example.com/20180125/key.key"
#EXTINF:12.5,
http://www.example.com/20180125/GBDYO3576000.ts
#EXTINF:12.5,
http://www.example.com/20180125/GBDYO3576001.ts
#EXTINF:12.5,
http://www.example.com/20180125/GBDYO3576002.ts
复制代码

Then, use ffmpeg download and merge.

ffmpeg -i HdNz1kaz.m3u8 -c copy new.mp4
复制代码

3.openssl decrypt the file ts

If the key values: asdjklfjaskdlf
IV key value (m3u8 already recorded file) is "0x0123456789abcdef0123456789abcdef"

The method for decrypting GBDYO3576000.ts:

strkey=asdjklfjaskdlf
iv=0x0123456789abcdef0123456789abcdef
openssl aes-128-cbc -d -in GBDYO3576000.ts -out out_0.ts -nosalt -K $strkey  -iv $iv
复制代码

4. Use the vlc download and save the file ts

There playback progress bar at the bottom of the playlist, which indicates progress of the download, not to move, not going to click play, pause, stop, etc., do not control it wants stood until the playback progress bar is complete, the file says the merger is completed. Place to go file save location to see to know.

ffmpeg error

error:

Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)

When the need to merge video, add-bsf:a aac_adtstoasc

ffmpeg -i index.m3u8 -c copy -bsf:a aac_adtstoasc new.mp4
ffmpeg -i index.m3u8 -c:a copy -bsf:a aac_adtstoasc new.mp4
复制代码

error:

Codec for stream 0 does not use global headers but container format requires global headers
Codec for stream 1 does not use global headers but container format requires global headers

We need to add global header

ffmpeg -i index.m3u8 -c:a copy -flags +global_header new.mp4
复制代码

Guess you like

Origin juejin.im/post/5e2db03b6fb9a0300a450af0