mirror of
https://github.com/zoriya/Kyoo.Transcoder.git
synced 2025-12-05 22:16: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)
|
||||
|
||||
target_link_libraries(transcoder avformat avcodec avutil)
|
||||
target_link_libraries(transcoder m pthread)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(transcoder wsock32 ws2_32)
|
||||
target_link_libraries(transcoder Secur32 Secur32)
|
||||
target_link_libraries(transcoder Bcrypt Bcrypt)
|
||||
else()
|
||||
target_link_libraries(transcoder m pthread)
|
||||
endif()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
A C library using FFMPEG (libav) to process videos files for kyoo.
|
||||
|
||||
## Features
|
||||
- Return streams informations (language, title, codec, arrengements)
|
||||
- Return streams informations (language, title, codec, arrangement)
|
||||
- Extract subtitles, fonts & chapters to an external file
|
||||
- Transmux to hls (TODO support multi-audio)
|
||||
|
||||
|
||||
@@ -8,13 +8,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#define kmkdir(dir, mode) mkdir(dir)
|
||||
#include <io.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
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
|
||||
#define kmkdir(dir, mode) mkdir(dir, mode)
|
||||
#include <unistd.h>
|
||||
|
||||
#define kmkdir(dir, mode) mkdir(dir, mode)
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "compatibility.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
char *strndup(const char *str, size_t count)
|
||||
@@ -18,4 +19,32 @@ char *strndup(const char *str, size_t count)
|
||||
memcpy(ret, str, len);
|
||||
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
|
||||
@@ -132,7 +132,7 @@ void extract_chapters(AVFormatContext *ctx, const char *out_path)
|
||||
*tmp = '\0';
|
||||
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++) {
|
||||
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;
|
||||
double start = chapter->start * 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);
|
||||
}
|
||||
Reference in New Issue
Block a user