Commit c4c50182 authored by Stefan Westerfeld's avatar Stefan Westerfeld

DOCS: update documentation / videowmark for windows build

See #45.
Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent bc5f317c
......@@ -22,6 +22,8 @@
*
*/
//---------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <cstdio>
......@@ -29,14 +31,21 @@
#include <algorithm>
#include <filesystem>
//---------------------------------------------------------------------------
using namespace std;
//---------------------------------------------------------------------------
string g_sVersion = "videowmark 0.0.5";
string g_sFFMPEG_VERBOSE = "-v error";
string g_sFFProbe = "ffprobe.exe";
string g_sFFMpeg = "ffmpeg.exe";
string g_sAudiowmark = "audiowmark.exe";
int g_iQuiet = 0;
//---------------------------------------------------------------------------
#define STRING_LENGTH 4096
//---------------------------------------------------------------------------
......@@ -49,17 +58,17 @@ int die(string sErrorMsg)
}
//---------------------------------------------------------------------------
//Fix me
//Maybe there is es better solution
// Fix me
// Maybe there is es better solution
//
//The result of getenv is not correct in cygwin environment.
// The result of getenv is not correct in cygwin environment.
//
//Example: getenv("TEMP");
// Example: getenv("TEMP");
//
//Result : /cygdrive/c/path/to/temp
//But should be: c:\path\to\temp
// Result : /cygdrive/c/path/to/temp
// But should be: c:\path\to\temp
//
//This is a workaround to repair the path
// This is a workaround to repair the path
string repair_cygwin_path(string sPath)
{
int i = 0;
......@@ -69,7 +78,7 @@ string sResult = "";
{
sPath.erase(0, 10);
for(i = 0; i < sPath.length(); i++)
for(i = 0; i < int(sPath.length()); i++)
{
if(sPath[i] == '/')
{
......@@ -89,14 +98,13 @@ string sResult = "";
}
//---------------------------------------------------------------------------
//Fix me
//Maybe there is es better solution
// Converts the Windows path to the UNIX path
string get_unix_path(string sPath)
{
int i = 0;
string sResult = "";
for(i = 0; i < sPath.length(); i++)
for(i = 0; i < int(sPath.length()); i++)
{
if(sPath[i] == '\\')
{
......@@ -110,6 +118,108 @@ string sResult = "";
}
//---------------------------------------------------------------------------
// Converts the UNIX path to the Windows path
string get_windows_path(string sPath)
{
int i = 0;
string sResult = "";
for(i = 0; i < int(sPath.length()); i++)
{
if(sPath[i] == '/')
{
sPath[i] = '\\';
}
}
sResult = sPath;
return sResult;
}
//---------------------------------------------------------------------------
// Completes the path if necessary
string complete_path(string sPath)
{
int iPathLength = 0;
bool bUNIX = true;
string sResult = "";
iPathLength = sPath.length();
if(iPathLength > 0)
{
if(int(sPath.find("\\")) >= 0 )
{
bUNIX = false;
}
if(bUNIX == true)
{ // UNIX
if(sPath[iPathLength-1] != '/')
{
sPath += "/";
}
}
else
{ // Windows
if(sPath[iPathLength-1] != '\\')
{
sPath += "\\";
}
}
}
sResult = sPath;
return sResult;
}
//---------------------------------------------------------------------------
// Set the current working directory
string set_working_dir(string sDestExe)
{
string sResult = "";
string sWorkingDir = "";
string sPath = "";
string sTempUnixPath = "";
char cWorkingDir[STRING_LENGTH] = {};
//If something goes wrong while getting the working dir
sResult = sDestExe;
//Get current application directory
GetModuleFileNameA(NULL, cWorkingDir, STRING_LENGTH);
sWorkingDir = cWorkingDir;
if(sDestExe.length() > 0 && sWorkingDir.length() > 0)
{
//Repair the path if needed
sWorkingDir = repair_cygwin_path(sWorkingDir);
//Convert Windows path to UNIX path
sWorkingDir = get_unix_path(sWorkingDir);
//Fix me:
//Create filesystem::path object ( works in Cygwin only with UNIX path )
filesystem::path p(sWorkingDir);
//Get file path
sPath = p.parent_path();
//Completes the path if necessary
sPath = complete_path(sPath);
//Convert UNIX path to Windows path
sPath = get_windows_path(sPath);
//Build the filename
sResult = "\"" + sPath + sDestExe + "\"";
}
return sResult;
}
//---------------------------------------------------------------------------
// Create the temp file
string create_temp_file(string sFilename)
{
......@@ -132,21 +242,29 @@ string sTempFilename = "";
//Repair the path if needed
sTempPath = repair_cygwin_path(sTempPath);
//Fix me:
//filesystem::path in Cygwin only works with /
//Completes the path if necessary
sTempPath = complete_path(sTempPath);
//Convert Windows path to UNIX path
sTempUnixFilename = get_unix_path(sFilename);
//Fix me:
//Create filesystem::path object ( works in Cygwin only with UNIX path )
filesystem::path p(sTempUnixFilename);
//Get filename without path
sFilenameWoPath = p.filename();
sTempFilename = sTempPath + "\\" + sFilenameWoPath;
//Create filename
sTempFilename = sTempPath + sFilenameWoPath;
//Create temp file at destination
if(CopyFile(sFilename.c_str(), sTempFilename.c_str(), false) == false)
{
die("Could not create temp file");
}
//Return file path
return sTempFilename;
}
//---------------------------------------------------------------------------
......@@ -162,11 +280,10 @@ bool delete_temp_file(string sFilename)
string ExecCmd(string sCMD /* [in] command to execute */ )
{
int i = 0;
string strResult = "";
char cmd[STRING_LENGTH] = {};
HANDLE hPipeRead = 0;
HANDLE hPipeWrite = 0;
string strResult = "";
char cmd[STRING_LENGTH] = {};
HANDLE hPipeRead = 0;
HANDLE hPipeWrite = 0;
strcpy(cmd, sCMD.c_str());
......@@ -248,7 +365,6 @@ string sProbeResult = "";
string sTempResult = "";
string sBitRate = "";
string sData = "";
char cResult[STRING_LENGTH] = {};
int i = 0;
int iPos = 0;
......@@ -260,7 +376,7 @@ int iPos = 0;
sProbeResult = ExecCmd(sCMD);
//Parse to find the audio line
for(i = 0; i < sProbeResult.length(); i++)
for(i = 0; i < int(sProbeResult.length()); i++)
{
if(sProbeResult[i] != 0x0d && sProbeResult[i] != 0x0a)
{
......@@ -285,7 +401,7 @@ int iPos = 0;
if(sResult.length() > 0)
{
sValue = "codec_name=";
iPos = sResult.find(sValue);
iPos = int(sResult.find(sValue));
if(iPos > 0)
{
iPos += sValue.length();
......@@ -297,7 +413,7 @@ int iPos = 0;
}
sValue = "bit_rate=";
iPos = sResult.find(sValue);
iPos = int(sResult.find(sValue));
if(iPos > 0)
{
iPos += sValue.length();
......@@ -399,7 +515,6 @@ string sTempFilenameAudioWM = "";
// check file extensions
sExtIn = extension(sInFile);
sExtOut = extension(sOutFile);
if(sExtIn != sExtOut)
{
die("input/output extension must match ('" + sExtIn + "' vs. '" + sExtOut + "')");
......@@ -518,7 +633,6 @@ string sTempPath = "";
string sResult = "";
string sTempFilenameVideo = "";
string sTempFilenameAudio = "";
char cResult[STRING_LENGTH] = {};
// check audio/video stream count
sResult = audio_video_stream_count(sFilename);
......@@ -593,6 +707,13 @@ char cResult[STRING_LENGTH] = {};
}
//---------------------------------------------------------------------------
void show_version_and_exit()
{
printf("%s\n", g_sVersion.c_str());
exit(0);
}
//---------------------------------------------------------------------------
void show_help_and_exit()
{
printf(
......@@ -610,6 +731,9 @@ void show_help_and_exit()
" --key <file> load watermarking key from file\n"
" -q, --quiet disable information messages\n"
" -v, --verbose enable ffmpeg verbose output\n"
" --version show the current videowmark version\n"
" --detect-speed detect and correct replay speed difference\n"
" --detect-speed-patient slower, more accurate speed detection\n"
);
exit(0);
......@@ -625,25 +749,33 @@ string sFilename = "";
string sInFile = "";
string sOutFile = "";
string sHash = "";
string sARGS = "";
int i = 0;
string sARGS = "";
// Set the the current working directory
g_sFFProbe = set_working_dir(g_sFFProbe);
g_sFFMpeg = set_working_dir(g_sFFMpeg);
g_sAudiowmark = set_working_dir(g_sAudiowmark);
if(argc > 1)
{
//Get all args
// Get all args
for(i = 1; i < argc; i++)
{
if(string(argv[i]) == "-v" || string(argv[i]) == "--verbose")
{
g_sFFMPEG_VERBOSE = "-v info";
}
else if(string(argv[i]) == "--version")
{
show_version_and_exit();
}
else if(string(argv[i]) == "-q" || string(argv[i]) == "--quiet")
{
sARGS += " -q";
g_iQuiet = 1;
}
else if(string(argv[i]) == "--detect-speed")
else if(string(argv[i]) == "--detect-speed" || string(argv[i]) == "--detect-speed-patient")
{
sARGS += " " + string(argv[i]);
}
......@@ -697,7 +829,7 @@ int i = 0;
}
}
//Get and execute action
// Get and execute action
if(sAction == "add" && sInFile.length() > 0 && sOutFile.length() > 0 && sHash.length() > 0)
{
add_watermark(sInFile, sOutFile, sHash, sARGS);
......
Last update: 05.03.2024
In this step-by-step guide I show how to build Audiowmark
to run it on Windows x64.
......@@ -64,7 +66,7 @@ Prepare everything:
- Extract zita-resempler-main.zip to c:\zita-resempler-main
- Extract audiowmark-0.6.2.zip to c:\audiowmark-0.6.2
- Extract audiowmark-0.6.2.tar.zst to c:\audiowmark-0.6.2
Edit "c:\audiowmark-0.6.2\src\utils.cc" and insert the following line directly below the comment section ( needed for vasprintf )
#define _GNU_SOURCE
......@@ -73,7 +75,7 @@ Prepare everything:
- Extract x86_64-13.2.0-release-posix-seh-msvcrt-rt_v11-rev0.7z\mingw64 to c:\mingw64
- Add "C:\mingw64\bin" to the system path variable and place it at the top most position
- Add "C:\mingw64\bin" to the system path variable and place it at the very first position
- Important : Restart Windows !
......@@ -117,6 +119,7 @@ Prepare everything:
- Install FFmpeg
- Copy ALL files from "C:\ffmpeg-master-latest-win64-gpl-shared\bin\*.*" to "C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin"
- Copy ALL files ( except dir "pkgconfig" ) from "C:\ffmpeg-master-latest-win64-gpl-shared\lib\*.*" to "C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\lib"
- Copy ALL files ( except dir "pkgconfig" ) from "C:\ffmpeg-master-latest-win64-gpl-shared\lib\*.*" to "C:\cygwin64\usr\x86_64-pc-cygwin\lib"
- Copy ALL .pc-files from "C:\ffmpeg-master-latest-win64-gpl-shared\lib\pkgconfig\*.pc" to "C:\cygwin64\lib\pkgconfig"
- Copy ALL sub directories from "C:\ffmpeg-master-latest-win64-gpl-shared\include\*" to "C:\audiowmark-0.6.2\src\*"
......@@ -127,10 +130,10 @@ Now we should be ready to build the audiowmark source code:
Change the current directory to: /cygdrive/c/audiowmark-0.6.2
- Type in:
./configure --host=x86_64-pc-cygwin
./configure --host=x86_64-pc-cygwin --with-ffmpeg
- Type in:
make.exe
make
All created EXE-files will be saved to "C:\audiowmark-0.6.2\src\.libs"
Note : There is another, significantly smaller version of each EXE file in "C:\audiowmark-0.6.2\src\". Don't use these. They don't work.
......@@ -153,13 +156,24 @@ And that's a lot.
Every single DLL- and EXE-file we will find somewhere in "C:\cygwin64"
Each file must be copied into the SAME directory where the EXE file is located.
Location: C:\audiowmark-0.6.2\src\.libs\
---------------
Location in Windows : C:\audiowmark-0.6.2\src\.libs\
Location in Cygwin : /cygdrive/c/audiowmark-0.6.2/src/.libs
---------------
audiowmark.exe
C:\audiowmark-0.6.2\src\
---------------
Location in Windows : C:\audiowmark-0.6.2\src\
Location in Cygwin : /cygdrive/c/audiowmark-0.6.2/src/
---------------
videowmark.exe
Location: /usr/x86_64-w64-mingw32/sys-root/mingw/bin/
---------------
Location in Windows : C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin
Location in Cygwin : /usr/x86_64-w64-mingw32/sys-root/mingw/bin/
---------------
ffmpeg.exe
ffplay.exe
ffprobe.exe
......@@ -180,7 +194,10 @@ swresample-4.dll
swscale-7.dll
Location: /usr/bin/
---------------
Location in Windows : C:\cygwin64\bin
Location in Cygwin : /usr/bin/
---------------
cygiconv-2.dll
cygintl-8.dll
cyggpg-error-0.dll
......@@ -198,7 +215,11 @@ cygwin1.dll
cyggcc_s-seh-1.dll
cygfftw3f-3.dll
Location: /usr/x86_64-pc-cygwin/bin/
---------------
Location in Windows : C:\cygwin64\usr\x86_64-pc-cygwin\bin
Location in Cygwin : /usr/x86_64-pc-cygwin/bin/
---------------
libzita-resampler.dll
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment