Commit d20cba65 authored by Jan Gerber's avatar Jan Gerber
Browse files

also print oshash/size/path in frontend and --info view for files that can not be decoded.

parent b51a6001
......@@ -402,49 +402,53 @@ void json_format_info(FILE* output, AVFormatContext *ic, const char *url) {
unsigned long long filesize;
fprintf(output, "{\n");
if (ic->duration != AV_NOPTS_VALUE) {
float secs;
secs = (float)ic->duration / AV_TIME_BASE;
json_add_key_value(output, "duration", &secs, JSON_FLOAT, 0, 1);
} else {
float t = -1;
json_add_key_value(output, "duration", &t, JSON_FLOAT, 0, 1);
}
if (ic->bit_rate) {
float t = (float)ic->bit_rate / 1000;
json_add_key_value(output, "bitrate", &t, JSON_FLOAT, 0, 1);
}
if(ic) {
if (ic->duration != AV_NOPTS_VALUE) {
float secs;
secs = (float)ic->duration / AV_TIME_BASE;
json_add_key_value(output, "duration", &secs, JSON_FLOAT, 0, 1);
} else {
float t = -1;
json_add_key_value(output, "duration", &t, JSON_FLOAT, 0, 1);
}
if (ic->bit_rate) {
float t = (float)ic->bit_rate / 1000;
json_add_key_value(output, "bitrate", &t, JSON_FLOAT, 0, 1);
}
do_indent(output, 1);
fprintf(output, "\"video\": [");
if(ic->nb_programs) {
int j, k;
for(j=0; j<ic->nb_programs; j++) {
for(k=0; k<ic->programs[j]->nb_stream_indexes; k++)
json_stream_format(output, ic, ic->programs[j]->stream_index[k], 2, !k && !j, CODEC_TYPE_VIDEO);
}
} else {
for(i=0;i<ic->nb_streams;i++) {
json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_VIDEO);
do_indent(output, 1);
fprintf(output, "\"video\": [");
if(ic->nb_programs) {
int j, k;
for(j=0; j<ic->nb_programs; j++) {
for(k=0; k<ic->programs[j]->nb_stream_indexes; k++)
json_stream_format(output, ic, ic->programs[j]->stream_index[k], 2, !k && !j, CODEC_TYPE_VIDEO);
}
} else {
for(i=0;i<ic->nb_streams;i++) {
json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_VIDEO);
}
}
}
fprintf(output, "],\n");
do_indent(output, 1);
fprintf(output, "\"audio\": [");
if(ic->nb_programs) {
int j, k;
for(j=0; j<ic->nb_programs; j++) {
for(k=0; k<ic->programs[j]->nb_stream_indexes; k++)
json_stream_format(output, ic, ic->programs[j]->stream_index[k], 2, !k && !j, CODEC_TYPE_AUDIO);
}
} else {
for(i=0;i<ic->nb_streams;i++) {
json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_AUDIO);
fprintf(output, "],\n");
do_indent(output, 1);
fprintf(output, "\"audio\": [");
if(ic->nb_programs) {
int j, k;
for(j=0; j<ic->nb_programs; j++) {
for(k=0; k<ic->programs[j]->nb_stream_indexes; k++)
json_stream_format(output, ic, ic->programs[j]->stream_index[k], 2, !k && !j, CODEC_TYPE_AUDIO);
}
} else {
for(i=0;i<ic->nb_streams;i++) {
json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_AUDIO);
}
}
fprintf(output, "],\n");
} else {
json_add_key_value(output, "code", "badfile", JSON_STRING, 0, 1);
json_add_key_value(output, "error", "file does not exist or has unknown format.", JSON_STRING, 0, 1);
}
fprintf(output, "],\n");
json_oshash(output, url, 1);
json_add_key_value(output, "path", (void *)url, JSON_STRING, 0, 1);
......
......@@ -2142,7 +2142,7 @@ int main(int argc, char **argv) {
break;
case NOOSHASH_FLAG:
convert->disable_oshash = 1;
sprintf(info.oshash,"0");
sprintf(info.oshash,"0000000000000000");
flag = -1;
break;
case NOUPSCALING_FLAG:
......@@ -2610,24 +2610,24 @@ int main(int argc, char **argv) {
ff2theora_output(convert);
}
else{
if (info.frontend)
fprintf(info.frontend, "{\"code\": \"badfile\", \"error\":\"input format not supported.\"}\n");
else if (output_json)
fprintf(stdout, "{\"code\": \"badfile\", \"error\":\"input format not supported.\"}\n");
else
fprintf(stderr,"\nUnable to decode input.\n");
return(1);
}
av_close_input_file(convert->context);
}
else{
if (info.frontend)
fprintf(info.frontend, "{\"code\": \"badfile\", \"error\":\"file does not exist or has unknown data format.\"}\n");
json_format_info(info.frontend, NULL, inputfile_name);
else if (output_json)
fprintf(stdout, "{\"code\": \"badfile\", \"error\":\"file does not exist or has unknown data format.\"}\n");
json_format_info(stdout, NULL, inputfile_name);
else
fprintf(stderr, "\nFile `%s' does not exist or has an unknown data format.\n", inputfile_name);
fprintf(stderr,"\nUnable to decode input.\n");
return(1);
}
av_close_input_file(convert->context);
}
else{
if (info.frontend)
json_format_info(info.frontend, NULL, inputfile_name);
else if (output_json)
json_format_info(stdout, NULL, inputfile_name);
else
fprintf(stderr, "\nFile `%s' does not exist or has an unknown format.\n", inputfile_name);
return(1);
}
ff2theora_close(convert);
} // 2pass loop
......
......@@ -256,7 +256,7 @@ void oggmux_init (oggmux_info *info) {
th_comment_add_tag(&info->tc, "ENCODER", PACKAGE_STRING);
vorbis_comment_add_tag(&info->vc, "ENCODER", PACKAGE_STRING);
if (strcmp(info->oshash, "0") > 0) {
if (strcmp(info->oshash, "0000000000000000") > 0) {
th_comment_add_tag(&info->tc, "SOURCE_OSHASH", info->oshash);
vorbis_comment_add_tag(&info->vc, "SOURCE_OSHASH", info->oshash);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment