[MPlayer-dev-eng] Re: -of mpeg

Andriy N. Gritsenko andrej at lucky.net
Fri Oct 10 05:20:49 CEST 2003


    Hi, MAL!

Sometime (on Thursday, September 25 at 12:42) I've received something...
>Just a quickie...
>
>Can someone explain why when I do:
>
>mencoder -of mpeg -ovc copy -oac copy input.mpg -o output.mpg
>
>where input.mpg is MPEG2 video/audio at SVCD spec, does it state:
>
>"Writing AVI header..."
>"Writing AVI index..."
>and:
>"Fixing AVI header..."
>
>Surely if i'm wanting an MPEG output, (-of mpeg), it should get an MPEG 
>header?

    It comes from help_mp-*.h so I cannot do anything with it.

>As it stands, not only can I not play the file in a windows player, (the 
>original plays fine), but I also lose the audio stream, (even mplayer 
>reports no audio stream).
[.......]

    Silly me... I didn't find it earlier but it was my bug. Sorry. Patch
is attached so you could fix it right now. It must work fine.

    With best wishes.
    Andriy.
-------------- next part --------------
diff -udprP MPlayer-0.92.orig/libmpdemux/muxer_mpeg.c MPlayer-0.92/libmpdemux/muxer_mpeg.c
--- MPlayer-0.92.orig/libmpdemux/muxer_mpeg.c	Sun Jan 19 02:33:11 2003
+++ MPlayer-0.92/libmpdemux/muxer_mpeg.c	Fri Oct 10 06:09:20 2003
@@ -6,6 +6,7 @@
 
 #include "config.h"
 #include "../version.h"
+#include "../mp_msg.h"
 
 #include "wine/mmreg.h"
 #include "wine/avifmt.h"
@@ -60,23 +61,24 @@ static muxer_stream_t* mpegfile_new_stre
   if (!(s->b_buffer = malloc (MUXER_MPEG_BLOCKSIZE))) {
     free (s);
     return NULL; // no mem?!
-  } else if (type == MUXER_TYPE_VIDEO) {
+  }
+  muxer->streams[muxer->avih.dwStreams]=s;
+  s->type=type;
+  s->id=muxer->avih.dwStreams;
+  s->timer=0.0;
+  s->size=0;
+  s->muxer=muxer;
+  if (type == MUXER_TYPE_VIDEO) {
     s->ckid = be2me_32 (0x1e0 + muxer->num_videos);
     muxer->num_videos++;
     s->h.fccType=streamtypeVIDEO;
     if(!muxer->def_v) muxer->def_v=s;
-//    printf ("Added video stream %d\n", muxer->num_videos);
+    mp_msg (MSGT_MENCODER, MSGL_DBG2, "Added video stream %d, ckid=%X\n", muxer->num_videos, s->ckid);
   } else { // MUXER_TYPE_AUDIO
     s->ckid = be2me_32 (0x1c0 + s->id - muxer->num_videos);
     s->h.fccType=streamtypeAUDIO;
-//    printf ("Added audio stream %d\n", s->id - muxer->num_videos + 1);
+    mp_msg (MSGT_MENCODER, MSGL_DBG2, "Added audio stream %d, ckid=%X\n", s->id - muxer->num_videos + 1, s->ckid);
   }
-  muxer->streams[muxer->avih.dwStreams]=s;
-  s->type=type;
-  s->id=muxer->avih.dwStreams;
-  s->timer=0.0;
-  s->size=0;
-  s->muxer=muxer;
   muxer->avih.dwStreams++;
   return s;
 }
@@ -119,6 +121,7 @@ static int write_mpeg_block(muxer_t *mux
   unsigned int mints=0;
   uint16_t l1;
 
+  mp_msg(MSGT_MENCODER, MSGL_DBG3, " MPEG block: size=%u, scr=%u, rate=%u, id=%X;", len, muxer->file_end, muxer->sysrate, s->ckid);
   if (s->b_buffer_ptr == 0) { // 00001111 if no PTS
     s->b_buffer[0] = 0xf;
     s->b_buffer_ptr = 1;
@@ -238,6 +241,7 @@ static void set_mpeg_pts(muxer_t *muxer,
   }
   else
     dts -= nts/2; // one frame :)
+  mp_msg(MSGT_MENCODER, MSGL_DBG3, ", dts=%u", dts);
   write_mpeg_ts (s->b_buffer+7, dts, 0x10);
 }
 
@@ -316,6 +320,7 @@ static void mpegfile_write_chunk(muxer_s
     else
       sz = len;
   }
+  mp_msg(MSGT_MENCODER, MSGL_DBG3, "\nMPEG chunk: size=%u, pts=%f", len, s->timer);
   set_mpeg_pts (muxer, s, pts);
   // alter counters:
   if (s->h.dwSampleSize) {
@@ -361,6 +366,7 @@ static void mpegfile_write_chunk(muxer_s
     memcpy (s->b_buffer+s->b_buffer_ptr, s->buffer+ptr, len);
     s->b_buffer_ptr += len;
   }
+  mp_msg(MSGT_MENCODER, MSGL_DBG3, " next pts=%f\n", s->timer);
 }
 
 static void mpegfile_write_header(muxer_t *muxer){


More information about the MPlayer-dev-eng mailing list