Bonjour,
Je bosse (loisir pour moi) sur l'intégration du codec vidéo Lagarith dans l’enregistreur vidéo intégré de DCS (simu de vol) pour obtenir directement une vidéo format avi lossless avec audio WAV en sortie. C'est un enregistreur images par images, donc l'avantage, on ouvre le fichier .trk, on enregistre sans perte de performances ou qualité. Bref.
C'est mon premier projet en C++, je suis débutant en prog donc d'avance, excusez moi pour ma certaine ignorance Le but, c'est de créer un plugin lagarith.dll, je sais comment l'intégrer au jeu par ailleurs, le souci, c'est que je ne connais pas grand chose à l'encodage vidéo et je ne sais pas quel type de données insérer dans mon code source.
Je pense aussi que j'ai beaucoup d'incohérence dans mes déclarations.
Bonne nouvelle, je ne pars pas de rien, j'utilise le canevas du SDK de ED. Par ailleurs, je devrais certainement faire une version 32 bits, mais c'est quoi la différence en terme de code avec le 64bits?
Je demande donc votre expertise pour mener mon projet à terme, et continuer mon apprentissage!
Merci d'avance pour votre aide. Bonnes fêtes de fin d'année.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 //Voila mon header #ifndef _lagarith_h_ #define _lagarith_h_ #ifdef __cplusplus extern "C" { #endif /** * Encoding parameters. */ struct lagarith_params { /** * Video width in pixels. */ int 720; /** * Video height in pixels. * Negative value means bottom-to-top image. * In DCS it is always negative. */ int -1280; /** * Video frames per second. */ int 30; /** * Video quality [0, 1.0], where 1.0 means best. */ float 1.0; /** * Audio sample rate in Hz. */ int 320; /** * Number of audio channels (2 for stereo). */ int 2; }; #ifndef _lagarith_h_ typedef struct lagarith_h lagarith_t; #endif /** * Encoder description. */ struct lagarith_info { /** * Encoder name. */ const char *lagarith; /** * Init encoder. * @param file_prefix output filename (utf-8) with or w/o extension depending on record_avi.lua setting * @param params encoding settings * @param format custom format string from record_avi.lua * @return pointer to private data or NULL on error */ lagarith_t* (*start)(const char *test, const struct lagarith_params *params, const char *avi); /** * Encode video frame. * @param self private encoder data * @param frame pointer to BGR DIB data * @param stride length of pixel row in bytes (usually 3*width, constant during encoding) * @retval 1 ok * @retval 0 unrecoverable error */ int (*video)(lagarith_t *self, const unsigned char *frame, unsigned int 3*width); /** * Encode audio frames. * @param self private encoder data * @param buffer pointer to audio samples (interleaved). * @param nframes number of audio frames in the buffer (a frame contains 1 sample for every channel). * @retval 1 ok * @retval 0 unrecoverable error * * @note: Audio samples values are in range [-1.0, 1.0] */ int (*audio)(lagarith_t *self, const float *buffer, unsigned nframes); /** * Finish encoding and release private data. * @param self private encoder data */ void (*finish)(lagarith_t *self); }; /** * Type of function to export from encoder's DLL. * The actual function name is a user-defined option. */ typedef struct lagarith_info* (*lagarith_get)(); #ifdef __cplusplus } // extern "C" #endif #endif /* _lagarith_h_ */PS: Désolé pour la longueur de code, j'ai hésité à attacher le code en pièces jointes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 //Voila mon code source #define LAGARITH_PRIVATE typedef struct test_data lagarith_t; #include "Lagarith.h" // this is your private area #include <windows.h> #include <stdio.h> #include <stdlib.h> struct test_data { // here you will keep your private data FILE *out; unsigned video_frames; unsigned audio_frames; }; static lagarith_t* test_start(const char *output, const struct lagarith_params *params, const char *format) { char outname[MAX_PATH]; wchar_t woutname[MAX_PATH]; _snprintf(outname, sizeof(outname), "%s.txt", output); if (!MultiByteToWideChar(CP_UTF8, 0, outname, -1, woutname, sizeof(woutname)/sizeof(woutname[0]))) return 0; struct test_data *self = (struct test_data*) calloc(1, sizeof(*self)); if (!self) return 0; self->out = _wfopen(woutname, L"wb"); if (!self->out) { free (self); return 0; } self->video_frames = 0; self->audio_frames = 0; fprintf(self->out, "Started with:\n"); fprintf(self->out, "output = \"%s\"\n", output); fprintf(self->out, "width = %d, height = %d, framerate = %d, quality = %f\n", params->width, params->height, params->framerate, params->quality); fprintf(self->out, "samplerate = %d, nchannels = %d\n", params->samplerate, params->nchannels); fprintf(self->out, "format = \"%s\".\n", format); MessageBoxA(NULL, "Started!", "Test Encoder", MB_OK); return self; } int test_video(lagarith_t *self, const unsigned char *bgra_dib, unsigned int stride) { self->video_frames += 1; fprintf(self->out, "video: stride = %d, frames done: %d\n", stride, self->video_frames); return 1; } int test_audio(lagarith_t *self, const float *buffer, unsigned nframes) { self->audio_frames += nframes; fprintf(self->out, "audio: nframes = %d, frames done: %d\n", nframes, self->audio_frames); return 1; } static void test_stop(lagarith_t *self) { if (self) { fprintf(self->out, "Stopped.\n"); fclose(self->out); free(self); } } // public part: static struct lagarith_info test_info = { "Test encoder", test_start, test_video, test_audio, test_stop }; extern "C" __declspec(dllexport) struct lagarith_info* ed_test_lagarith() { return &test_info; }
J'ai beaucoup appris à travers les cours C++ mais je ne trouve aucun cas similaire :/
Partager