Hallo

> Some days ago, I was posting the following message to the list. Apparently, I
> did not receive any reply. Beg your pardon for my impatience. But can
> somebody help?
Some things take more time. 

I have attached a little patch. Now lav2wav will happly create "sound of
silence"
If the file does not have a valid audio file it creates a 44.1kHz 16Bit
Stereo silence (00000000 hex). At least it worked for me. 

I'm a bit unsoure if the value is correct with only zeros. 

If it works, I'll commit it to the CVS, but I think it will be a
optional feature. You can enable it with a command line option to create
silence instead of stopping. 


auf hoffentlich bald,

Berni the Chaos of Woodquarter

Email: [EMAIL PROTECTED]
www: http://www.lysator.liu.se/~gz/bernhard
--- lav2wav.c.orig      2003-10-09 17:03:21.269003184 +0200
+++ mjpeg_play/lavtools/lav2wav.c       2003-10-09 18:08:25.543463248 +0200
@@ -163,7 +163,7 @@
 int     argc;
 char    **argv;
 {
-       int n,f;
+       int n,f,i;
        int res;
        int warned = 0;
        int start_frame = 0;
@@ -207,44 +207,15 @@
 
     if(!el.has_audio)
     {
-        mjpeg_error("Input file(s) have no audio");
-        exit(1);
-    }
-
-    if(!ignore_bitrate) 
-      {
-        if(el.audio_bits!=16)
-          {
-            mjpeg_error("Input file(s) must have 16 bit audio!");
-            exit(1);
-          }
-        
-        switch (el.audio_rate) {
-        case 48000 : 
-        case 44100 :
-        case 32000 :
-          break;
-        default:
-          mjpeg_error("Audio rate is %ld Hz",el.audio_rate);
-          mjpeg_error("Audio rate must be 32000, 44100 or 48000 !");
-          exit(1);
-        }
-      }
+        /* old version */
+        /*mjpeg_error("Input file(s) have no audio"); */
+        /*exit(1);   */
 
-    switch (el.audio_chans) {
-    case 1:
-    case 2:
-      break;
-      
-    default:
-      mjpeg_error("Audio channels %d not allowed",el.audio_chans);
-      exit(1);
-    }
- 
        /* Create wav header (skeleton) on stdout ... */
-       wav_header( el.audio_bits, el.audio_rate, el.audio_chans, 1);
+        /* audio_bits, audio_rate, audio_chans */
+       wav_header( 16, 44100, 2, 1);
        /* skip to the start frame if specified */
-       f = 0;
+        f = 0;
        if (start_frame != 0)
                f = start_frame;
        /* num_frames = -1, read em all, else read specified # */
@@ -254,30 +225,81 @@
        /* Stream out audio wav-style... in per-frame chunks */
        for( ; f < num_frames; ++f )
        {
-               n = el_get_audio_data(audio_buff, f, &el, 0);
-               if( n < 0 )
-               {
-                       mjpeg_error_exit1( "%s: Couldn't get audio for frame %d!", 
argv[0], f );
-               }
-               if( n != 0 )
-               {
-                       res = do_write( 1, audio_buff, n );
-                       if( res != n )
-                       {
-                               mjpeg_error_exit1( "%s: Couldn't write audio for frame 
%d!", argv[0], f );
-                               exit(1);
-                       }
-               }
-
-               else if( f < num_frames && ! warned )
-               {
-                       mjpeg_warn( "%s: audio ends early at frame %d", argv[0], f );
-                       warned = 1;
-               }
+        for ( i = 0; i < 1764; i++) 
+               res = do_write (1, "\x0000000", 4);
+       }
+
+    wav_close(1);
+    exit(0);
+    }
+
+    if (!ignore_bitrate) 
+      {
+        if(el.audio_bits!=16)
+          {
+                 mjpeg_error("Input file(s) must have 16 bit audio!");
+                 exit(1);
+         }
+
+       switch (el.audio_rate) {
+               case 48000 : 
+               case 44100 :
+               case 32000 :
+                       break;
+               default:
+                       mjpeg_error("Audio rate is %ld Hz",el.audio_rate);
+                       mjpeg_error("Audio rate must be 32000, 44100 or 48000 !");
+                       exit(1);
        }
+      }
+
+    switch (el.audio_chans) {
+           case 1:
+           case 2:
+                   break;
+
+           default:
+                   mjpeg_error("Audio channels %d not allowed",el.audio_chans);
+                   exit(1);
+    }
+
+    /* Create wav header (skeleton) on stdout ... */
+    wav_header( el.audio_bits, el.audio_rate, el.audio_chans, 1);
+    /* skip to the start frame if specified */
+    f = 0;
+    if (start_frame != 0)
+           f = start_frame;
+    /* num_frames = -1, read em all, else read specified # */
+    if ( num_frames == -1)
+           num_frames = el.video_frames;
+
+    /* Stream out audio wav-style... in per-frame chunks */
+    for( ; f < num_frames; ++f )
+    {
+           n = el_get_audio_data(audio_buff, f, &el, 0);
+           if( n < 0 )
+           {
+                   mjpeg_error_exit1( "%s: Couldn't get audio for frame %d!", 
argv[0], f );
+           }
+           if( n != 0 )
+           {
+                   res = do_write( 1, audio_buff, n );
+                   if( res != n )
+                   {
+                           mjpeg_error_exit1( "%s: Couldn't write audio for frame 
%d!", argv[0], f );
+                           exit(1);
+                   }
+           }
+
+           else if( f < num_frames && ! warned )
+           {
+                   mjpeg_warn( "%s: audio ends early at frame %d", argv[0], f );
+                   warned = 1;
+           }
+    }
 
-       wav_close(1);
-       exit(0);
+    wav_close(1);
+    exit(0);
 }
 
 

Reply via email to