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 750398 - avenc_mjpeg fails to negotiate the source format
avenc_mjpeg fails to negotiate the source format
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
1.4.5
Other Linux
: Normal minor
: 1.5.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-06-04 14:09 UTC by Francois Gouget
Modified: 2015-06-12 23:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
avcodec: Check against codec format list (2.59 KB, patch)
2015-06-04 23:17 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Francois Gouget 2015-06-04 14:09:54 UTC
To reproduce this, simply run the following command:

$ GST_DEBUG=1 gst-launch-1.0 videotestsrc num-buffers=40 ! videoconvert ! avenc_mjpeg ! fakesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
0:00:00.013323325 30166      0x18b1230 ERROR                  libav :0:: Specified pix_fmt is not supported
ERROR: from element /GstPipeline:pipeline0/avenc_mjpeg:avenc_mjpeg0: GStreamer error: negotiation problem.
Additional debug info:
gstvideoencoder.c(1463): gst_video_encoder_chain (): /GstPipeline:pipeline0/avenc_mjpeg:avenc_mjpeg0:
encoder not initialized
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

This worked fine in 1.0.6 but is broken in 1.2.4 and 1.4.5. It seems to be related to the 'format: { I420, Y42B }' restriction on the sink pad.
Comment 1 Nicolas Dufresne (ndufresne) 2015-06-04 17:18:53 UTC
Note that the recommended encoder for JPEG is jpegenc, which works in this scenario. This bug remains valid, thanks for reporting.
Comment 2 Nicolas Dufresne (ndufresne) 2015-06-04 17:36:21 UTC
Looks like we need to use AV_PIX_FMT_YUVJ420P instead of AV_PIX_FMT_YUV420P when encoding JPEG.
Comment 3 Nicolas Dufresne (ndufresne) 2015-06-04 18:13:42 UTC
The mjpeg encoder is the only encoder not yet ported to the new .color_range property. That means we need an exception specifically for that. (We should probably add .color_range too).
Comment 4 Nicolas Dufresne (ndufresne) 2015-06-04 23:17:32 UTC
Created attachment 304620 [details] [review]
avcodec: Check against codec format list

There exist few formats (deprecated though) used by mjpeg decoder
and encoder that maps to the same GStreamer format. To properly
pick the right format, also lookup each Codec list before accepting
the format. This fixes error when trying to use mjpeg encoder.

Note that this may results in faded colors. In fact, these special
format are meant to specify that this is full range YUV. Colorimetry
in gst-libav is not yet implemented, hence is ignored in general. So
I think it's fine to first fix the issue before addressing the missing
feature.
Comment 5 Francois Gouget 2015-06-09 10:14:03 UTC
This patch works for me.

The colors are indeed a bit faded, which was already the case with the GStreamer 0.10 ffenc_mjpeg version. That's particularly visible when Spice switches from the native rendering to the GStreamer-based video streaming. But otherwise I'm not sure one would really notice it. So while it would be nice to improve this aspect, it's not a blocker.

Regarding jpegenc, the issue is that it does not have a 'bitrate' property and as such is not a direct replacement for avenc_mjpeg. That's why I use avenc_mjpeg in the Spice GStreamer backend: it can easily be substituted with other encoders like VP8 or x264 with uniform code for adjusting each to the network conditions.
Comment 6 Nicolas Dufresne (ndufresne) 2015-06-12 23:40:04 UTC
I'll file a bug for the color issues. Thanks for testing and confirming my thoughts.
Comment 7 Nicolas Dufresne (ndufresne) 2015-06-12 23:41:03 UTC
Attachment 304620 [details] pushed as a33a1bf - avcodec: Check against codec format list
Comment 8 Nicolas Dufresne (ndufresne) 2015-06-12 23:44:56 UTC
Create this bug: https://bugzilla.gnome.org/show_bug.cgi?id=750882