After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668833 - kateenc provides wrong duration information when muxed in Matroska
kateenc provides wrong duration information when muxed in Matroska
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 673102 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-01-27 12:59 UTC by horsthuchen
Modified: 2012-03-30 15:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Output from the gst-launch command (27.56 KB, application/x-bzip)
2012-01-30 14:05 UTC, horsthuchen
Details
Log of my Qt program (27.57 KB, text/x-log)
2012-01-31 10:14 UTC, horsthuchen
Details

Description horsthuchen 2012-01-27 12:59:38 UTC
Hi all,
I try to use the kateenc encoder together with the matroskamux plugin to write an MotionJpeg Stream together with an subtitle in one file.

But while pushing some "text/plain" packages into that encoder and after all pushing an EOS Package to the whole Pipe I get an Error:
gst_kate_enc_sink_event:<kateenc0> Failed to encode EOS packet: -4

And after extracting the katestream from the matroska container the using "KateDj" to get an human readable form.

There are Errors in this file:
First it it is starting with
  event {
    id 0
    00:00:00 --> -596:-31:-23.648001
    pre text "Hello World"
  }

and then 

the duration is always zero as seen here
  event {
    id 1
    00:00:0.13699999 --> 00:00:0.13699999
    pre text "Hello World"
  }

I write every 10th Frame "Hello World" with the pushBuffer Function.
Comment 1 Vincent Penquerc'h 2012-01-27 13:09:11 UTC
Could you please share the sample code you're using to push buffers so I can reproduce the issue, as it seems to be dependant on the input timestamps (-4 being a timestamp related error) ?
Comment 2 horsthuchen 2012-01-27 13:20:58 UTC
I'm using qtgstreamer 

   char ch[]= "Hello World";
    static int i=0;
    i++;
    if(i%10==0)
    {
      memcpy(subtitleBuffer->data(),ch,12);
      subtitleAppSource->pushBuffer(subtitleBuffer);
    }

    memcpy(videoBuffer->data(), image.data, videoBuffer->size());
    videoAppSource->pushBuffer(videoBuffer);


And to stop

pipeline->sendEvent(QGst::EosEvent::create());

Do you need additional Code fragments.

My whole pipe:

      appsrc->  jpegenc->   matroskamux->filesink
                            /\
                            ||
appsrc->kateenc->kateparse =
Comment 3 horsthuchen 2012-01-27 13:25:28 UTC
But without the kateparse I get same behaviour
Comment 4 Vincent Penquerc'h 2012-01-27 13:28:16 UTC
I should be able to reproduce something similar with that information, thanks.
Comment 5 Vincent Penquerc'h 2012-01-28 12:44:13 UTC
I cannot reproduce the error, but as I said on IRC, I think I remember seeing that a while ago, and it was fixed then. I can't find what fixed it, but please make sure you are using the latest version of libkate, as I think the fix may have been there.

I also found a memory corruption bug in matroskamux and an old obsolete duration hack in kateenc, both fixed now, see commits below. The matroskamux one only got introduced recently, so you only need that fix if you were using git gstreamer, but you do need the kateenc one for timings to work with Matroska.

Now, if you still get that EOS error, can you please try the following pipeline:

GST_DEBUG=kate*:5,matroska*:5,GST_SCHEDULING:5  gst-launch-0.10  texttestsrc num-buffers=8 blocksize=12 ! text/plain,framerate=1/1 ! kateenc category=SUB ! queue ! matroskamux name=mux ! filesink location=out.mkv videotestsrc num-buffers=80 ! video/x-raw-yuv,framerate=10/1 ! jpegenc ! queue ! mux. >& /tmp/gst.log

The output will all be redirected to /tmp/gst.log, along with extra debug info, which you can attach to this bug if you get that EOS issue with that command as well. If not, then please run your own program with GST_DEBUG=kate*:5,matroska*:5,GST_SCHEDULING:5, and attach the output of that.


commit 119f94bab7564603a15b51376e815b122c31d404
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Sat Jan 28 12:35:13 2012 +0000

    matroskamux: do not free memory twice
    
    A recent change to fix leaking codec ID string accidentally caused
    one of the very few places that weren't leaking to now free twice.


commit e0b0604119fd7cfb2242605dcff10405ff0a1285
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Sat Jan 28 12:32:46 2012 +0000

    kateenc: remove 'flush every packet' hack
    
    This is a bad hack which does not work with Matroska, and is now
    obsolete as similar code is not included in oggmux/oggstream.
Comment 6 horsthuchen 2012-01-30 14:05:30 UTC
Created attachment 206433 [details]
Output from the gst-launch command

I have tried the mentioned command. And it seems that it works, but vlc does not display the subtitles. But that could be a vlc problem.

I will test the rest tomorrow.
Comment 7 Vincent Penquerc'h 2012-01-30 14:25:51 UTC
A quick try shows here:

[0x7fe7b80380b0] main subpicture error: blending YUVA to J422 failed

So it looks like VLC is missing a blender for this format, as replacing jpegenc with theoraenc causes VLC to show the subtitles. My guess is that VLC decodes JPEG and Theora to different YUV formats, and cannot overlay AYUV onto the one it decodes JPEG to.

Is your EOS issue fixed too ?
If so, was it fixed by updating the gst kateenc plugin, or libkate ?
Comment 8 horsthuchen 2012-01-31 07:59:09 UTC
Yesterday I tried only to compile from the git respoitory and include the testtestserc patch.

Today I try to fix my own program.

I got a new Error:

:959:gst_kate_enc_chain_text:<kateenc0> Encoding text:  Hello World (12 bytes) from 18446743552.000000 to 18446743552.000000
0:00:05.084648652 31958 0x7f234400de40 WARN                 kateenc gstkateenc.c:963:gst_kate_enc_chain_text:<kateenc0> error: Failed to encode text: -4
0:00:05.084694194 31958 0x7f234400de40 LOG                  kateenc gstkateenc.c:1025:gst_kate_enc_chain:<kateenc0> Leaving chain function
0:00:05.084737658 31958 0x7f234400de40 INFO                 kateenc gstkateenc.c:1365:gst_kate_enc_sink_event:<kateenc0> Got EOS event
0:00:05.084749318 31958 0x7f234400de40 LOG                  kateenc gstkateenc.c:1367:gst_kate_enc_sink_event:<kateenc0> ensuring all headers are in
0:00:05.084760751 31958 0x7f234400de40 WARN                 kateenc gstkateenc.c:1384:gst_kate_enc_sink_event:<kateenc0> Failed to encode EOS packet: -4
0:00:05.086646714 31958 0x7f234400b5f0 ERROR           collectpads2 gstcollectpads2.c:1502:gst_collect_pads2_recalculate_waiting:<collectpads20> GstCollectPads2 can handle only time segments.

Have to any hint what I could do
Comment 9 horsthuchen 2012-01-31 10:14:05 UTC
Created attachment 206505 [details]
Log of my Qt program
Comment 10 horsthuchen 2012-01-31 10:14:57 UTC
I have an log file of my current program.
But don't understand the errors.
Maybe you do.
Comment 11 Vincent Penquerc'h 2012-01-31 11:29:23 UTC
Those logs show that the text buffers that come in have wrong timestamps (I think the 18446743552 is actually no timestamp).
The source should timestamp buffers properly.
Error logging could be better though :)
Comment 12 horsthuchen 2012-01-31 12:07:20 UTC
But could I get correct timestamps.
I already have set property of appsrc do-timestamp to true
Comment 13 horsthuchen 2012-01-31 15:13:29 UTC
I think that could be closed It works.
I didn't set the timestamps correct resp. I left this completely out

But now everything is doing what it should.

Thanks a lot for the help
Comment 14 Vincent Penquerc'h 2012-02-01 12:03:47 UTC
Great.

For my own knowledge, can you say what step did fix the EOS issue ?
Was it fixed as a side effect of setting timestamps on the text buffers, or updating libkate, or something else ?
Comment 15 horsthuchen 2012-02-02 08:30:13 UTC
I never updated libkate (it was already the newest version).
I don't really know what the error fixed.
Before I started I had the gstreamer 0.10.35 installed from the debian packages and know I compiled it from the git master branch by myself.
So this could be also a reason in my eyes.

But I did not change anything else in the development environment.

I also added some queues into the pipe (as in the example shown) but do not know if that matters.

Sorry that I could not do full particulars what fixed the bug, because it was sometimes a quite confusing development process for me.

Hope you can benefit from this information.
Comment 16 Vincent Penquerc'h 2012-02-02 10:05:19 UTC
Thanks for the info.
That EOS issue was possibly a red herring then, caused as a byproduct of the rest.
I've updated the bug title to reflect what was actually fixed, then.
Comment 17 Antoine Tremblay 2012-03-30 15:24:47 UTC
*** Bug 673102 has been marked as a duplicate of this bug. ***