Bug 961881 - sound juicer produces flac file without MD5 signature
sound juicer produces flac file without MD5 signature
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: sound-juicer (Show other bugs)
20
x86_64 Linux
unspecified Severity high
: ---
: ---
Assigned To: Bastien Nocera
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-10 11:46 EDT by Sean Sheedy
Modified: 2015-06-29 07:57 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-06-29 07:57:06 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
GNOME Bugzilla 707963 None None None Never
GNOME Bugzilla 727802 None None None Never

  None (edit)
Description Sean Sheedy 2013-05-10 11:46:46 EDT
Description of problem:
When extracting to a flac file, sound juicer does not set the MD5 signature.  This basically makes the flac file useless.

Version-Release number of selected component (if applicable):
3.4.0-1

How reproducible:
Always

Steps to Reproduce:
1. Start sound juicer
2. Select FLAC profile
3. Extract an audio track
4. Check the resultant file with flac --test
  
Actual results:
flac --test produces the error:
WARNING, cannot check MD5 signature since it was unset in the STREAMINFO

Expected results:
The MD5 signature should be set.

Additional info:
Comment 1 Sean Sheedy 2013-06-27 12:08:49 EDT
This was originally filed against Fedora 17, but is still reproducing in Fedora 18.  I've updated the bug to reflect this.
Comment 2 Sean Sheedy 2013-06-27 12:14:11 EDT
Versions of components on Fedora 18 that produce the problem:

sound-juicer-3.5.0-2
libmusicbrainz5-5.0.1-5
libdiscid-0.2.2-7
gstreamer1-1.0.7-1
gstreamer1-plugins-base-1.0.7-1
gstreamer1-plugins-good
Comment 3 Fedora End Of Life 2013-12-21 08:28:35 EST
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '18'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior to Fedora 18's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 4 Sean Sheedy 2014-01-31 14:59:36 EST
Still reproducing in Fedora 20 - updating version field.
Comment 5 Sean Sheedy 2014-01-31 15:13:33 EST
Versions of components on Fedora 20 that produce the problem:

sound-juicer-3.5.0-5.fc20.x86_64
libmusicbrainz5-5.0.1-8.fc20.x86_64
libdiscid-0.2.2-9.fc20.x86_64
gstreamer1-1.2.2-1.fc20.x86_64
gstreamer1-1.2.2-1.fc20.i686
gstreamer1-plugins-base-1.2.2-1.fc20.x86_64
gstreamer1-plugins-good-1.2.2-2.fc20.x86_64
Comment 6 Christophe Fergeau 2014-04-07 13:51:33 EDT
I've spent some time on this one. When it's done encoding the file, libflac calls update_metadata() in src/libFLAC/stream_encoder.c which tries to seek at the beginning of the encoded file to rewrite the STREAMINFO header with the computed md5 checksum.
This calls gst_flac_enc_seek_callback() which starts by doing:

    /* try to seek to the beginning of the output */
    query = gst_query_new_seeking (GST_FORMAT_BYTES);
    if (gst_pad_query (peerpad, query)) {
      GstFormat format;

      gst_query_parse_seeking (query, &format, &seekable, NULL, NULL);
      if (format != GST_FORMAT_BYTES)
        seekable = FALSE;
    } else {
      GST_LOG_OBJECT (flacenc, "SEEKING query not handled");
    }
    gst_query_unref (query);

sound-juicer is using giosink, which does not handle SEEKING queries:

static gboolean
gst_gio_base_sink_query (GstBaseSink * bsink, GstQuery * query)
{
  GstGioBaseSink *sink = GST_GIO_BASE_SINK (bsink);
  GstFormat format;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
      gst_query_parse_position (query, &format, NULL);
      switch (format) {
        case GST_FORMAT_BYTES:
        case GST_FORMAT_DEFAULT:
          gst_query_set_position (query, GST_FORMAT_BYTES, sink->position);
          return TRUE;
        default:
          return FALSE;
      }
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
      return TRUE;
    case GST_QUERY_URI:
      if (GST_IS_URI_HANDLER (sink)) {
        gchar *uri;

        uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink));
        gst_query_set_uri (query, uri);
        g_free (uri);
        return TRUE;
      }
      return FALSE;
    default:
      return GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
  }
}


