-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathencode.cpp
More file actions
51 lines (49 loc) · 1.54 KB
/
Copy pathencode.cpp
File metadata and controls
51 lines (49 loc) · 1.54 KB
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
#include "source.h"
#include "decoder.h"
#include "encoder.h"
#include "stdio.h"
#ifndef TEST_RTMP_URL
#define TEST_RTMP_URL "rtmp://58.200.131.2:1935/livetv/hunantv"
#endif
int main(int argc, char** argv){
videoSourceHandle videoSource = videoSource_init( (char*)TEST_RTMP_URL, 0);
// videoSourceHandle videoSource = videoSource_init((char*)"rtmp://10.10.1.108:8981/app/video/001", 1);
AVPacket packet;
int width, height, size;
cudaVideoSurfaceFormat format;
videoDecoderHandle videoDecode = videoDecoder_init(AV_CODEC_ID_H264);
videoEncoderHandle videoEncode = NULL;
videoFrameList* frameList;
videoEncodedBuffer* buffer;
#ifdef DEBUG
FILE* fp = fopen("/tmp/encode.h264", "wb");
#endif
while(1){
if(videoSource_read(videoSource, &packet)<0){
break;
}
frameList = videoDecoder_decode(videoDecode, packet.data, packet.size);
if(frameList==NULL){
continue;
}
if(videoEncode==NULL){
videoEncode = videoEncoder_init(frameList->width, frameList->height);
}
buffer = videoEncoder_encode(videoEncode, frameList->pFrames);
videoFrameList_destory(&frameList);
if(buffer == NULL){
continue;
}
printf("Encode Buffer size: %d\n", buffer->size);
#ifdef DEBUG
fwrite(buffer->data, 1, buffer->size, fp);
#endif
videoEncodedBuffer_destory(&buffer);
}
#ifdef DEBUG
fclose(fp);
#endif
videoDecoder_destroy(videoDecode);
videoEncoder_destroy(videoEncode);
return 0;
}