GNOME Bugzilla – Bug 668833
kateenc provides wrong duration information when muxed in Matroska
Last modified: 2012-03-30 15:24:47 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.
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) ?
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 =
But without the kateparse I get same behaviour
I should be able to reproduce something similar with that information, thanks.
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.
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.
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 ?
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
Created attachment 206505 [details] Log of my Qt program
I have an log file of my current program. But don't understand the errors. Maybe you do.
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 :)
But could I get correct timestamps. I already have set property of appsrc do-timestamp to true
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
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 ?
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.
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.
*** Bug 673102 has been marked as a duplicate of this bug. ***