You-get && FFmpeg

  • 一、引言
  • 二、 you-get 介绍
    • 2.1 you-get 安装
    • 2.2 you-get语法及参数
    • 2.3 you-get运用实例
  • 三、FFmpeg介绍
    • 3.1 FFmpeg安装
    • 3.2 you-get与FFmpeg的结合使用
  • 四、 HEVC 扩展

一、引言

  Sometimes we need to download the video on the web page to share or recreate, or you know. When the relevant website does not provide video download or does not provide the service of saving the video to the local, what should we do?

  1. On the mobile phone, screen recording can be used, but the files obtained from the screen recording are generally larger. IPhone can write a shortcut for one-click download, as shown in the figure below, this article will not discuss the implementation method.
    You-get && FFmpeg_第1张图片

  2. There are many ways to implement it on the PC side. Common ones include screen recording, Chrome browser installation of corresponding plug-ins, Edge browser installation of plug-ins, Python crawlers, and so on.

    This article shares the use of the command line program you-get to download videos from web pages.

二、 you-get 介绍

  You get is an open source library of Python on GitHub(link),the latest version is 0.4.1555。

The official introduction is:

You-Get is a small command-line utility for downloading media (video, audio and images) from the Web when there are no other means to do so. It can download video and audio files from such popular web sites as YouTube, Twitter, Niconico, Vimeo, Flickr, Instagram and a whole lot more.

You-Get is a great option for when you want to enjoy your favorite videos, audio or images from the internet without having to open any web browsers or get interrupted by ads. It’s also a good choice for when you want to get rid of any closed-source technology or proprietary JavaScript code from running on your computer.

2.1 you-get 安装

  You need to install python3 and pip before installing you get,You must have installed them. I won’t repeat it here.

  There are many ways to install you-get, and we choose the most convenient PIP installation method. Open the CMD (PowerShell) window and enter the following code to install you-get

pip install you-get

Or download it on this website:https://sourceforge.net/projects/you-get.mirror/

You-get && FFmpeg_第2张图片

  After installation, view the version information on the command line:

PS C:\Users\dahu> you-get --v
you-get: version 0.4.1520, a tiny downloader that scrapes the web.

2.2 you-get语法及参数

  After you-get is installed, it can be used directly on the command line. A simple command line can realize video download, or it can be used in Python script to complete more complex work.

  Generally, many languages can use the ‘help’ parameter to view the help and description of related function packages or functions. The optional parameters of you get are as follows:

  (Readers can read Section 2.3 first and try the following parameters slowly after simple application.)

C:\Users\dahu>you-get --help
usage: you-get [OPTION]... URL...

A tiny downloader that scrapes the web

optional arguments:
  -V, --version         Print version and exit
  -h, --help            Print this help message and exit

Dry-run options:
  (no actual downloading)

  -i, --info            Print extracted information
  -u, --url             Print extracted information with URLs
  --json                Print extracted URLs in JSON format

Download options:
  -n, --no-merge        Do not merge video parts
  --no-caption          Do not download captions (subtitles, lyrics, danmaku,
                        ...)
  -f, --force           Force overwriting existing files
  --skip-existing-file-size-check
                        Skip existing file without checking file size
  -F STREAM_ID, --format STREAM_ID
                        Set video format to STREAM_ID
  -O FILE, --output-filename FILE
                        Set output filename
  -o DIR, --output-dir DIR
                        Set output directory
  -p PLAYER, --player PLAYER
                        Stream extracted URL to a PLAYER
  -c COOKIES_FILE, --cookies COOKIES_FILE
                        Load cookies.txt or cookies.sqlite
  -t SECONDS, --timeout SECONDS
                        Set socket timeout
  -d, --debug           Show traceback and other debug info
  -I FILE, --input-file FILE
                        Read non-playlist URLs from FILE
  -P PASSWORD, --password PASSWORD
                        Set video visit password to PASSWORD
  -l, --playlist        Prefer to download a playlist
  -a, --auto-rename     Auto rename same name different files
  -k, --insecure        ignore ssl errors

Playlist optional options:
  --first FIRST         the first number
  --last LAST           the last number
  --size PAGE_SIZE, --page-size PAGE_SIZE
                        the page size number

Proxy options:
  -x HOST:PORT, --http-proxy HOST:PORT
                        Use an HTTP proxy for downloading
  -y HOST:PORT, --extractor-proxy HOST:PORT
                        Use an HTTP proxy for extracting only
  --no-proxy            Never use a proxy
  -s HOST:PORT or USERNAME:PASSWORD@HOST:PORT, --socks-proxy HOST:PORT or USERNAME:PASSWORD@HOST:PORT
                        Use an SOCKS5 proxy for downloading

The above help documents are actually very comprehensive. It’s not difficult for you to understand as long as you know a little English.

Probably translate it:

语法:you-get 选项及参数 网页视频URL

可选参数:
-V, --version 打印版本并退出
-h, --help 打印此帮助信息并退出

试运行选项:(没有实际下载)
-i, --info 打印提取的信息(通常用此参数获取目标视频可供下载的清晰度)
-u, --url 打印带有 URL 的提取信息
–json 以 JSON 格式打印提取的 URL

下载选项:
-n, --no-merge 不合并视频部分
–no-caption 不下载字幕(字幕、歌词、弹幕、…)
-f, --force 强制覆盖现有文件
–skip-existing-file-size-check跳过现有文件而不检查文件大小
-F STREAM_ID, --format STREAM_ID将视频格式设置为 STREAM_ID
-O 文件,–输出文件名文件 设置输出文件名
-o 目录,–输出目录目录设置输出目录
-p 播放器,–player 播放器将提取的 URL 流式传输到 PLAYER
-c COOKIES_FILE,–cookies COOKIES_FILE加载 cookies.txt 或 cookies.sqlite
-t 秒,–超时秒设置套接字超时
-d, --debug 显示回溯和其他调试信息
-I 文件,–输入文件文件从 FILE 中读取非播放列表 URL
-P 密码, --password 密码将视频访问密码设置为 PASSWORD
-l, --playlist 喜欢下载播放列表
-a, --auto-rename 自动重命名同名的不同文件
-k, --insecure 忽略 ssl 错误

播放列表可选选项:(播放列表:比如要下载B站的视频合集)
–first FIRST 第一个数字
–last LAST 最后一个数字
–size PAGE_SIZE, --page-size PAGE_SIZE页面大小编号

代理选项:
-x 主机:端口,–http-proxy 主机:端口 使用 HTTP 代理进行下载
-y 主机:端口,–extractor-proxy 主机:端口 仅使用 HTTP 代理进行提取
–no-proxy 从不使用代理
-s HOST:PORT 或 USERNAME:PASSWORD@HOST:PORT, --socks-proxy HOST:PORT 或 USERNAME:PASSWORD@HOST:PORT 使用 SOCKS5 代理下载

2.3 you-get运用实例

  1. Check this video Clarity available for save,The value of format field is the parameter of downloading videos with different definition.
    You-get && FFmpeg_第3张图片

  2. Saving this video,Select MP4 format 1080p definition and save it in the local disk directory ‘F: \ say love you’.
    You-get && FFmpeg_第4张图片
    Go to the corresponding location of the computer to view: (where XML is the bullet screen file of the video, and those interested can further merge the bullet screen with the video)
    You-get && FFmpeg_第5张图片
    Tips:There are generally two video formats: MP4 and flv. If saved in MP4 format, a web video will correspond to three local files after downloading: barrage XML, video MP4, audio MP4, namely audio and video separation, needs to be further synthesized by itself; This is not the case with FLV format (you can watch it directly with iqiyi). However, MP4 is a commonly used format, so you need to install ‘ffmpeg’ on your PC for automatic synthesis. The appeal example is my download effect after installing ffmpeg, which automatically combines audio and video, which is very convenient.
    You-get && FFmpeg_第6张图片

三、FFmpeg介绍

FFmpeg:A set of open source computer programs that can be used to record, convert digital audio and video, and convert them into streams.

3.1 FFmpeg安装

(1)Go to ffmpeg official website https://ffmpeg.org/download.html Download the installation package. Or download directly from my GitHub or gitee. (it may be faster to use gitee)

github地址:click here

gitee地址:click here

You-get && FFmpeg_第7张图片
(2)After downloading, unzip the file and enter the bin directory. You can see ffmpeg.exe、ffplay.exe、ffprobe.exe three files. OK, go to the next step.

You-get && FFmpeg_第8张图片
(3)Set the environment variable, click “system properties - > Advanced - > environment variable - > user variable”, select the entry “path”, click “Edit - > new”, copy and paste the bin folder path in the first step, and then click OK.

You-get && FFmpeg_第9张图片
(4)We open the CMD command line window and enter the command “ffmpeg – version”. The window returns the version information of ffmpeg, indicating that the installation is successful.

Next, don’t worry. After downloading with you get, it will automatically merge audio and video.

You-get && FFmpeg_第10张图片

3.2 you-get与FFmpeg的结合使用

For example, download a video collection of bilibili, note that the ` – playlist 'option is required here.You-get && FFmpeg_第11张图片

四、 HEVC 扩展

After merging videos with this method, it is possible that when using win10’s “movie and TV” for playback, it will prompt that it cannot be decoded and need to install hevc extension, but the extension is charged for power on at Microsoft.

You-get && FFmpeg_第12张图片

You-get && FFmpeg_第13张图片

If you don’t want to pay, you can download it directly in my warehouse in section ‘3.1’, and double-click to install it.

来一句歌词:

她的睫毛 弯的嘴角
无预警地对我笑

你可能感兴趣的:(python,python,视频处理)