Skip to content

Commit

Permalink
Merge pull request #1796 from JeromeMartinez/MP4_tagc
Browse files Browse the repository at this point in the history
MP4: support of media characteristic (spoken dialog, translation, easy to read...)
  • Loading branch information
JeromeMartinez authored Jun 16, 2023
2 parents 598d69d + 5440ca1 commit bf4425b
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Source/MediaInfo/Export/Export_Mpeg7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,16 @@ static Node* Mpeg7_CS(Node* Node_MediaFormat, const char* MainName, const char*
static const char* Mpeg7_ServiceKind2Type[][2] =
{
{ "Dubbed", "dubbed"},
{ "Commentary", "commentary"},
{ "EasyReader", "easyReader"},
{ "HI", "hearingImpaired"},
{ "HI-ME", "hearingImpaired"},
{ "HI-D", "hearingImpaired"},
{ "Translated", "translated"},
{ "Supplementary", "supplementary"},
{ "VI", "visuallyImpaired"},
{ "VI-ME", "visuallyImpaired"},
{ "VI-D", "visuallyImpaired"},
};
static const size_t Mpeg7_ServiceKind2Type_Size=sizeof(Mpeg7_ServiceKind2Type)/sizeof(*Mpeg7_ServiceKind2Type);
static const char* Mpeg7_ServiceKind2Type_Get(const char* Value)
Expand Down
38 changes: 38 additions & 0 deletions Source/MediaInfo/File__Analyze_Streams_Finish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,44 @@ void File__Analyze::Streams_Finish_StreamOnly(stream_t StreamKind, size_t Pos)
if (Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Mode)).empty())
Fill(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Mode), "CBR");
}

//ServiceKind
auto ServiceKind = Retrieve(StreamKind, Pos, "ServiceKind");
if (!ServiceKind.empty())
{
ZtringList List;
List.Separator_Set(0, __T(" / "));
List.Write(ServiceKind);
if (List.size()>1)
{
size_t HI_ME_Pos=(size_t)-1;
size_t HI_D_Pos=(size_t)-1;
static const auto HI_ME_Text=__T("HI-ME");
static const auto HI_D_Text=__T("HI-D");
static const auto VI_ME_Text=__T("VI-ME");
static const auto VI_D_Text=__T("VI-D");
for (size_t i=0; i<List.size(); i++)
{
const auto& Item=List[i];
if (HI_ME_Pos==(size_t)-1 && (Item==HI_ME_Text || Item==VI_ME_Text))
HI_ME_Pos=i;
if (HI_D_Pos==(size_t)-1 && (Item==HI_D_Text || Item==HI_D_Text))
HI_D_Pos=i;
}
if (HI_ME_Pos!=(size_t)-1 && HI_D_Pos!=(size_t)-1)
{
if (HI_ME_Pos>HI_D_Pos)
std::swap(HI_ME_Pos, HI_D_Pos);
List[HI_ME_Pos]=__T("HI");
List.erase(List.begin()+HI_D_Pos);
Fill(StreamKind, Pos, "ServiceKind", List.Read(), true);
List.Write(Retrieve(StreamKind, Pos, "ServiceKind/String"));
List[HI_ME_Pos].From_UTF8("Hearing Impaired");
List.erase(List.begin()+HI_D_Pos);
Fill(StreamKind, Pos, "ServiceKind/String", List.Read(), true);
}
}
}
}

