I'm writening a little program to retrieve informations with mediainfo, informations used after by the program
For this i have made a function getinfo() :
* Have you tried with the last version (0.7.5.4)? I corrected some memory problems in this version
* Maybe the IFO parser crashes, I have corrected something in it with te last development snapshot: https://sourceforge.net/project/showfiles.php?group_id=86862&package_id=197932&release_id=551761
Please test this version
* Limitation of 255 characters is a VERY BAD idea. returned strings are NOT limited, if you want to do copies, do it with strncpy(dest, src, 254); dest[254]='\0'
* You use the C++ version of the interface, why not using std::string?
* If always a crash, is it only with THIS file, or any? I this file only, I am interested in having it, please send it at zen@mediaarea.net
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm writening a little program to retrieve informations with mediainfo, informations used after by the program
For this i have made a function getinfo() :
#include "MediaInfoDLL.h" //Dynamicly-loaded library (.dll or .so)
#include <iostream>
#include <iomanip>
using namespace MediaInfoLib;
int getinfo (char * fichier)
{
MediaInfo MI;
char MiV[255];
char VidCodec[255];
char VidWidth[255];
char VidHeight[255];
char AudCodec0[255];
char AudCodec1[255];
char AudCodec2[255];
char AudLanguage0[255];
char AudLanguage1[255];
char AudLanguage2[255];
char SubLanguage0[255];
char SubLanguage1[255];
char SubLanguage2[255];
// Récupération de la version de MediaInfo utilisée
strcpy(MiV,MI.Option(_T("Info_Version"), _T("0.7.0.0;MediaInfoDLL_Example_MSVC;0.7.0.0")).c_str());
//ouverture du fichier
MI.Open(_T(fichier));
//récupération des variables
strcpy(VidCodec,MI.Get(Stream_Video, 0, _T("Codec"), Info_Text, Info_Name).c_str());
strcpy(VidWidth,MI.Get(Stream_Video, 0, _T("Width"), Info_Text, Info_Name).c_str());
strcpy(VidHeight,MI.Get(Stream_Video, 0, _T("Height"), Info_Text, Info_Name).c_str());
strcpy(AudCodec0,MI.Get(Stream_Audio, 0, _T("Codec"), Info_Text, Info_Name).c_str());
strcpy(AudCodec1,MI.Get(Stream_Audio, 1, _T("Codec"), Info_Text, Info_Name).c_str());
strcpy(AudCodec2,MI.Get(Stream_Audio, 2, _T("Codec"), Info_Text, Info_Name).c_str());
strcpy(AudLanguage0,MI.Get(Stream_Audio, 0, _T("Language"), Info_Text, Info_Name).c_str());
strcpy(AudLanguage1,MI.Get(Stream_Audio, 1, _T("Language"), Info_Text, Info_Name).c_str());
strcpy(AudLanguage2,MI.Get(Stream_Audio, 2, _T("Language"), Info_Text, Info_Name).c_str());
strcpy(SubLanguage0,MI.Get(Stream_Text, 0, _T("Language"), Info_Text, Info_Name).c_str());
strcpy(SubLanguage1,MI.Get(Stream_Text, 1, _T("Language"), Info_Text, Info_Name).c_str());
strcpy(SubLanguage2,MI.Get(Stream_Text, 2, _T("Language"), Info_Text, Info_Name).c_str());
// Fermeture du fichier
MI.Close();
//Affichage des variables
printf("Informations recuperee avec %s\n",MiV);
printf("Codec Video : %s\n",VidCodec);
printf("resolution %sx%s\n",VidWidth,VidHeight);
printf("Codec Audio 0 : %s\n",AudCodec0);
printf("Langage Audio 0 : %s\n",AudLanguage0);
printf("Codec Audio 1 : %s\n",AudCodec1);
printf("Langage Audio 1 : %s\n",AudLanguage1);
printf("Codec Audio 2 : %s\n",AudCodec2);
printf("Langage Audio 2 : %s\n",AudLanguage2);
printf("Langage Sous-Titre 0 : %s\n",SubLanguage0);
printf("Langage Sous-Titre 1 : %s\n",SubLanguage1);
printf("Langage Sous-Titre 2 : %s\n",SubLanguage2);
return 0;
}
In my main program if i do :
getinfo("Z:/Films/X-Men/X-Men 2/VIDEO_TS/VTS_01_0.IFO");
getinfo("Z:/Films/X-Men/X-Men/VIDEO_TS/VTS_01_0.IFO");
it works perfectly
and if i do:
char urlfilm[255];
char sousdossier[255];
sprintf(sousdossier,"%s/","Z:/Films/X-Men/X-Men/VIDEO_TS");
sprintf(urlfilm,"%sVTS_01_0.IFO",sousdossier);
getinfo(urlfilm);
sprintf(sousdossier,"%s/","Z:/Films/X-Men/X-Men 2/VIDEO_TS");
sprintf(urlfilm,"%sVTS_01_0.IFO",sousdossier);
getinfo(urlfilm);
it crashes on the second getinfo call with a segmentation fault
I dont understand why for me it's quiet the same
what have i done wrong in my getinfo ?
Thanks
* Have you tried with the last version (0.7.5.4)? I corrected some memory problems in this version
* Maybe the IFO parser crashes, I have corrected something in it with te last development snapshot: https://sourceforge.net/project/showfiles.php?group_id=86862&package_id=197932&release_id=551761
Please test this version
* Limitation of 255 characters is a VERY BAD idea. returned strings are NOT limited, if you want to do copies, do it with strncpy(dest, src, 254); dest[254]='\0'
* You use the C++ version of the interface, why not using std::string?
* If always a crash, is it only with THIS file, or any? I this file only, I am interested in having it, please send it at zen@mediaarea.net