Compare with filesink which has in its gst_file_sink_query() method:

    case GST_QUERY_SEEKING:
      gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
      if (format == GST_FORMAT_BYTES || format == GST_FORMAT_DEFAULT) {
        gst_query_set_seeking (query, GST_FORMAT_BYTES, self->seekable, 0, -1);
      } else {
        gst_query_set_seeking (query, format, FALSE, 0, -1);
      }
      res = TRUE;
      break;

However, switching sound-juicer to using filesink is not enough to get the flac signature to be written :( 

gst-launch-1.0 filesrc ! flacparse ! flacdec !  flacenc !filesink does the right thing though, so I guess this is a bug related to flacenc being wrapped inside an encodebin. gst debug log has flacenc 
gstflacenc.c:974:gst_flac_enc_seek_callback: Seek to 26 succeeded
gstflacenc.c:1154:gst_flac_enc_write_callback:<flacenc1> Fixing up headers at pos=26, size=16

but this does not seem to translate to an updated header in the encoded flac file :(
Comment 7 Christophe Fergeau 2014-04-07 14:22:59 EDT
I've been able to reproduce this using (from gstreamer source)
 
gst-plugins-base/tests/examples/encoding -f audio/x-flac -a audio/x-flac  -o /home/teuf/output.flac file:///home/teuf/11k16bitpcm.wav

(wav file came from http://www.nch.com.au/acm/11k16bitpcm.wav linked from https://en.wikipedia.org/wiki/WAV but any random file should do the trick).

After that (metaflac comes with the 'flac' package)
$ metaflac --list --block-number=0 /home/teuf/output.flac
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4608 samples
  maximum blocksize: 4608 samples
  minimum framesize: 0 bytes
  maximum framesize: 0 bytes
  sample_rate: 11025 Hz
  channels: 1
  bits-per-sample: 16
  total samples: 0
  MD5 signature: 00000000000000000000000000000000


If instead I do things manually with:
gst-launch-1.0 filesrc location=/home/teuf/11k16bitpcm.wav ! wavparse !  flacenc ! filesink location=/home/teuf/output.flac


$ metaflac --list --block-number=0 /home/teuf/output.flac
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4608 samples
  maximum blocksize: 4608 samples
  minimum framesize: 214 bytes
  maximum framesize: 7700 bytes
  sample_rate: 11025 Hz
  channels: 1
  bits-per-sample: 16
  total samples: 152267
  MD5 signature: 7ad725dd59f9d1f4bf6d50cf80aee75d

I'll file a gstreamer bug for this tomorrow.
Comment 8 Sean Sheedy 2014-04-08 02:29:35 EDT
Christophe,

Excellent code sleuthing.  All the best.
Comment 9 Christophe Fergeau 2014-04-08 05:02:33 EDT
(In reply to Christophe Fergeau from comment #6)
> sound-juicer is using giosink, which does not handle SEEKING queries:
> [...] 
> Compare with filesink which has in its gst_file_sink_query() method:
> [...] 
> However, switching sound-juicer to using filesink is not enough to get the
> flac signature to be written :( 
> 

Rather than hardcoding the output sink, we probably can let gstreamer pick the 'best' one for us through:

 sink = gst_element_make_from_uri (GST_URI_SINK, outputuri, "sink", NULL);

It seems to be picking filesink for local files, and hopefully will use a different sink for non file:// URIs.
Comment 10 Fedora End Of Life 2015-05-29 05:03:20 EDT
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 11 Fedora End Of Life 2015-06-29 07:57:06 EDT
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.