+static int change_output_resolution(int stream_index,int width,int height,int fps,char interlace[1024],char error_msg[1024])
{
OutputStream* ost = NULL;
char filter_cmd[1024]={0};
@@ -6131,6 +6130,35 @@ static int change_output_resolution(int stream_index,int width,int height,char e
ost->enc_ctx->coded_width = width;
ost->enc_ctx->coded_height = height;
}
+
+ if(strcmp(interlace,"enable") == 0) //隔行编码
+ {
+ ost->enc_ctx->flags = ost->enc_ctx->flags | AV_CODEC_FLAG_INTERLACED_ME;
+ ost->enc_ctx->flags = ost->enc_ctx->flags | AV_CODEC_FLAG_INTERLACED_DCT;
+ av_log(NULL,AV_LOG_FATAL,"video interlace set enable");
+ }
+ /*if(strcmp(interlace,"disable") == 0) //逐行编码
+ {
+ ost->enc_ctx->flags = (ost->enc_ctx->flags&(~AV_CODEC_FLAG_INTERLACED_ME));
+ ost->enc_ctx->flags = (ost->enc_ctx->flags&(~AV_CODEC_FLAG_INTERLACED_DCT));
+ //ost->enc_ctx->flags = 0;
+ int flags1 = ost->enc_ctx->flags & AV_CODEC_FLAG_INTERLACED_ME;
+ int flags2 = ost->enc_ctx->flags & AV_CODEC_FLAG_INTERLACED_DCT;
+ av_log(NULL,AV_LOG_FATAL,"video interlace set disable,flags1=%d flags2=%d\n",flags1,flags2);
+ }
+ */
+
+
+ /*if(fps != UNKNOW_VALUES)
+ {
+ ost->enc_ctx->framerate = (AVRational){fps,1};
+ ost->enc_ctx->time_base = (AVRational) { 1, fps };
+ av_log(NULL,AV_LOG_FATAL,"lvyunxiang test framerate=%d\n",ost->enc_ctx->framerate);
+ ost->frame_rate = (AVRational){fps,1};
+ }
+ */
+
+
if(codec_id == AV_CODEC_ID_H264)
{
@@ -6521,11 +6549,14 @@ static int cmd_modify(struct cli_def *cli, char *command, char *argv[], int argc
{
char rc_method[1024] = {0};
memset(rc_method,0,1024);
+ char interlace[1024] = {0};
+ memset(interlace,0,1024);
int bitrate = UNKNOW_VALUES;
int maxrate = UNKNOW_VALUES;
int minrate = UNKNOW_VALUES;
int width = UNKNOW_VALUES;
int height = UNKNOW_VALUES;
+ int fps = UNKNOW_VALUES;
int bf = UNKNOW_VALUES;
int stream_index = UNKNOW_VALUES;
char error_msg[1024]={0};
@@ -6570,9 +6601,17 @@ static int cmd_modify(struct cli_def *cli, char *command, char *argv[], int argc
{
int stream_index = UNKNOW_VALUES;
char error_msg[1024]={0};
@@ -6570,9 +6601,17 @@ static int cmd_modify(struct cli_def *cli, char *command, char *argv[], int argc
{
stream_index = atoi(argv[++i]);
}
+ if(strcmp(argv[i],"interlace") == 0)
+ {
+ strcpy(interlace,argv[++i]);
+ }
+ if(strcmp(argv[i],"fps") == 0)
+ {
+ fps = atoi(argv[++i]);
+ }
}
- av_log(NULL, AV_LOG_FATAL, "stream_index:%d rc_method:%s bitrate:%d maxrate:%d minrate:%d bf:%d width:%d height:%d\n",
- stream_index,rc_method,bitrate,maxrate,minrate,bf,width,height);
+ av_log(NULL, AV_LOG_FATAL, "stream_index:%d rc_method:%s bitrate:%d maxrate:%d minrate:%d bf:%d width:%d height:%d fps:%d interlace:%s\n",
+ stream_index,rc_method,bitrate,maxrate,minrate,bf,width,height,fps,interlace);
if(strlen(rc_method) > 0 || bitrate != UNKNOW_VALUES || maxrate != UNKNOW_VALUES || minrate != UNKNOW_VALUES || bf != UNKNOW_VALUES)
{
int ret = change_encoder_parm(stream_index,rc_method,bitrate,maxrate,minrate,bf,error_msg);
@@ -6582,9 +6621,9 @@ static int cmd_modify(struct cli_def *cli, char *command, char *argv[], int argc
return 0;
}
}
- if(width != UNKNOW_VALUES && height != UNKNOW_VALUES)
+ if(width != UNKNOW_VALUES && height != UNKNOW_VALUES )
{
- int ret = change_output_resolution(stream_index,width,height,error_msg);
+ int ret = change_output_resolution(stream_index,width,height,fps,interlace,error_msg);
if(ret != 0)
{
cli_print(cli,error_msg);
@@ -7146,7 +7185,7 @@ static int recreate_argv(int argc, char **argv, int *new_argc, char ***new_argv)
/* delete the config file */
close(fd);
- unlink(argv[1]);
+ //unlink(argv[1]);
}
return 0;