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 @@ ...@@ -22,6 +22,8 @@
* *
*/ */
//---------------------------------------------------------------------------
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <cstdio> #include <cstdio>
...@@ -29,14 +31,21 @@ ...@@ -29,14 +31,21 @@
#include <algorithm> #include <algorithm>
#include <filesystem> #include <filesystem>
//---------------------------------------------------------------------------
using namespace std; using namespace std;
//---------------------------------------------------------------------------
string g_sVersion = "videowmark 0.0.5";
string g_sFFMPEG_VERBOSE = "-v error"; string g_sFFMPEG_VERBOSE = "-v error";
string g_sFFProbe = "ffprobe.exe"; string g_sFFProbe = "ffprobe.exe";
string g_sFFMpeg = "ffmpeg.exe"; string g_sFFMpeg = "ffmpeg.exe";
string g_sAudiowmark = "audiowmark.exe"; string g_sAudiowmark = "audiowmark.exe";
int g_iQuiet = 0; int g_iQuiet = 0;
//---------------------------------------------------------------------------
#define STRING_LENGTH 4096 #define STRING_LENGTH 4096
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -49,17 +58,17 @@ int die(string sErrorMsg) ...@@ -49,17 +58,17 @@ int die(string sErrorMsg)
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//Fix me // Fix me
//Maybe there is es better solution // 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 // Result : /cygdrive/c/path/to/temp
//But should be: 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) string repair_cygwin_path(string sPath)
{ {
int i = 0; int i = 0;
...@@ -69,7 +78,7 @@ string sResult = ""; ...@@ -69,7 +78,7 @@ string sResult = "";
{ {
sPath.erase(0, 10); sPath.erase(0, 10);
for(i = 0; i < sPath.length(); i++) for(i = 0; i < int(sPath.length()); i++)
{ {
if(sPath[i] == '/') if(sPath[i] == '/')
{ {
...@@ -89,14 +98,13 @@ string sResult = ""; ...@@ -89,14 +98,13 @@ string sResult = "";
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//Fix me // Converts the Windows path to the UNIX path
//Maybe there is es better solution
string get_unix_path(string sPath) string get_unix_path(string sPath)
{ {
int i = 0; int i = 0;
string sResult = ""; string sResult = "";
for(i = 0; i < sPath.length(); i++) for(i = 0; i < int(sPath.length()); i++)
{ {
if(sPath[i] == '\\') if(sPath[i] == '\\')
{ {
...@@ -110,6 +118,108 @@ string sResult = ""; ...@@ -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 // Create the temp file
string create_temp_file(string sFilename) string create_temp_file(string sFilename)
{ {
...@@ -132,21 +242,29 @@ string sTempFilename = ""; ...@@ -132,21 +242,29 @@ string sTempFilename = "";
//Repair the path if needed //Repair the path if needed
sTempPath = repair_cygwin_path(sTempPath); sTempPath = repair_cygwin_path(sTempPath);
//Fix me: //Completes the path if necessary
//filesystem::path in Cygwin only works with / sTempPath = complete_path(sTempPath);
//Convert Windows path to UNIX path
sTempUnixFilename = get_unix_path(sFilename); sTempUnixFilename = get_unix_path(sFilename);
//Fix me:
//Create filesystem::path object ( works in Cygwin only with UNIX path )
filesystem::path p(sTempUnixFilename); filesystem::path p(sTempUnixFilename);
//Get filename without path
sFilenameWoPath = p.filename(); 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) if(CopyFile(sFilename.c_str(), sTempFilename.c_str(), false) == false)
{ {
die("Could not create temp file"); die("Could not create temp file");
} }
//Return file path
return sTempFilename; return sTempFilename;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -162,11 +280,10 @@ bool delete_temp_file(string sFilename) ...@@ -162,11 +280,10 @@ bool delete_temp_file(string sFilename)
string ExecCmd(string sCMD /* [in] command to execute */ ) string ExecCmd(string sCMD /* [in] command to execute */ )
{ {
int i = 0; int i = 0;
string strResult = "";
string strResult = ""; char cmd[STRING_LENGTH] = {};
char cmd[STRING_LENGTH] = {}; HANDLE hPipeRead = 0;
HANDLE hPipeRead = 0; HANDLE hPipeWrite = 0;
HANDLE hPipeWrite = 0;
strcpy(cmd, sCMD.c_str()); strcpy(cmd, sCMD.c_str());
...@@ -248,7 +365,6 @@ string sProbeResult = ""; ...@@ -248,7 +365,6 @@ string sProbeResult = "";
string sTempResult = ""; string sTempResult = "";
string sBitRate = ""; string sBitRate = "";
string sData = ""; string sData = "";
char cResult[STRING_LENGTH] = {};
int i = 0; int i = 0;
int iPos = 0; int iPos = 0;
...@@ -260,7 +376,7 @@ int iPos = 0; ...@@ -260,7 +376,7 @@ int iPos = 0;
sProbeResult = ExecCmd(sCMD); sProbeResult = ExecCmd(sCMD);
//Parse to find the audio line //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) if(sProbeResult[i] != 0x0d && sProbeResult[i] != 0x0a)
{ {
...@@ -285,7 +401,7 @@ int iPos = 0; ...@@ -285,7 +401,7 @@ int iPos = 0;
if(sResult.length() > 0) if(sResult.length() > 0)
{ {
sValue = "codec_name="; sValue = "codec_name=";
iPos = sResult.find(sValue); iPos = int(sResult.find(sValue));
if(iPos > 0) if(iPos > 0)
{ {
iPos += sValue.length(); iPos += sValue.length();
...@@ -297,7 +413,7 @@ int iPos = 0; ...@@ -297,7 +413,7 @@ int iPos = 0;
} }
sValue = "bit_rate="; sValue = "bit_rate=";
iPos = sResult.find(sValue); iPos = int(sResult.find(sValue));
if(iPos > 0) if(iPos > 0)
{ {
iPos += sValue.length(); iPos += sValue.length();
...@@ -399,7 +515,6 @@ string sTempFilenameAudioWM = ""; ...@@ -399,7 +515,6 @@ string sTempFilenameAudioWM = "";
// check file extensions // check file extensions
sExtIn = extension(sInFile); sExtIn = extension(sInFile);
sExtOut = extension(sOutFile); sExtOut = extension(sOutFile);
if(sExtIn != sExtOut) if(sExtIn != sExtOut)
{ {
die("input/output extension must match ('" + sExtIn + "' vs. '" + sExtOut + "')"); die("input/output extension must match ('" + sExtIn + "' vs. '" + sExtOut + "')");
...@@ -518,7 +633,6 @@ string sTempPath = ""; ...@@ -518,7 +633,6 @@ string sTempPath = "";
string sResult = ""; string sResult = "";
string sTempFilenameVideo = ""; string sTempFilenameVideo = "";
string sTempFilenameAudio = ""; string sTempFilenameAudio = "";
char cResult[STRING_LENGTH] = {};
// check audio/video stream count // check audio/video stream count
sResult = audio_video_stream_count(sFilename); sResult = audio_video_stream_count(sFilename);
...@@ -593,6 +707,13 @@ char cResult[STRING_LENGTH] = {}; ...@@ -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() void show_help_and_exit()
{ {
printf( printf(
...@@ -610,6 +731,9 @@ void show_help_and_exit() ...@@ -610,6 +731,9 @@ void show_help_and_exit()
" --key <file> load watermarking key from file\n" " --key <file> load watermarking key from file\n"
" -q, --quiet disable information messages\n" " -q, --quiet disable information messages\n"
" -v, --verbose enable ffmpeg verbose output\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); exit(0);
...@@ -625,25 +749,33 @@ string sFilename = ""; ...@@ -625,25 +749,33 @@ string sFilename = "";
string sInFile = ""; string sInFile = "";
string sOutFile = ""; string sOutFile = "";
string sHash = ""; string sHash = "";
string sARGS = "";
int i = 0; 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) if(argc > 1)
{ {
//Get all args // Get all args
for(i = 1; i < argc; i++) for(i = 1; i < argc; i++)
{ {
if(string(argv[i]) == "-v" || string(argv[i]) == "--verbose") if(string(argv[i]) == "-v" || string(argv[i]) == "--verbose")
{ {
g_sFFMPEG_VERBOSE = "-v info"; 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") else if(string(argv[i]) == "-q" || string(argv[i]) == "--quiet")
{ {
sARGS += " -q"; sARGS += " -q";
g_iQuiet = 1; 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]); sARGS += " " + string(argv[i]);
} }
...@@ -697,7 +829,7 @@ int i = 0; ...@@ -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) if(sAction == "add" && sInFile.length() > 0 && sOutFile.length() > 0 && sHash.length() > 0)
{ {
add_watermark(sInFile, sOutFile, sHash, sARGS); add_watermark(sInFile, sOutFile, sHash, sARGS);
......
Last update: 05.03.2024
In this step-by-step guide I show how to build Audiowmark In this step-by-step guide I show how to build Audiowmark
to run it on Windows x64. to run it on Windows x64.
...@@ -64,7 +66,7 @@ Prepare everything: ...@@ -64,7 +66,7 @@ Prepare everything:
- Extract zita-resempler-main.zip to c:\zita-resempler-main - 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 ) 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 #define _GNU_SOURCE
...@@ -73,7 +75,7 @@ Prepare everything: ...@@ -73,7 +75,7 @@ Prepare everything:
- Extract x86_64-13.2.0-release-posix-seh-msvcrt-rt_v11-rev0.7z\mingw64 to c:\mingw64 - 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 ! - Important : Restart Windows !
...@@ -117,6 +119,7 @@ Prepare everything: ...@@ -117,6 +119,7 @@ Prepare everything:
- Install FFmpeg - 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 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-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 .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\*" - 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: ...@@ -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 Change the current directory to: /cygdrive/c/audiowmark-0.6.2
- Type in: - Type in:
./configure --host=x86_64-pc-cygwin ./configure --host=x86_64-pc-cygwin --with-ffmpeg
- Type in: - Type in:
make.exe make
All created EXE-files will be saved to "C:\audiowmark-0.6.2\src\.libs" 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. 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. ...@@ -153,13 +156,24 @@ And that's a lot.
Every single DLL- and EXE-file we will find somewhere in "C:\cygwin64" 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. 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 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 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 ffmpeg.exe
ffplay.exe ffplay.exe
ffprobe.exe ffprobe.exe
...@@ -180,7 +194,10 @@ swresample-4.dll ...@@ -180,7 +194,10 @@ swresample-4.dll
swscale-7.dll swscale-7.dll
Location: /usr/bin/ ---------------
Location in Windows : C:\cygwin64\bin
Location in Cygwin : /usr/bin/
---------------
cygiconv-2.dll cygiconv-2.dll
cygintl-8.dll cygintl-8.dll
cyggpg-error-0.dll cyggpg-error-0.dll
...@@ -198,7 +215,11 @@ cygwin1.dll ...@@ -198,7 +215,11 @@ cygwin1.dll
cyggcc_s-seh-1.dll cyggcc_s-seh-1.dll
cygfftw3f-3.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 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