获取网页视频文件

获取网页视频文件

方法很多,这里说一个比较简单的方法:

you-get

安装 python;

pip install you-get

获取视频:

如,某视频网站: https://www.video.com/video/VideoP=01

1: 这个表示 视频的 网页, 01 表示 这个视频的 第一集;

2: you-get -i https://www.video.com/video/VideoP=01

这里会显示当前视频的 format:mp4hd 等等好几条;

3: you-get --format=mp4hd https://www.video.com/video/VideoP=01

获取相关 format 类型的分辨率 类型的 视频;

注意:一般默认 获取的音视频都有,但是有些网站,一个视频文件,会获取两个 mp4,其实一个是视频文件,一个是音频文件,所以需要 通过 ffmpeg 组合一下,windows 上可以用 powershell:

如 1.00.mp4, 1.01.mp4

ffmpe.exe -i "t:\1.00.mp4" -i "t:\1.01.mp4" -vcodec copy -acodec copy ./out1.mp4

可以直接 将文件放到 命令行中 获取 地址;

you-get : 中文说明:

中文说明 · soimort/you-get Wiki · GitHub

// ffmpeg_you-get视频合成.cpp 这个代码,简单执行了 音频文件 和 视频文件 合成;

// 这里在 windows 上默认文件枚举的排列的方式 是名称排列,所以不需要每次便利对比;

// 可以更加文件名的实际情况修改;

// 这里程序以多字节设置运行;

// ffmpeg_you-get视频合成.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。

//

#include

#include

#include

#include

#include

#include

using namespace std;

const char* pstrDir = "F:\\test";

std::vector g_vector_strPath;

void EnumerateFolder(const char * path)

{

HRESULT hr;

hr = CoInitialize(NULL);

LPMALLOC pMalloc = NULL;

hr = SHGetMalloc(&pMalloc);

LPSHELLFOLDER psfDesktop = NULL;

hr = SHGetDesktopFolder(&psfDesktop);

OLECHAR olePath[MAX_PATH]; // wide-char version of path name

MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1, olePath, MAX_PATH);

LPITEMIDLIST pidl = NULL;

hr = psfDesktop->ParseDisplayName(NULL, NULL, olePath/*path*/, NULL, &pidl, NULL);

LPSHELLFOLDER psfFolder = NULL;

hr = psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (void**)&psfFolder);

psfDesktop->Release();

pMalloc->Free(pidl);

LPENUMIDLIST penumIDL = NULL;

hr = psfFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &penumIDL);

while (1)

{

hr = penumIDL->Next(1, &pidl, NULL);

if (hr == NOERROR)

{

WIN32_FIND_DATA ffd; // let 's cheat a bit :)

hr = SHGetDataFromIDList(psfFolder, pidl, SHGDFIL_FINDDATA, &ffd, sizeof(WIN32_FIND_DATA));

g_vector_strPath.push_back(std::string(ffd.cFileName));

//cout << "Name = " << ffd.cFileName << endl;

//cout << "Type = " << ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? "dir\n " : "file\n ");

//cout << "Size = " << ffd.nFileSizeLow << endl;

pMalloc->Free(pidl);

}

else

{

break;

}

}

penumIDL->Release();

psfFolder->Release();

pMalloc->Release();

CoUninitialize(); // shut down COM

}

void ffmpeg_you_get()

{

int n_vector = g_vector_strPath.size();

std::string strDir = std::string(pstrDir) + std::string("\\");

for (int n = 0; n < n_vector; n++)

{

//std::cout << g_vector_strPath.at(n) << std::endl;

}

int nVector = g_vector_strPath.size();

while (g_vector_strPath.size() >= 2)

{

std::string strFile1 = g_vector_strPath.at(0);

std::string strFile2 = g_vector_strPath.at(1);

for (int n = 0; n < nVector; n++)

{

std::string strP = std::string("P") + std::to_string(n) + std::string("."); //根据实际文件命名修改;

std::string str_00 = "[00].mp4";

std::string str_01 = "[01].mp4";

// std::string strFile1 = g_vector_strPath.at(0);

// std::string strFile2 = g_vector_strPath.at(1);

int nPstrFile1 = strFile1.find(strP, 0);

int nPstrFile2 = strFile2.find(strP, 0);

int nstr_00 = strFile1.find(str_00);

int nstr_01 = strFile2.find(str_01);

int nstrFile1Len = strFile1.length();

int nstrFile2Len = strFile2.length();

if ((nstrFile1Len == nstrFile2Len) && (nPstrFile1 > 0) && (nPstrFile1 == nPstrFile2) && (nstr_00 > 0) && (nstr_00 == nstr_01))

{

std::string strFullFile1 = std::string("\"") + strDir + strFile1 + "\"";

std::string strFullFile2 = std::string("\"") + strDir + strFile2 + "\"";

std::string strFullFile_out = std::string("\"") + strFile1 + "\"";

std::string strffmpeg = std::string("F:\\t1\\bin\\ffmpeg.exe");

std::string ffmpegParam = std::string(" -i ") + strFullFile1 + " -i " + strFullFile2 + " -acodec copy -vcodec copy " + strFullFile_out;

std::string strFFmpegCmd = strffmpeg + ffmpegParam;

if(0)

{

WinExec(strFFmpegCmd.c_str(), SW_SHOW);

}

else

{

SHELLEXECUTEINFO ShExecInfo;

ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);

ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;

ShExecInfo.hwnd = NULL;

ShExecInfo.lpVerb = NULL;

ShExecInfo.lpFile = strffmpeg.c_str();

ShExecInfo.lpParameters = ffmpegParam.c_str();

ShExecInfo.lpDirectory = NULL;

ShExecInfo.nShow = SW_SHOW;

ShExecInfo.hInstApp = NULL;

ShellExecuteEx(&ShExecInfo);

//是否等待直到另一个程序启动;

WaitForSingleObject(ShExecInfo.hProcess, 100000);

}

//删除前两个已经完成的;

for (int i = 0; i<2; i++)

{

g_vector_strPath.erase(g_vector_strPath.begin());

}

break;

}

}

}

}

int main()

{

EnumerateFolder(pstrDir);

ffmpeg_you_get();

}

相关推荐

超详细家庭版吐司制作
bt365备用网站

超详细家庭版吐司制作

📅 06-29 👁️ 2699
马蜂窝价格多少钱一斤?
365bet提款多久到

马蜂窝价格多少钱一斤?

📅 06-29 👁️ 3470
打手槍好無聊? 男人必學「6大技巧」嗨到不想停...
正在阅读:贪玩蓝月为什么能请那么多明星 请那么多明星原因贪玩蓝月为什么能请那么多明星 请那么多明星原因
EV (Exposure Value)、P-line Table、Shutter (曝光时间)、ISO (感光度) 之间关系
4小时?第二天?喝完酒后多久可以开车?这几个例子告诉你答案