MCPcopy Create free account
hub / github.com/TASEmulators/fceux / initVideoStream

Function initVideoStream

src/drivers/Qt/AviRecord.cpp:1095–1290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1093}
1094
1095static int initVideoStream( const char *codec_name, OutputStream *ost )
1096{
1097 int ret;
1098 const AVCodec *codec;
1099 AVCodecContext *c;
1100 double fps;
1101 int fps1000;
1102 unsigned int usec;
1103
1104 fps = getBaseFrameRate();
1105
1106 usec = (unsigned int)((1.0e6 / fps)+0.50);
1107
1108 fps1000 = (int)(fps * 1000.0);
1109
1110 /* find the video encoder */
1111 codec = avcodec_find_encoder_by_name(codec_name);
1112
1113 if (codec == NULL)
1114 {
1115 fprintf( avLogFp, "Video codec not found: %s\n", codec_name);
1116 return -1;
1117 }
1118 //printf("CODEC: %s\n", codec->name );
1119
1120 ost->st = avformat_new_stream(oc, NULL);
1121
1122 if (ost->st == NULL)
1123 {
1124 fprintf( avLogFp, "Error: Could not alloc video stream\n");
1125 return -1;
1126 }
1127
1128 c = avcodec_alloc_context3(codec);
1129
1130 if (c == NULL)
1131 {
1132 fprintf( avLogFp, "Error: Could not alloc an video encoding context\n");
1133 return -1;
1134 }
1135 /* Put sample parameters. */
1136 c->bit_rate = 400000;
1137 c->gop_size = 12; /* emit one intra frame every twelve frames at most */
1138
1139 loadCodecConfig( 0, codec_name, c );
1140
1141 ost->enc = c;
1142
1143 //av_opt_show2( (void*)c, NULL, AV_OPT_FLAG_VIDEO_PARAM, 0 );
1144
1145 /* Resolution must be a multiple of two. */
1146 c->width = nes_shm->video.ncol;
1147 c->height = nes_shm->video.nrow;
1148
1149 /* timebase: This is the fundamental unit of time (in seconds) in terms
1150 * of which frame timestamps are represented. For fixed-fps content,
1151 * timebase should be 1/framerate and timestamp increments should be
1152 * identical to 1. */

Callers 1

initMediaFunction · 0.85

Calls 3

getBaseFrameRateFunction · 0.85
loadCodecConfigFunction · 0.85
alloc_pictureFunction · 0.85

Tested by

no test coverage detected