<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 22.06.2015 08:14, Petter Reinholdtsen wrote:<br>
    <blockquote cite="mid:2flvbeggthb.fsf@diskless.uio.no" type="cite">
      <pre wrap="">[Peter Belkner]
</pre>
      <blockquote type="cite">
        <pre wrap="">I've made an educated guess on how to continue: simply skip the
package, and it seems to work smoothly:
</pre>
      </blockquote>
      <pre wrap="">
How did you test?</pre>
    </blockquote>
    <br>
    I was testing with Winamp and the FFmpeg based "in_ffsox" input
    plugin. It was not "stuttering" at all. I discovered "stuttering"
    only when testing with VLC player.<br>
    <br>
    Meanwhile I've learned that we have two issues:<br>
    <ol>
      <li>"20030213-cvs.mpeg" had not processed at all (i.e. just
        loudness analysis was aborting with an error and hence it could
        not have "stuttered")</li>
      <li>"DavidGallo_2007.dv" stutters.</li>
    </ol>
    <p>The (previous) patch solves the first issue. The idea is to throw
      away packages FFmpeg cannot deal with.<br>
    </p>
    <p>After having solved the first issue, "20030213-cvs.mpeg" will
      also "stutter". For solving "stuttering" I know have a really
      "educated" guess based on the observation that in almost all cases
      the duration of processed video files will be double the original
      length. A further observation is that the time stamps produced
      differ by the factor 2 between the video and the audio stream. </p>
    <p>The following patch solves "stuttering" (but really is some kind
      of a "sledgehammer")</p>
    <blockquote>
      <pre>diff -rc ./bs1770gain-0.4.4-beta2/libffsox-2/ffsox_frame_writer.c ./bs1770gain-0.4.4-beta3/libffsox-2/ffsox_frame_writer.c
*** ./bs1770gain-0.4.4-beta2/libffsox-2/ffsox_frame_writer.c    2015-06-14 18:11:19.000000000 +0200
--- ./bs1770gain-0.4.4-beta3/libffsox-2/ffsox_frame_writer.c    2015-06-22 09:12:36.000000000 +0200
***************
*** 145,150 ****
--- 145,154 ----
  
    if (0!=*got_packet) {
      av_packet_rescale_ts(pkt,cc->time_base,st->time_base);
+     // where do the "magic" factor 0.5 come from?
+     pkt->dts>>=1;
+     pkt->pts>>=1;
+     pkt->duration>>=1;
  
      if (ffsox_stream_interleaved_write(so,pkt)<0) {
        DMESSAGE("writing packet");</pre>
    </blockquote>
    <p>Maybe Carl Eugen can provide some insight into how to align the
      time scales between streams.<br>
    </p>
    <br>
    <blockquote cite="mid:2flvbeggthb.fsf@diskless.uio.no" type="cite">
      <pre wrap="">

I applied the enclosed patch (notice the DMESSAGE) to see how often it
trigger, and processed the MPEG file, and the sound was still
stuttering.  This was the output when running bs1770gain:

% ./bs1770gain/bs1770gain 20030213-cvs.mpeg -a -o foo
analyzing ...
  [1/1] "20030213-cvs.mpeg": 7%Error decoding audio, skipping audio package: frame_reader_run(), "ffsox_frame_reader.c" (148).
        
      integrated:  -34.7 LUFS / 11.7 LU
transcoding ...
  [1/1] "20030213-cvs.mkv" 7%Error decoding audio, skipping audio package: frame_reader_run(), "ffsox_frame_reader.c" (148).
    
done.
%

--- bs1770gain-0.4.3.orig/libffsox-2/ffsox_frame_reader.c
+++ bs1770gain-0.4.3/libffsox-2/ffsox_frame_reader.c
@@ -145,8 +145,10 @@ static int frame_reader_run(frame_reader
       }
 
       if ((size=avcodec_decode_audio4(cc,frame,&got_frame,pkt))<0) {
-        DMESSAGE("decoding audio");
-        return -1;
+        DMESSAGE("decoding audio, skipping audio package");
+        // skip the package.
+        pkt->size=0;
+        return 0;
       }
 
       pkt->size-=size;

</pre>
    </blockquote>
    <br>
  </body>
</html>