mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Decoding subtitles streams.
This commit is contained in:
parent
3cf861a7c3
commit
5baf78fdde
@ -7,12 +7,12 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
extern "C" API struct Stream
|
//extern "C" API struct Stream
|
||||||
{
|
//{
|
||||||
std::string title;
|
// std::string title;
|
||||||
std::string languageCode;
|
// std::string languageCode;
|
||||||
std::string format;
|
// std::string format;
|
||||||
bool isDefault;
|
// bool isDefault;
|
||||||
bool isForced;
|
// bool isForced;
|
||||||
std::string path;
|
// std::string path;
|
||||||
};
|
//};
|
@ -13,11 +13,6 @@ int Init()
|
|||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Video ScanVideo(std::string path)
|
|
||||||
//{
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
void ExtractSubtitles(const char* path)
|
void ExtractSubtitles(const char* path)
|
||||||
{
|
{
|
||||||
AVFormatContext* formatContext = NULL;
|
AVFormatContext* formatContext = NULL;
|
||||||
@ -34,12 +29,24 @@ void ExtractSubtitles(const char* path)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVDictionaryEntry* metadata = NULL;
|
for (unsigned int i = 0; i < formatContext->nb_streams; i++)
|
||||||
|
|
||||||
while ((metadata = av_dict_get(formatContext->metadata, "", metadata, AV_DICT_IGNORE_SUFFIX)))
|
|
||||||
{
|
{
|
||||||
std::cout << metadata->key << " - " << metadata->value << std::endl;
|
AVStream* stream = formatContext->streams[i];
|
||||||
|
const AVCodecContext* streamContext = stream->codec;
|
||||||
|
|
||||||
|
if (streamContext->codec_type == AVMEDIA_TYPE_SUBTITLE)
|
||||||
|
{
|
||||||
|
const AVCodec* dec = streamContext->codec;
|
||||||
|
std::cout << "Stream #" << i << ", stream type: " << streamContext->codec_type << " codec: " << dec->long_name << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//const char* outputPath = "subtitle.ass";
|
||||||
|
//if (avformat_alloc_output_context2(&formatContext, NULL, NULL, outputPath) < 0)
|
||||||
|
//{
|
||||||
|
// std::cout << "Error: Can't create output file at " << outputPath << std::endl;
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
avformat_close_input(&formatContext);
|
avformat_close_input(&formatContext);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace Kyoo.InternalAPI
|
|||||||
|
|
||||||
public void ExtractSubtitles(string path)
|
public void ExtractSubtitles(string path)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("&Transcoder extract subs: " + TranscoderAPI.ExtractSubtitles(path));
|
TranscoderAPI.ExtractSubtitles(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetVideo(string path)
|
public void GetVideo(string path)
|
||||||
|
@ -7,9 +7,9 @@ namespace Kyoo.InternalAPI.TranscoderLink
|
|||||||
private const string TranscoderPath = @"C:\Projects\Kyoo\Debug\Kyoo.Transcoder.dll";
|
private const string TranscoderPath = @"C:\Projects\Kyoo\Debug\Kyoo.Transcoder.dll";
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public extern static string Init();
|
public extern static int Init();
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public extern static string ExtractSubtitles(string path);
|
public extern static void ExtractSubtitles(string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user