#13 Blue tint in video

closed-fixed
nobody
None
5
2011-01-22
2010-10-08
Cefn Hoile
No

I also seem to get a blue tint in GSMovie playback.

Hadn't noticed this so much before as I was mostly looking at B+W footage, but when I'm playing color, I get issues which are consistent with this bug report...
https://answers.launchpad.net/ubuntu/+source/totem/+question/7373

What's a sensible intervention to make in order to fix the problem outlined in that bug report, and maybe using the same approach, but modifying the pipeline which GSMovie creates so that I can paint it into my processing sketch?

I'm running Ubuntu Lucid with the latest gstreamer-java build from SVN and the following packages...

ii gstreamer-tools 0.10.30-1~lucid1 Tools for use with GStreamer
ii gstreamer0.10-alsa 0.10.30-2~lucid1 GStreamer plugin for ALSA
ii gstreamer0.10-esd 0.10.25-4~lucid1 GStreamer plugin for ESD
ii gstreamer0.10-ffmpeg 0.10.11-1~lucid1 FFmpeg plugin for GStreamer
ii gstreamer0.10-gnonlin 0.10.16-1~lucid1 non-linear editing module for GStreamer
ii gstreamer0.10-nice 0.0.10-2build1 ICE library (GStreamer plugin)
ii gstreamer0.10-pitfdll 0.9.1.1+cvs20080215-1ubuntu2 GStreamer plugin for using MS Windows binary
ii gstreamer0.10-plugins-bad 0.10.20-1~lucid1 GStreamer plugins from the "bad" set
ii gstreamer0.10-plugins-bad-multiverse 0.10.18-0ubuntu1 GStreamer plugins from the "bad" set (Multiv
ii gstreamer0.10-plugins-base 0.10.30-2~lucid1 GStreamer plugins from the "base" set
ii gstreamer0.10-plugins-base-apps 0.10.30-2~lucid1 GStreamer helper programs from the "base" se
ii gstreamer0.10-plugins-good 0.10.25-4~lucid1 GStreamer plugins from the "good" set
ii gstreamer0.10-plugins-ugly 0.10.16-1~lucid1 GStreamer plugins from the "ugly" set
ii gstreamer0.10-plugins-ugly-multiverse 0.10.14-0ubuntu2 GStreamer plugins from the "ugly" set (Multi
ii gstreamer0.10-pulseaudio 0.10.25-4~lucid1 GStreamer plugin for PulseAudio
ii gstreamer0.10-tools 0.10.30-1~lucid1 Tools for use with GStreamer
ii gstreamer0.10-x 0.10.30-2~lucid1 GStreamer plugins for X11 and Pango
ii libgstreamer-plugins-base0.10-0 0.10.30-2~lucid1 GStreamer libraries from the "base" set
ii libgstreamer0.10-0 0.10.30-1~lucid1 Core GStreamer libraries and elements
ii libgstreamer0.10-dev 0.10.30-1~lucid1 GStreamer core development files

Discussion

  • Andres Colubri
    Andres Colubri
    2010-10-11

    I don't know if this a very clean solution but you can try first a color conversion to x-raw-yuv to swap the swap, as explained in the ubuntu bug report, and the another conversion to put in rgb (otherwise the stream won't play in Processing). For example:

    pipe = new GSPipeline(this, "videotestsrc pattern=0 ! ffmpegcolorspace ! video/x-raw-yuv,format=(fourcc)YV12 ! ffmpegcolorspace ! video/x-raw-rgb, width=320, height=240, bpp=32, depth=24");

    Here you should replace the videotestsrc source element with the appropriate elements for movie playback.

     
  • Cefn Hoile
    Cefn Hoile
    2010-10-12

    Thanks for your very detailed suggestion, Andres. But how do I know which files to apply special pipelines to?

    Since the pipeline is normally automatically constructed using just a filename, I'm not sure which cases will end up bringing in the components with the bug in and which need to be streamed using this modified pipeline. Or can all streams be handled in the same way?

    Black and White, for example, will presumably not require this gstreamer pipeline, but it's not clear from just the filename whether one of these videos will turn out to be black and white. I'm streaming hundreds of videos, so avoiding manually marking them up would be very useful.

    Do I need to know which color space or codec the originating video file uses to use this special pipeline, or just that it's color? Better, can I introspect this at runtime somehow, and switch which pipeline to build?

     
  • Andres Colubri
    Andres Colubri
    2010-10-14

    Although the GSMovie, GSCamera and GSMoviemaker classes should be enough for most users, I added the GSPipeline for more advanced and customized stream handling. However, properly defining a gstreamer pipeline requires you to understand the details of how gstreamer works.

    In this particular case, I suggested the use of GSPipeline more like a temporary workaround to take care of this color issue, ideally the GSMovie class should be able to deal with this and pick the right colorspace. From what I read on some other forums, this tint problem might be a bug in gstreamer itself, or maybe in the gstreamer-java bindings.

    In any case, a pipeline for movie playback is not so difficult to construct, specially because there is a gstreamer element called decodebin that autodetects the codec of the movie and does the appropriate decoding. So, in the case you need to play the file "/home/cefn/test.avi", which has a resolution of say 320x240, then the pipeline should be something like this:

    p = new GSPipeline(this, "filesrc location = /home/cefn/test.avi ! decodebin ! ffmpegcolorspace ! video/x-raw-rgb, width=320, height=240, bpp=32, depth=24");

    > Since the pipeline is normally automatically constructed using just a
    > filename, I'm not sure which cases will end up bringing in the components
    > with the bug in and which need to be streamed using this modified pipeline.
    > Or can all streams be handled in the same way?

    This is a good point, not sure at what point down the pipeline the bug is introduced and by which element... But I'd expect GSMovie and the GSPipeline I just suggested to have the same behavior in this case, because what GSMovie basically does is to construct a pipeline like the one in GSPipeline.

    > Do I need to know which color space or codec the originating video file
    > uses to use this special pipeline, or just that it's color? Better, can I
    > introspect this at runtime somehow, and switch which pipeline to build?

    No, because decodebin automatically determines the codec of the input stream and selects the appropriate decoder.

     
  • Cefn Hoile
    Cefn Hoile
    2010-12-08

    I've been trying to get this approach to work, but really struggling since even my simplest program relies on GSMovie#loop() to keep short videos cycling.

    Tried modifying GSMovie so that it can allow either a text specification of a Pipeline, (allowing all config to be specified) or a simple Playbin (where the pipeline is automatically constructed)? However, I've struggled doing this.

    Ended up with the implementation below, which nearly works. If I add '! autovideosink' it shows the first frame of the correct video, without the blue tint, in a separate xwindow, whilst all instances of the image in Processing are black squares.

    However, the pipeline doesn't seem to be feeding (stays at the first frame despite the setState(State.PLAYING) call in the superconstructor of GSPipeline) and I really need to be able to forward pixels to the RGB VideoSink which textures back into Processing instead of the autovideosink. Any ideas?

    public class CefnPipeline extends GSPipeline{

    public CefnPipeline\(PApplet parent, String filepath\) \{
        super\(parent, "filesrc location=" + filepath + " \! decodebin2 \! ffmpegcolorspace \! video/x-raw-yuv,format=\(fourcc\)YV12"\);
        this.gpipe.getBus\(\).connect\(new Bus.EOS\(\) \{
            public void endOfStream\(GstObject element\) \{
                boolean res = CefnPipeline.this.gpipe.seek\(ClockTime.fromNanos\(0\)\);
                if \(\!res\) \{
                    System.err.println\("Seek operation failed."\);
                \}    
            \}
        \}\);
    \}
    

    }

     
  • Cefn Hoile
    Cefn Hoile
    2010-12-08

    Should clarify that if I do not add the ! autovideosink then I get lines and lines of...

    Error getting pixels from pipeline: null
    Error getting pixels from pipeline: null
    Error getting pixels from pipeline: null
    Error getting pixels from pipeline: null
    Error getting pixels from pipeline: null
    Error getting pixels from pipeline: null
    Error getting pixels from pipeline: null

    For reference you can see all the code at...

    https://github.com/cefn/Powerpointless/tree/d1cb59f9e998c57ca1f4310edd268d89b04072cc/com/cefn/powerpointless

     
  • zaros
    zaros
    2011-01-10

    I tried this:

    pipe = new GSPipeline(this, "filesrc location=../video.mp4 ! qtdemux name=demux demux.video_00 ! queue ! ffdec_h264 ! ffmpegcolorspace ! video/x-raw-yuv, format=(fourcc)YV12 ! ffmpegcolorspace ! video/x-raw-rgb, width=640, height=480, bpp=32, depth=24");

    Colors didn't swap, and performance was bad.

     
  • zaros
    zaros
    2011-01-10

    I tried this:

    pipe = new GSPipeline(this, "filesrc location=/home/hirakudev/Dev/hirakudata/guidevideo.mp4 ! qtdemux name=demux demux.video_00 ! queue ! ffdec_h264 ! ffmpegcolorspace ! video/x-raw-yuv, format=(fourcc)YV12 ! queue ! ffmpegcolorspace ! video/x-raw-rgb, width=1280, height=720, bpp=32, depth=24");

    unfortunately trying the same pipe with gst-launch doesn't work

    -- Gstreamer encountered a general stream error.

    Don't know what to make of it.

     
  • zaros
    zaros
    2011-01-11

    GSpipeline works as expected now, thanks.

     
  • Andres Colubri
    Andres Colubri
    2011-01-22

    • status: open --> closed-fixed