[xiph-commits] r16660 - trunk/ffmpeg2theora/src

j at svn.xiph.org j at svn.xiph.org
Wed Oct 28 10:06:05 PDT 2009


Author: j
Date: 2009-10-28 10:06:05 -0700 (Wed, 28 Oct 2009)
New Revision: 16660

Modified:
   trunk/ffmpeg2theora/src/avinfo.c
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
   trunk/ffmpeg2theora/src/theorautils.c
Log:
also print oshash/size/path in frontend and --info view for files that can not be decoded.

Modified: trunk/ffmpeg2theora/src/avinfo.c
===================================================================
--- trunk/ffmpeg2theora/src/avinfo.c	2009-10-27 22:04:20 UTC (rev 16659)
+++ trunk/ffmpeg2theora/src/avinfo.c	2009-10-28 17:06:05 UTC (rev 16660)
@@ -402,49 +402,53 @@
     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");
+        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);
-         }
+        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 {
-        for(i=0;i<ic->nb_streams;i++) {
-            json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_AUDIO);
-        }
+        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);
 

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-10-27 22:04:20 UTC (rev 16659)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-10-28 17:06:05 UTC (rev 16660)
@@ -2142,7 +2142,7 @@
                             break;
                         case NOOSHASH_FLAG:
                             convert->disable_oshash = 1;
-                            sprintf(info.oshash,"0");
+                            sprintf(info.oshash,"0000000000000000");
                             flag = -1;
                             break;
                         case NOUPSCALING_FLAG:
@@ -2610,25 +2610,25 @@
                 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
 

Modified: trunk/ffmpeg2theora/src/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.c	2009-10-27 22:04:20 UTC (rev 16659)
+++ trunk/ffmpeg2theora/src/theorautils.c	2009-10-28 17:06:05 UTC (rev 16660)
@@ -256,7 +256,7 @@
 
     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);
     }



More information about the commits mailing list