I have a problem with files written from live sources (webcams) and pseuso-live sources (screencaptures) in GStreamer. The resulting files don't have a time length, and as a result don't play at all in Media Player Classic. They do play in Firefox, but without a time length and sometimes with increased speed.
It does not seem to matter what (pseudo-)live source I use, nor what codec or container. The story is always the same; incorrect media files with no set time length.
However, when I add the option "num-buffers=100" to dx9screencapsrc, the src element sends an EOS event after that number of buffers and then the file renders properly in MPC and Firefox. So the EOS event seems to do something so that the file gets closed properly.
I've tried the common ways to stop the pipeline (via setState(...)). Tried to manually send an EOS event to all elements, listening to the EOS event on the Bus and then quiting the pipeline. All to no avail, the files stay corrupt.
My question is, how can I stop the pipeline when using (pseudo-)live sources and produce correct files (i.e. in this case, has a correct time length).
I'm using gstreamer-java with GStreamer 0.10 on Java 6 and Windows 8. Take the following pipeline as an example:
dx9screencapsrc ! video/x-raw-rgb,framerate=15/1 ! ffmpegcolorspace ! vp8enc ! webmmux ! filesink location=%s
At this point, I'm at a loss as to how to solve this problem. Any help is greatly appreciated!
FIXED As it turns out, I had to send the EOS event only to the src element, not to every element in the pipeline.
The correct way would be to send the EOS event to the pipeline and wait until you get it as a GstMessage on the bus.
If you say you have tried that and it didn't work it could be a bug in the involved elements (unlikely), in the java bindings or in your code.
To rule out bugs in the involved elements I'd recommend trying:
gst-launch-0.10 -e dx9screencapsrc ! video/x-raw-rgb,framerate=15/1 ! ffmpegcolorspace ! vp8enc ! webmmux ! filesink location=%s
The -e flag will enable eos-on-shutdown which means that once you interrupt the process it will send EOS and wait for it on the bus (just like your application should do). If that works I'd recommend reviewing your code.
It is important to notice that you are using gstreamer 0.10 that is now 3 years obsolete and unmantained. It is strongly recommended to move to the 1.x series.