Opened 10 years ago

Closed 7 years ago

#934 closed defect (fixed)

mediagoblin.media_types.video tries to process SVG files

Reported by: ayleph Owned by:
Priority: major Milestone:
Component: programming Keywords: svg, gstreamer, thumbnail
Cc: Alex Jordan Parent Tickets:

Description

When an SVG file is uploaded, mediagoblin.media_types.video accepts the file and tries to transcode and create a thumbnail of the file. Debug output follows. Attached is a screenshot of how an SVG appears after being processed by mediagoblin.media_types.video. In this instance, the SVG plugin is not installed. This issue may not apply if the SVG plugin is installed.

09:51:53,585 INFO    [mediagoblin.media_types] No media handler found by file extension. Doing it the expensive way...
09:51:53,588 INFO    [mediagoblin.media_types.image.processing] Sniffing mediagoblin.media_types.image
09:51:53,589 DEBUG   [mediagoblin.media_types.image.processing] Media present, extension not found in ['png', 'gif', 'jpg', 'jpeg', 'tiff']
09:51:53,589 INFO    [mediagoblin.media_types.audio.processing] Sniffing mediagoblin.media_types.audio
09:51:53,589 INFO    [mediagoblin.media_types.audio.transcoders] Initializing AudioTranscoder
09:51:53,589 INFO    [mediagoblin.media_types.audio.transcoders] Discovering /tmp/tmp48IrtU
09:51:53,623 DEBUG   [mediagoblin.media_types.audio.transcoders] Discovered: {'_timeoutid': 0, 'audiocaps': {}, 'audiodepth': 0, 'videowidth': 554, 'audiofloat': False, 'dbin': <__main__.GstDecodeBin object (decodeb
in0) at 0x7f19041d1410>, '_nomorepads': True, 'audiorate': 0, 'audiochannels': 0, 'audiowidth': 0, 'videoheight': 102, 'tags': {}, 'bus': <gst.Bus object (bus1) at 0x7f19041d1690>, 'finished': True, 'typefind': <__main__.GstTy
peFindElement object (typefind) at 0x7f19041d1500>, 'videorate': <gst.Fraction 0/1>, 'src': <__main__.GstFileSrc object (filesrc0) at 0x7f19041d14b0>, 'mimetype': 'image/svg+xml', 'audiolength': 0L, 'videolength': -1, 'otherst
reams': [], 'sinknumber': 1, '_max_interleave': 1.0, '_success': True, 'videocaps': <GstCaps at 0x7f18c400a140>, '_timeout': 3000, 'is_audio': False, 'is_video': True}
09:51:53,623 INFO    [mediagoblin.media_types.audio.transcoders] Quitting MainLoop gracefully...
09:51:53,623 INFO    [mediagoblin.media_types.video.transcoders] Initializing VideoTranscoder...
09:51:53,623 INFO    [mediagoblin.media_types.video.transcoders] Discovering /tmp/tmp48IrtU
09:51:53,623 DEBUG   [mediagoblin.media_types.video.transcoders] Setting up discoverer
09:51:53,633 DEBUG   [mediagoblin.media_types.video.transcoders] Discovered: /gst+extend+discoverer+Discoverer:gst+extend+discoverer+discoverer1 (Discoverer)
09:51:53,633 INFO    [mediagoblin.media_types.video.transcoders] Terminating MainLoop
09:51:53,634 INFO    [mediagoblin.media_types.video.processing] Sniffing mediagoblin.media_types.video
09:51:53,634 DEBUG   [mediagoblin.media_types.video.processing] Discovered: {'_timeoutid': 0, 'audiocaps': {}, 'audiodepth': 0, 'videowidth': 554, 'audiofloat': False, 'dbin': <__main__.GstDecodeBin object (decodebin1) at 0x7f19041d1140>, '_nomorepads': True, 'audiorate': 0, 'audiochannels': 0, 'audiowidth': 0, 'videoheight': 102, 'tags': {}, 'bus': <gst.Bus object (bus4) at 0x7f19041d1730>, 'finished': True, 'typefind': <__main__.GstTypeFindElement object (typefind) at 0x7f19041d10f0>, 'videorate': <gst.Fraction 0/1>, 'src': <__main__.GstFileSrc object (filesrc1) at 0x7f19041d10a0>, 'mimetype': 'image/svg+xml', 'audiolength': 0L, 'videolength': -1, 'otherstreams': [], 'sinknumber': 1, '_max_interleave': 1.0, '_success': True, 'videocaps': <GstCaps at 0x7f18c400a2c0>, '_timeout': 3000, 'is_audio': False, 'is_video': True}
09:51:53,634 INFO    [mediagoblin.media_types] mediagoblin.media_types.video accepts the file
09:51:53,676 DEBUG   [mediagoblin.processing.task] Processing <MediaEntry 30: MediaGoblin_logo>
09:51:53,676 INFO    [mediagoblin.media_types.video.transcoders] Initializing VideoTranscoder...
09:51:53,679 INFO    [mediagoblin.media_types.video.transcoders] Discovering /path/to/mediagoblin/user_dev/media/queue/media_entries/hash/MediaGoblin_logo.svg
09:51:53,679 DEBUG   [mediagoblin.media_types.video.transcoders] Setting up discoverer
09:51:53,686 DEBUG   [mediagoblin.media_types.video.transcoders] Discovered: /gst+extend+discoverer+Discoverer:gst+extend+discoverer+discoverer2 (Discoverer)
09:51:53,686 INFO    [mediagoblin.media_types.video.transcoders] Terminating MainLoop
09:51:53,688 DEBUG   [mediagoblin.media_types.video.util] skip_transcode config: {u'mime_types': [u'video/webm'], u'container_formats': [u'Matroska'], u'video_codecs': [u'VP8 video'], u'audio_codecs': [u'Vorbis'], u'dimensions_match': True}
09:51:53,688 DEBUG   [mediagoblin.media_types.video.transcoders] Setting up discoverer
09:51:53,690 DEBUG   [mediagoblin.media_types.video.transcoders] Setting up transcoding pipeline
09:51:53,707 INFO    [mediagoblin.media_types.video.transcoders] Discovering...
09:51:53,709 INFO    [mediagoblin.media_types.video.transcoders] Done
09:51:53,709 DEBUG   [mediagoblin.media_types.video.transcoders] Initializing MainLoop()
09:51:53,712 DEBUG   [mediagoblin.media_types.video.transcoders] __discovered, data: {'_timeoutid': 0, 'audiocaps': {}, 'audiodepth': 0, 'videowidth': 554, 'audiofloat': False, 'dbin': <__main__.GstDecodeBin object (decodebin3) at 0x7f1904585820>, '_nomorepads': True, 'audiorate': 0, 'audiochannels': 0, 'audiowidth': 0, 'videoheight': 102, 'tags': {}, 'bus': <gst.Bus object (bus10) at 0x7f19088945f0>, 'finished': True, 'typefind': <__main__.GstTypeFindElement object (typefind) at 0x7f1904585aa0>, 'videorate': <gst.Fraction 0/1>, 'src': <__main__.GstFileSrc object (filesrc3) at 0x7f1904585730>, 'mimetype': 'image/svg+xml', 'audiolength': 0L, 'videolength': -1, 'otherstreams': [], 'sinknumber': 1, '_max_interleave': 1.0, '_success': True, 'videocaps': <GstCaps at 0x7f18c400a600>, '_timeout': 3000, 'is_audio': False, 'is_video': True}
09:51:53,712 DEBUG   [mediagoblin.media_types.video.transcoders] linking elements
09:51:53,727 INFO    [mediagoblin.media_types.video.transcoders] Transcoding...
...
09:51:53,779 INFO    [mediagoblin.media_types.video.transcoders] 100% done...
09:51:53,780 DEBUG   [mediagoblin.media_types.video.transcoders] {'current': 9520, 'total': 9520, 'percent': 100, 'percent-double': 100.0, 'format': <enum GST_FORMAT_BYTES of type GstFormat>}
09:51:53,780 DEBUG   [mediagoblin.media_types.video.transcoders] (<gst.Bus object (bus13) at 0x7f1908894460>, <gst.Message (none) from VideoTranscoderPipeline at 0x7f18cc0048b0>, <flags GST_MESSAGE_EOS of type GstMessageType>)
09:51:53,782 INFO    [mediagoblin.media_types.video.transcoders] Done
09:51:53,784 DEBUG   [mediagoblin.media_types.video.transcoders] <glib.MainLoop object at 0x7f19044cc870>
09:51:53,785 INFO    [mediagoblin.media_types.video.transcoders] Terminating MainLoop
09:51:53,789 DEBUG   [mediagoblin.media_types.video.processing] Saving medium...
09:51:53,791 DEBUG   [mediagoblin.media_types.video.processing] Saved medium
09:51:53,828 DEBUG   [mediagoblin.media_types.video.transcoders] playbin state changed:
prev: <enum GST_STATE_NULL of type GstState>
cur: <enum GST_STATE_READY of type GstState>
 pending: <enum GST_STATE_PAUSED of type GstState>
...
09:51:53,833 INFO    [mediagoblin.media_types.video.transcoders] playbin ready
09:51:53,833 CRITICA [mediagoblin.media_types.video.transcoders] Could not get any video data from playbin
09:51:53,833 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 1: query failed
09:51:53,833 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 2: query failed
09:51:53,833 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 3: query failed
09:51:53,834 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 4: query failed
09:51:53,834 CRITICA [mediagoblin.media_types.video.transcoders] Pipeline duration query retry limit reached.
09:51:53,834 DEBUG   [mediagoblin.media_types.video.transcoders] thumbnail_pipeline: filesrc location="/path/to/mediagoblin/user_dev/media/queue/media_entries/hash/MediaGoblin_logo.svg" ! decodebin2 ! ffmpegcolorspace ! videoscale ! video/x-raw-rgb,depth=24,bpp=24,pixel-aspect-ratio=1/1,width=180 ! fakesink signal-handoffs=True
09:51:53,859 DEBUG   [mediagoblin.media_types.video.transcoders] thumbnail state changed:
prev: <enum GST_STATE_NULL of type GstState>
cur: <enum GST_STATE_READY of type GstState>
 pending: <enum GST_STATE_VOID_PENDING of type GstState>
...
09:51:53,860 INFO    [mediagoblin.media_types.video.transcoders] Could not seek.
...
09:51:53,867 ERROR   [mediagoblin.media_types.video.transcoders] thumbnail error: [<GError at 0x7f18f83e5570>, 'gstvideoscale.c(779): gst_video_scale_fixate_caps (): /GstPipeline:pipeline0/GstVideoScale:videoscale0:\nError calculating the output scaled size - integer overflow']
09:51:53,867 ERROR   [mediagoblin.media_types.video.transcoders] thumbnail error: [<GError at 0x7f18f83e56c0>, 'gstvideoscale.c(779): gst_video_scale_fixate_caps (): /GstPipeline:pipeline0/GstVideoScale:videoscale0:\nError calculating the output scaled size - integer overflow']
09:51:53,867 DEBUG   [mediagoblin.media_types.video.transcoders] thumbnail state changed:
prev: <enum GST_STATE_READY of type GstState>
cur: <enum GST_STATE_PAUSED of type GstState>
 pending: <enum GST_STATE_VOID_PENDING of type GstState>
09:51:53,867 INFO    [mediagoblin.media_types.video.transcoders] Could not seek.
09:51:53,867 ERROR   [mediagoblin.media_types.video.transcoders] Thumbnailing failed because of videoscale integer overflow. Will retry with fallback.
09:51:53,876 INFO    [mediagoblin.media_types.video.transcoders] Retrying with manually set sizes...
09:51:53,876 INFO    [mediagoblin.media_types.video.transcoders] Initializing VideoTranscoder...
09:51:53,876 INFO    [mediagoblin.media_types.video.transcoders] Discovering /path/to/mediagoblin/user_dev/media/queue/media_entries/hash/MediaGoblin_logo.svg
09:51:53,876 DEBUG   [mediagoblin.media_types.video.transcoders] Setting up discoverer
09:51:53,879 ERROR   [mediagoblin.media_types.video.transcoders] Thumbnailing failed because of videoscale integer overflow. Will retry with fallback.
09:51:53,879 INFO    [mediagoblin.media_types.video.transcoders] Retrying with manually set sizes...
09:51:53,879 INFO    [mediagoblin.media_types.video.transcoders] Initializing VideoTranscoder...
09:51:53,879 INFO    [mediagoblin.media_types.video.transcoders] Discovering /path/to/mediagoblin/user_dev/media/queue/media_entries/hash/MediaGoblin_logo.svg
09:51:53,879 DEBUG   [mediagoblin.media_types.video.transcoders] Setting up discoverer
09:51:53,882 DEBUG   [mediagoblin.media_types.video.transcoders] Discovered: /gst+extend+discoverer+Discoverer:gst+extend+discoverer+discoverer5 (Discoverer)
09:51:53,882 INFO    [mediagoblin.media_types.video.transcoders] Terminating MainLoop
09:51:53,883 DEBUG   [mediagoblin.media_types.video.transcoders] Discovered: /gst+extend+discoverer+Discoverer:gst+extend+discoverer+discoverer6 (Discoverer)
09:51:53,883 INFO    [mediagoblin.media_types.video.transcoders] Terminating MainLoop
09:51:53,904 DEBUG   [mediagoblin.media_types.video.transcoders] playbin state changed:
prev: <enum GST_STATE_NULL of type GstState>
cur: <enum GST_STATE_READY of type GstState>
 pending: <enum GST_STATE_PAUSED of type GstState>
...
09:51:53,909 INFO    [mediagoblin.media_types.video.transcoders] playbin ready
09:51:53,909 CRITICA [mediagoblin.media_types.video.transcoders] Could not get any video data from playbin
09:51:53,909 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 1: query failed
09:51:53,909 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 2: query failed
09:51:53,909 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 3: query failed
09:51:53,910 ERROR   [mediagoblin.media_types.video.transcoders] Could not get duration on attempt 4: query failed
09:51:53,910 CRITICA [mediagoblin.media_types.video.transcoders] Pipeline duration query retry limit reached.
09:51:53,910 DEBUG   [mediagoblin.media_types.video.transcoders] thumbnail_pipeline: filesrc location="/path/to/mediagoblin/user_dev/media/queue/media_entries/hash/MediaGoblin_logo.svg" ! decodebin2 ! ffmpegcolorspace ! videoscale ! video/x-raw-rgb,depth=24,bpp=24,pixel-aspect-ratio=1/1,width=180,height=33 ! fakesink signal-handoffs=True
09:51:53,936 DEBUG   [mediagoblin.media_types.video.transcoders] thumbnail state changed:
prev: <enum GST_STATE_NULL of type GstState>
cur: <enum GST_STATE_READY of type GstState>
 pending: <enum GST_STATE_VOID_PENDING of type GstState>
...
09:51:53,937 INFO    [mediagoblin.media_types.video.transcoders] Could not seek.
...
09:51:56,863 CRITICA [mediagoblin.media_types.video.transcoders] Reached gobject timeout
09:51:56,930 DEBUG   [mediagoblin.media_types.video.transcoders] playbin state changed:
prev: <enum GST_STATE_NULL of type GstState>
cur: <enum GST_STATE_READY of type GstState>
 pending: <enum GST_STATE_PAUSED of type GstState>
...
09:51:56,936 CRITICA [mediagoblin.media_types.video.transcoders] Reached gobject timeout
09:51:56,970 DEBUG   [mediagoblin.tools.processing] No processing callback for <MediaEntry 30: MediaGoblin_logo>

Attachments (2)

tanscode-svg.png (93.3 KB ) - added by ayleph 10 years ago.
SVG that has been transcoded by mediagoblin.media_types.video
0001-Prevent-video-plugin-from-processing-svg-934.patch (1.8 KB ) - added by ayleph 7 years ago.

Download all attachments as: .zip

Change History (11)

by ayleph, 10 years ago

Attachment: tanscode-svg.png added

SVG that has been transcoded by mediagoblin.media_types.video

comment:1 by ayleph, 10 years ago

Owner: set to ayleph
Status: newin_progress

comment:2 by ayleph, 10 years ago

Quick solution: use the EXCLUDED_EXTS directive to disallow mediagoblin.media_types.video processing SVG files.

Here's the current state of code.

mediagoblin/media_types/video/processing.py

EXCLUDED_EXTS = ["nef"]

def sniff_handler(media_file, filename):
    name, ext = os.path.splitext(filename)
    clean_ext = ext.lower()[1:]

    if clean_ext in EXCLUDED_EXTS:
        # We don't handle this filetype, though gstreamer might think we can
        return None

And here we explicitly disallow processing SVG files as video type.

mediagoblin/media_types/video/processing.py

EXCLUDED_EXTS = ["nef", "svg"]

def sniff_handler(media_file, filename):
    name, ext = os.path.splitext(filename)
    clean_ext = ext.lower()[1:]

    if clean_ext in EXCLUDED_EXTS:
        # We don't handle this filetype, though gstreamer might think we can
        return None

The only difference is this line:

-EXCLUDED_EXTS = ["nef"]
+EXCLUDED_EXTS = ["nef", "svg"]

comment:3 by ayleph, 10 years ago

With the above change made, the GMG web interface reports Sorry, I don't support that file type :( when an SVG file is selected for upload. Debug output confirms that the file is not accepted by any of the media_type handlers.

10:32:06,313 DEBUG   [paste.httpserver.ThreadPool] Added task (0 tasks queued)
10:32:06,322 DEBUG   [mediagoblin.tools.routing] endpoint: mediagoblin.submit.start view_func: <function submit_start at 0x7fbbe040c0c8>
10:32:06,331 INFO    [mediagoblin.media_types] No media handler found by file extension. Doing it the expensive way...
10:32:06,334 INFO    [mediagoblin.media_types.image.processing] Sniffing mediagoblin.media_types.image
10:32:06,334 DEBUG   [mediagoblin.media_types.image.processing] Media present, extension not found in ['png', 'gif', 'jpg', 'jpeg', 'tiff']
10:32:06,334 INFO    [mediagoblin.media_types.audio.processing] Sniffing mediagoblin.media_types.audio
10:32:06,334 INFO    [mediagoblin.media_types.audio.transcoders] Initializing AudioTranscoder
10:32:06,335 INFO    [mediagoblin.media_types.audio.transcoders] Discovering /tmp/tmpP9Gdl6
10:32:06,363 DEBUG   [mediagoblin.media_types.audio.transcoders] Discovered: {'_timeoutid': 0, 'audiocaps': {}, 'audiodepth': 0, 'videowidth': 554, 'audiofloat': False, 'dbin': <__main__.GstDecodeBin object (decodebin0) at 0x7fbbe03f2af0>, '_nomorepads': True, 'audiorate': 0, 'audiochannels': 0, 'audiowidth': 0, 'videoheight': 102, 'tags': {}, 'bus': <gst.Bus object (bus1) at 0x7fbbe03f2b90>, 'finished': True, 'typefind': <__main__.GstTypeFindElement object (typefind) at 0x7fbbe03f2b40>, 'videorate': <gst.Fraction 0/1>, 'src': <__main__.GstFileSrc object (filesrc0) at 0x7fbbe03f20f0>, 'mimetype': 'image/svg+xml', 'audiolength': 0L, 'videolength': -1, 'otherstreams': [], 'sinknumber': 1, '_max_interleave': 1.0, '_success': True, 'videocaps': <GstCaps at 0x7fbba000a140>, '_timeout': 3000, 'is_audio': False, 'is_video': True}
10:32:06,363 INFO    [mediagoblin.media_types.audio.transcoders] Quitting MainLoop gracefully...
10:32:06,364 DEBUG   [mediagoblin.media_types] None did not accept the file
10:32:06,390 DEBUG   [paste.httpserver.ThreadPool] Added task (0 tasks queued)

I believe this is the desired behaviour. However, it is interesting that gstreamer0.10 apparently sets 'is_video': True for SVG files. Perhaps this is useful to someone.

comment:4 by ayleph, 10 years ago

Owner: ayleph removed
Status: in_progressreview

comment:5 by ayleph, 10 years ago

Resolution: invalid
Status: reviewclosed

This is no longer an issue with the new gstreamer1.0 code.

comment:6 by ayleph, 9 years ago

Resolution: invalid
Status: closedaccepted

Actually, this is still happening with gstreamer1.x, so I'm reopening the ticket.

comment:7 by Alex Jordan, 8 years ago

Cc: Alex Jordan added

comment:8 by ayleph, 7 years ago

Status: acceptedreview

I forgot about this for a long time, but here it is. This patch reimplements the EXCLUDED_EXT feature in the video processing engine. I've included SVG and NEF files as discussed previously.

comment:9 by ayleph, 7 years ago

Resolution: fixed
Status: reviewclosed

Pushed to master in 9a23a81.

Note: See TracTickets for help on using tickets.