mirror of
https://github.com/zoriya/Kyoo.Transcoder.git
synced 2025-12-06 06:26:11 +00:00
Implementing a adprintf for windows
This commit is contained in:
@@ -18,10 +18,11 @@ set_property(TARGET transcoder PROPERTY C_STANDARD 11)
|
|||||||
set_property(TARGET transcoder PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET transcoder PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
target_link_libraries(transcoder avformat avcodec avutil)
|
target_link_libraries(transcoder avformat avcodec avutil)
|
||||||
target_link_libraries(transcoder m pthread)
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(transcoder wsock32 ws2_32)
|
target_link_libraries(transcoder wsock32 ws2_32)
|
||||||
target_link_libraries(transcoder Secur32 Secur32)
|
target_link_libraries(transcoder Secur32 Secur32)
|
||||||
target_link_libraries(transcoder Bcrypt Bcrypt)
|
target_link_libraries(transcoder Bcrypt Bcrypt)
|
||||||
|
else()
|
||||||
|
target_link_libraries(transcoder m pthread)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
A C library using FFMPEG (libav) to process videos files for kyoo.
|
A C library using FFMPEG (libav) to process videos files for kyoo.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Return streams informations (language, title, codec, arrengements)
|
- Return streams informations (language, title, codec, arrangement)
|
||||||
- Extract subtitles, fonts & chapters to an external file
|
- Extract subtitles, fonts & chapters to an external file
|
||||||
- Transmux to hls (TODO support multi-audio)
|
- Transmux to hls (TODO support multi-audio)
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,20 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(WIN32)
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
#define kmkdir(dir, mode) mkdir(dir)
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
char *strndup(const char *str, size_t count);
|
char *strndup(const char *str, size_t count);
|
||||||
|
int asprintf(char **buffer, const char *fmt, ...);
|
||||||
|
int vasprintf(char **buffer, const char *fmt, va_list args);
|
||||||
|
|
||||||
|
#define kmkdir(dir, mode) mkdir(dir)
|
||||||
|
#define S_ISDIR(x) (x & S_IFDIR)
|
||||||
#else
|
#else
|
||||||
#define kmkdir(dir, mode) mkdir(dir, mode)
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define kmkdir(dir, mode) mkdir(dir, mode)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "compatibility.h"
|
#include "compatibility.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(WIN32)
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
char *strndup(const char *str, size_t count)
|
char *strndup(const char *str, size_t count)
|
||||||
@@ -18,4 +19,32 @@ char *strndup(const char *str, size_t count)
|
|||||||
memcpy(ret, str, len);
|
memcpy(ret, str, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int asprintf(char **buffer, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
ret = vasprintf(buffer, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vasprintf(char **buffer, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
|
va_list copy;
|
||||||
|
char *ret;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
va_copy(copy, args);
|
||||||
|
len = vsprintf(NULL, fmt, args);
|
||||||
|
va_end(copy);
|
||||||
|
|
||||||
|
*buffer = malloc(sizeof(char) * (len + 1));
|
||||||
|
if (!*buffer)
|
||||||
|
return 0;
|
||||||
|
vsprintf(*buffer, fmt, args);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -132,7 +132,7 @@ void extract_chapters(AVFormatContext *ctx, const char *out_path)
|
|||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
strcat(path, ".txt");
|
strcat(path, ".txt");
|
||||||
|
|
||||||
int fd = open(path, O_WRONLY | O_CREAT, 0644);
|
FILE *file = fopen(path, "w");
|
||||||
|
|
||||||
for (unsigned i = 0; i < ctx->nb_chapters; i++) {
|
for (unsigned i = 0; i < ctx->nb_chapters; i++) {
|
||||||
AVDictionaryEntry *name = av_dict_get(ctx->chapters[i]->metadata, "title", NULL, 0);
|
AVDictionaryEntry *name = av_dict_get(ctx->chapters[i]->metadata, "title", NULL, 0);
|
||||||
@@ -143,8 +143,8 @@ void extract_chapters(AVFormatContext *ctx, const char *out_path)
|
|||||||
continue;
|
continue;
|
||||||
double start = chapter->start * av_q2d(chapter->time_base);
|
double start = chapter->start * av_q2d(chapter->time_base);
|
||||||
double end = chapter->end * av_q2d(chapter->time_base);
|
double end = chapter->end * av_q2d(chapter->time_base);
|
||||||
dprintf(fd, "%f %f %s\n", start, end, name->value);
|
fprintf(file, "%f %f %s\n", start, end, name->value);
|
||||||
}
|
}
|
||||||
close(fd);
|
fclose(file);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user