//---------------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions Source/MediaInfo/Multiple/File_Mpeg4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace Elements
const int64u moov_meta__sonm=0x736F6E6D;
const int64u moov_meta__sosn=0x736F736E;
const int64u moov_meta__stik=0x7374696B;
const int64u moov_meta__tagc=0x74616763;
const int64u moov_meta__titl=0x7469746C;
const int64u moov_meta__tool=0x746F6F6C;
const int64u moov_meta__trkn=0x74726B6E;
Expand Down Expand Up @@ -568,7 +569,10 @@ void File_Mpeg4::Streams_Finish()
if (Temp->second.HasForcedSamples)
{
if (Temp->second.AllForcedSamples)
Fill(StreamKind_Last, StreamPos_Last, "Forced", "Yes");
{
if (Retrieve_Const(StreamKind_Last, StreamPos_Last, "Forced")!=__T("Yes"))
Fill(StreamKind_Last, StreamPos_Last, "Forced", "Yes");
}
else
Fill(StreamKind_Last, StreamPos_Last, "Forced", "Mixed");
if (Temp->second.ForcedFor.size())
Expand Down Expand Up @@ -3021,6 +3025,7 @@ File_Mpeg4::method File_Mpeg4::Metadata_Get(std::string &Parameter, int64u Meta)
case Elements::moov_meta__sonm : Parameter="Title/Sort"; Method=Method_String; break; //SortName
case Elements::moov_meta__sosn : Parameter="Title/Sort"; Method=Method_String; break; //SortShow
case Elements::moov_meta__stik : Parameter="ContentType"; Method=Method_Binary; break;
case Elements::moov_meta__tagc : Parameter="ServiceKind"; Method=Method_String3; break;
case Elements::moov_meta__titl : Parameter="Title"; Method=Method_String2; break;
case Elements::moov_meta__tool : Parameter="Encoded_Application"; Method=Method_String3; break;
case Elements::moov_meta__tmpo : Parameter="BPM"; Method=Method_Binary; break;
Expand All @@ -3032,7 +3037,6 @@ File_Mpeg4::method File_Mpeg4::Metadata_Get(std::string &Parameter, int64u Meta)
case Elements::moov_meta__tvsn : Parameter="Season"; Method=Method_String; break; //TVSeason
case Elements::moov_meta__xid_ : Parameter="Vendor"; Method=Method_String; break;
case Elements::moov_meta__year : Parameter="Recorded_Date"; Method=Method_String2; break;
case Elements::moov_meta__yyrc : Parameter="Recorded_Date"; Method=Method_String2; break;
default :
{
Parameter.clear();
Expand Down
78 changes: 76 additions & 2 deletions Source/MediaInfo/Multiple/File_Mpeg4_Elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9810,10 +9810,12 @@ void File_Mpeg4::moov_udta_xxxx()
}
else if (value=="forced-subtitle")
{
Fill(StreamKind_Last, StreamPos_Last, "Forced", "Yes");
if (Retrieve_Const(StreamKind_Last, StreamPos_Last, "Forced")!=__T("Yes"))
Fill(StreamKind_Last, StreamPos_Last, "Forced", "Yes");
}
else if (value=="subtitle")
{
FinalValue_String=FinalValue="Translation";
}
else if (value=="supplementary")
{
Expand Down Expand Up @@ -9984,12 +9986,84 @@ void File_Mpeg4::moov_udta_xxxx()
if (Retrieve(Stream_General, 0, Parameter.c_str()).empty())
Fill(Stream_General, 0, Parameter.c_str(), Value);
}
else if (Value.empty())
{
}
else if (Parameter=="ServiceKind")
{
auto& Field=Streams[moov_trak_tkhd_TrackID].Infos["ServiceKind"];
auto& Field_String=Streams[moov_trak_tkhd_TrackID].Infos["ServiceKind/String"];
if (Field.To_UTF8()=="Supplementary")
{
Field.clear();
Field_String.clear();
}
string FinalValue, FinalValue_String;
auto value=Value.To_UTF8();
if (false) {}
else if (value=="public.auxiliary-content")
{
if (Field.empty())
FinalValue_String=FinalValue="Supplementary";
}
else if (value=="public.accessibility.describes-music-and-sound")
{
FinalValue=string(AC3_Mode[StreamKind_Last==Stream_Audio?2:3])+'-'+AC3_Mode[1];
FinalValue_String=string(AC3_Mode_String[StreamKind_Last==Stream_Audio?2:3])+" - "+AC3_Mode_String[1];
}
else if (value=="public.accessibility.describes-video")
{
FinalValue=AC3_Mode[2];
FinalValue_String=AC3_Mode_String[2];
}
else if (value=="public.easy-to-read")
{
FinalValue="EasyReader";
FinalValue_String="Easy reader";
}
else if (value=="public.subtitles.forced-only")
{
if (Retrieve_Const(StreamKind_Last, StreamPos_Last, "Forced")!=__T("Yes"))
Fill(StreamKind_Last, StreamPos_Last, "Forced", "Yes");
}
else if (value=="public.accessibility.transcribes-spoken-dialog")
{
FinalValue=string(AC3_Mode[StreamKind_Last==Stream_Audio?2:3])+'-'+AC3_Mode[4];
FinalValue_String=string(AC3_Mode_String[StreamKind_Last==Stream_Audio?2:3])+" - "+AC3_Mode_String[4];
}
else if (value=="public.main-program-content")
{
FinalValue=AC3_Mode[0];
FinalValue_String=AC3_Mode_String[0];
}
else if (value=="public.translation")
{
FinalValue_String=FinalValue=StreamKind_Last==Stream_Audio?"Dubbed":"Translation";
}
else
FinalValue_String=FinalValue=value;
if (!FinalValue.empty())
{
if (!Field.empty())
{
Field+=__T(" / ");
Field_String+=__T(" / ");
}
Field+=Ztring().From_UTF8(FinalValue);
Field_String+=Ztring().From_UTF8(FinalValue_String);
}
}
else
{
if (Parameter!="Omud" // Some complex data is in Omud, but nothing interessant found
&& Parameter!="_SGI" // Found "_SGIxV4" with DM_IMAGE_PIXEL_ASPECT, in RLE, ignoring it for the moment
&& Parameter!="hway") // Unknown
Streams[moov_trak_tkhd_TrackID].Infos[Parameter]=Value;
{
auto& Field=Streams[moov_trak_tkhd_TrackID].Infos[Parameter];
if (!Field.empty())
Field+=__T(" / ");
Field+=Value;
}
}
FILLING_END();
}
Expand Down

0 comments on commit bf4425b

Please sign in to comment.