Create a Console App in Visual Studio on Windows
Contents
Create a Console App in Visual Studio on Windows#
This topic describes the steps needed to configure a C++ Console App in Visual Studio. These steps have been verified to work with Visual Studio 2022 Community Edition, on Windows 11 (22H2).
Create the Visual Studio project#
Create a C++, Console App in Visual Studio. Name the project
simple-converter. CheckPlace solution and project in the same directory.Download the 64 bit version of AVBlocks for C++ (Windows). The file you need will have a name similar to
avblocks-v3.1.0-demo.1-windows.zip- the version number may differ.Extract the ZIP archive in a location of your choice, then copy the
includeandlibdirectories to theavblockssubdirectory of the Visual Studio solution directory. The Visual Studio solution is the directory that contains thesimple-converter.slnsolution file.You should end up with a directory structure similar to the following:
simple-converter ├───avblocks │ ├───include │ └───lib ├───simple-converter.cpp ├───simple-converter.sln └───simple-converter.vcxproj
Replace the contents of
simple-converter.cppwith this code:#include <primo/avblocks/avb.h> #include <primo/platform/reference++.h> // link with AVBlocks64.lib #pragma comment(lib, "./avblocks/lib/x64/AVBlocks64.lib") using namespace primo::codecs; using namespace primo::avblocks; int main(int argc, const char * argv[]) { // needed for WMV CoInitializeEx(nullptr, COINITBASE_MULTITHREADED); Library::initialize(); auto inputInfo = primo::make_ref(Library::createMediaInfo()); inputInfo->inputs()->at(0)->setFile(L"Wildlife.wmv"); if (inputInfo->open()) { auto inputSocket = primo::make_ref(Library::createMediaSocket(inputInfo.get())); auto outputSocket = primo::make_ref(Library::createMediaSocket(Preset::Video::Generic::MP4::Base_H264_AAC)); outputSocket->setFile(L"Wildlife.mp4"); auto transcoder = primo::make_ref(Library::createTranscoder()); transcoder->inputs()->add(inputSocket.get()); transcoder->outputs()->add(outputSocket.get()); if (transcoder->open()) { transcoder->run(); transcoder->close(); } } Library::shutdown(); CoUninitialize(); return 0; }
In Visual Studio, select
Build | Configuration Managerfrom the menu, then select thex64platform to the solution platforms.In Visual Studio, select
Project | simple-converter Propertiesfrom the menu, thenC++ | General, then add./avblocks/includetoAdditional Include Directories.Build the project (Ctrl + Shift + B).
Copy the file
AVBlocks64.dllfromavblocks/lib/x64tox64/Debug.
Run the application#
Download the
Wildlife.wmvHD movie from the Internet Archive and save it in the Visual Studio solution directory (next to thesimple-converter.slnsolution file).Run the application in Visual Studio. Wait a few seconds for the Transcoder to finish. The converted file
Wildlife.mp4will be in the solution directory.
Troubleshooting#
You may get
The program can't start because AVBlocks64.dll is missing from your computer. Try reinstalling the program to fix this problem.or a similar message. To fix that, copy the fileAVBlocks64.dllfromavblocks/lib/x64tox64/Debug.transcoder->open()may fail if there is already a fileWildlife.mp4in the project directory. DeleteWildlife.mp4to solve that.