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 335635 - Add an Ogg/Vorbis retagging element
Add an Ogg/Vorbis retagging element
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 0.10.11
Assigned To: Tim-Philipp Müller
GStreamer Maintainers
: 333468 (view as bug list)
Depends on: 337026
Blocks: 76524 339878
 
 
Reported: 2006-03-23 10:17 UTC by Alex Lancaster
Modified: 2006-10-03 11:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vorbistag element (8.19 KB, patch)
2006-03-31 10:50 UTC, James "Doc" Livingston
none Details | Review
test.c (2.41 KB, patch)
2006-03-31 10:53 UTC, James "Doc" Livingston
none Details | Review
fixed patch (8.05 KB, patch)
2006-04-01 04:21 UTC, James "Doc" Livingston
none Details | Review
working version (8.34 KB, patch)
2006-04-08 23:57 UTC, James "Doc" Livingston
none Details | Review
fixed test.c (2.67 KB, patch)
2006-04-08 23:59 UTC, James "Doc" Livingston
none Details | Review
Updated patch to CVS (8.33 KB, patch)
2006-04-15 03:43 UTC, Alex Lancaster
reviewed Details | Review
derive for vorbisparse (8.16 KB, patch)
2006-05-19 05:07 UTC, James "Doc" Livingston
none Details | Review
include start of tests (22.91 KB, patch)
2006-05-21 12:40 UTC, James "Doc" Livingston
none Details | Review
small fixes (22.82 KB, patch)
2006-05-24 06:38 UTC, James "Doc" Livingston
reviewed Details | Review
more small fixes (22.66 KB, patch)
2006-05-25 06:39 UTC, James "Doc" Livingston
none Details | Review
updated patch (22.67 KB, patch)
2006-09-29 13:20 UTC, James "Doc" Livingston
committed Details | Review

Description Alex Lancaster 2006-03-23 10:17:54 UTC
There is currently no way to rewrite tags in an OGG file in gst 0.10.  This is something that we would like to do in rhythmbox as we now have preliminary support for ID3 tag writing using "id3demux ! id3mux" (or "id3demux ! tagid3v2mux").
Comment 1 Alex Lancaster 2006-03-23 10:30:01 UTC
*** Bug 333468 has been marked as a duplicate of this bug. ***
Comment 2 James "Doc" Livingston 2006-03-31 10:50:17 UTC
Created attachment 62450 [details] [review]
vorbistag element

This patch (against -bad) adds an "vorbistag" element which modifies the vorbis comment header. Usage would be "oggdemux ! vorbistag ! oggmux".
Comment 3 James "Doc" Livingston 2006-03-31 10:53:20 UTC
Created attachment 62451 [details] [review]
test.c

Program to test the element, compilable with  "gcc `pkg-config --cflags --libs gstreamer-0.10 gstreamer-base-0.10 gstreamer-plugins-base-0.10" -o test test.c

Usage: ./test source.ogg dest.ogg artist foo album bar ...


If the oggmux element is removed, you get what appears to be a valid vorbis stream, but with the oggmux element in place you end up with a 30-something byte file. Buggered if I know why.
Comment 4 James "Doc" Livingston 2006-03-31 10:58:43 UTC
While I think of it, whatever causes the oggmux issue is probably what causes the same with "filesrc ! oggdemux ! oggmux ! filesink".
Comment 5 James "Doc" Livingston 2006-04-01 04:21:50 UTC
Created attachment 62509 [details] [review]
fixed patch

This version of the patch might actually compile.
Comment 6 James "Doc" Livingston 2006-04-08 23:57:54 UTC
Created attachment 62995 [details] [review]
working version

Using gst-plugin-base from cvs (to get the newer vorbis and ogg stuff) this now works well for me, modulo the known issues with oggmux taking bits off the end.
Comment 7 James "Doc" Livingston 2006-04-08 23:59:19 UTC
Created attachment 62997 [details] [review]
fixed test.c

Updated test app that uses vorbisparse so that things work properly. Compile with " gcc `pkg-config --cflags --libs gstreamer-0.10 gstreamer-base-0.10 gstreamer-plugins-base-0.10` -g -o test test.c"
Comment 8 Alex Lancaster 2006-04-09 00:18:14 UTC
(In reply to comment #6)
> Created an attachment (id=62995) [edit]
> working version
> 
> Using gst-plugin-base from cvs (to get the newer vorbis and ogg stuff) this now
> works well for me, modulo the known issues with oggmux taking bits off the end.

What exactly is the "known issue" with oggmux taking bits of the end?  Is there bug on this?  What exactly does oggmux do (when it is working properly), is the analogue of id3mux and what does it do wrong now?

Comment 9 James "Doc" Livingston 2006-04-09 00:29:46 UTC
(In reply to comment #8)
> What exactly is the "known issue" with oggmux taking bits of the end?

This is only second-hand, so I may have mis-understood, but it doesn't handle the end-of-stream condition properly. The result is the last small piece of audio go be missing. If you've ripped the ogg vorbis files with GStreamer they are probably "damaged" in this way already, so it wouldn't have any furthur effect.


> Is there bug on this?

No idea, it just got mentioned to me on irc.


> What exactly does oggmux do (when it is working properly), is the
> analogue of id3mux and what does it do wrong now?

Ogg is a container (like AVI, Quicktime, etc) and oggmux takes streams, such as Vorbis or Theora, and puts them into an ogg container. When you have "ogg" audio files, they are really a Vorbis stream in an Ogg container.
Comment 10 Alex Lancaster 2006-04-09 00:38:59 UTC
(In reply to comment #9)

> This is only second-hand, so I may have mis-understood, but it doesn't handle
> the end-of-stream condition properly. The result is the last small piece of
> audio go be missing. If you've ripped the ogg vorbis files with GStreamer they
> are probably "damaged" in this way already, so it wouldn't have any furthur
> effect.

Bleh.  Luckily I don't rip anything using gstreamer ;-)  After being burnt with the lame element messing up my ID3 tags and xing headers I stayed away from any gstreamer apps for ripping.

> > Is there bug on this?
> No idea, it just got mentioned to me on irc.

bug #337026
Comment 11 Alex Lancaster 2006-04-09 00:55:16 UTC
(In reply to comment #10)

> Bleh.  Luckily I don't rip anything using gstreamer ;-)  After being burnt with
> the lame element messing up my ID3 tags and xing headers I stayed away from any
> gstreamer apps for ripping.

Although ripping works fine in gstreamer 0.10 with ripping in RB, I hasten to add.  (Can't test newer sound-juicer on FC-4 because it requires GNOME 2.14).
Comment 12 Alex Lancaster 2006-04-10 04:22:08 UTC
(In reply to comment #10)

> > > Is there bug on this?
> > No idea, it just got mentioned to me on irc.
> 
> bug #337026

Actually, apparently that is a different (but related) bug, the truncation problem has actually been fixed in CVS by this change (didn't have a bug number):

2006-04-03  Michael Smith  <msmith@fluendo.com>

        * ext/ogg/gstoggmux.c: (gst_ogg_mux_queue_pads):
          Oggmux sucks.
          Make it suck slightly less by writing out the final page.
          Still can't encode a vorbis-in-ogg file correctly, though. 
Comment 13 Alex Lancaster 2006-04-15 03:08:40 UTC
(In reply to comment #6)
> Created an attachment (id=62995) [edit]
> working version
> 
> Using gst-plugin-base from cvs (to get the newer vorbis and ogg stuff) this now
> works well for me, modulo the known issues with oggmux taking bits off the end

Current patch doesn't apply against CVS of gst-plugins-bad, probably needs some autotools updates:

$ patch -p0 < gpbad-vorbistag.patch
patching file configure.ac
Hunk #1 FAILED at 650.
Hunk #2 FAILED at 854.
2 out of 2 hunks FAILED -- saving rejects to file configure.ac.rej
patching file ext/Makefile.am
Hunk #1 succeeded at 215 with fuzz 2 (offset 13 lines).
Hunk #2 FAILED at 270.
Hunk #3 FAILED at 291.
2 out of 3 hunks FAILED -- saving rejects to file ext/Makefile.am.rej
patching file ext/vorbistag/Makefile.am
patching file ext/vorbistag/vorbistag.c
Comment 14 Alex Lancaster 2006-04-15 03:43:34 UTC
Created attachment 63535 [details] [review]
Updated patch to CVS

This works for me.  Also preserves existing tags that aren't changed.
Comment 15 James "Doc" Livingston 2006-04-27 05:31:56 UTC
I've now got a working patch for Rhythmbox that uses this to add support for editing tags in Ogg Vorbis files (bug 339878).


Issues:

* What should the element do with tags sent down the pipeline? The docs don't seem to be clear on what to do, and what the merge-mode means, in a three-way merge of pipeline, internal, and application tags. Currently the element just ignore pipeline tags.

* What tests should be added for the element? A few possible ones spring to mind:
a) tagging an untagged vorbis stream,
b) removing tags from a tagged vorbis stream, and
c) retagging and tagged vorbis stream

In each of the cases checking that the tags in the output stream are correct.
Comment 16 Alex Lancaster 2006-05-04 10:02:12 UTC
This works for me, any chance that this might be committed so at least it can be tested in CVS -bad? (which doesn't seem very risky since it's both in CVS and in -bad).
Comment 17 Tim-Philipp Müller 2006-05-17 08:46:21 UTC
Very clean and nice code. Looks generally fine to me.

Some random thoughts though:

 - is there a particular reason why you've decided to go for an element
   that processes and retags a raw vorbis stream rather than one that
   operates on a raw ogg stream? (both have advantages/disadvantages,
   I was just wondering what your reasons where or if this has been
   discussed on IRC or elsewhere before).

 - if the element is to be implemented as a vorbis stream retagger
   maybe it should derive from the already existing vorbisparse
   element? There are extra things to consider, like stream
   header packets being part of the caps etc.
   (apologies if all that came up before and was rejected as
   an idea, I haven't been following this discussion up until now)

 - in the current implementation in gst_vorbis_tag_chain() new_buf
   should probably be stamped with the same values for timestamp /
   duration / offset / offset_end etc. as the incoming vorbis
   comments packet buffer.


> What should the element do with tags sent down the pipeline? The docs don't
> seem to be clear on what to do, and what the merge-mode means, in a three-way
> merge of pipeline, internal, and application tags. Currently the element just
> ignore pipeline tags.

I think that's okay, after all you get the upstream tags as part of the stream as a vorbis comments packet/header buffer. I'd just treat the existing tags as they are in the vorbis comment buffer the same way tag events are usually handled.


> What tests should be added for the element? A few possible ones spring to
> mind:
> a) tagging an untagged vorbis stream,
> b) removing tags from a tagged vorbis stream, and
> c) retagging and tagged vorbis stream
> 
> In each of the cases checking that the tags in the output stream are correct.

Sounds good.
 

Comment 18 James "Doc" Livingston 2006-05-17 10:15:10 UTC
(In reply to comment #17)
>  - is there a particular reason why you've decided to go for an element
>    that processes and retags a raw vorbis stream rather than one that
>    operates on a raw ogg stream? (both have advantages/disadvantages,
>    I was just wondering what your reasons where or if this has been
>    discussed on IRC or elsewhere before).

I don't think I'd had a real discussion about this with anyone.

My reasoning for operating on vorbis streams rather than Ogg streams was that I thought it would make it easier to support re-tagging Ogg files that aren't just a single Vorbis stream.


Applications use the current incarnation of the voristag element by creating a pipline with "src ! oggdemux    oggmux ! sink" and listening for oggdemux's pad-added signal. In response to the signal, it would look at the caps and plug the appropriate tagging element (vorbistag for Vorbis streams) between oggdemux and oggmux.

I thought that this should work for Ogg files with other (e.g. Speex) streams, if the appropriate tagging element was written, and maybe for Oggs with multiple vorbis streams. The above could probably be encapsulated in an "oggtag" element rather than every application, bonus points if it didn't hard-code the tagging elements.


>  - if the element is to be implemented as a vorbis stream retagger
>    maybe it should derive from the already existing vorbisparse
>    element? There are extra things to consider, like stream
>    header packets being part of the caps etc.
>    (apologies if all that came up before and was rejected as
>    an idea, I haven't been following this discussion up until now)

Currently vorbistag requries a vorbisparse element before it, to fix all that up. Deriving from vorbisparse is probably a better idea, I'll look into it.


>  - in the current implementation in gst_vorbis_tag_chain() new_buf
>    should probably be stamped with the same values for timestamp /
>    duration / offset / offset_end etc. as the incoming vorbis
>    comments packet buffer.

I'll look at fixing that too.
Comment 19 James "Doc" Livingston 2006-05-19 05:07:29 UTC
Created attachment 65806 [details] [review]
derive for vorbisparse

This patch makes vorbistag derive from vorbisparse, so application don't need to add a vorbisparse element to the pipeline. Since doing that requires vorbisparse.h, this patch is against -base not -bad.

I've also made it copy timestamps/offsets/et al, and fixed a small leak.
Comment 20 James "Doc" Livingston 2006-05-21 12:40:34 UTC
Created attachment 65937 [details] [review]
include start of tests

Adds the three tests mentioned above, and a documentation section.
Comment 21 James "Doc" Livingston 2006-05-24 06:38:10 UTC
Created attachment 66111 [details] [review]
small fixes

A few minor fixes.
Comment 22 Tim-Philipp Müller 2006-05-24 09:44:04 UTC
Looks great to me. Two minor nitpicks:

 - you can use gst_buffer_stamp() to transfer the stamps from one buffer
   to another.

 - you can probably get rid of the ogg_packet stuff and just check
   *GST_BUFFER_DATA(buf) directly.

Now we just need to make sure it's ok to commit this directly to -base ..
Comment 23 James "Doc" Livingston 2006-05-25 06:39:30 UTC
Created attachment 66168 [details] [review]
more small fixes

Now correctly clean up the vorbis stuff used to craft the setup and audio buffers, and include the above two suggestions.

Valgrind is reporting one memory leak for me, and I'm not sure what causes it:
==10135== 24 bytes in 2 blocks are definitely lost in loss record 2 of 24
==10135==    at 0x401B422: malloc (vg_replace_malloc.c:149)
==10135==    by 0x43A6FE1: g_malloc (gmem.c:131)
==10135==    by 0x43B5B84: g_slice_alloc (gslice.c:777)
==10135==    by 0x439D89C: g_list_prepend (glist.c:95)
==10135==    by 0x47AA0B1: gst_tag_to_vorbis_comments (gstvorbistag.c:385)
==10135==    by 0x47AA26D: write_one_tag (gstvorbistag.c:398)
==10135==    by 0x41BBE63: ??? (gsttaglist.c:795)
==10135==    by 0x41B6611: gst_structure_foreach (gststructure.c:800)
==10135==    by 0x41BBEBE: gst_tag_list_foreach (gsttaglist.c:820)
==10135==    by 0x47AA344: gst_tag_list_to_vorbiscomment_buffer (gstvorbistag.c:442)
==10135==    by 0x47A4B4A: gst_vorbis_tag_chain (vorbistag.c:148)
==10135==    by 0x41A9803: gst_pad_chain (gstpad.c:3221)
Comment 24 Tim-Philipp Müller 2006-06-19 16:14:06 UTC
This is currently blocking on the oggmuxer, which needs to be fixed to set the EOS flag correctly on the last ogg page (packet?) for each stream.

Comment 25 Alex Lancaster 2006-06-29 16:31:02 UTC
Ping?  Any chance that this could be committed soon?
Comment 26 James "Doc" Livingston 2006-06-30 02:54:37 UTC
As Tim said, this is blocked by bug 337026 (oggmux's EOS handling).
Comment 27 James "Doc" Livingston 2006-09-29 13:20:03 UTC
Created attachment 73634 [details] [review]
updated patch

Syncs patch to cvs.

Since the oggmux fix in now in cvs, it would be good if I could get this reviewed.  Since it derived from vorbisparse, it would need to go in -base (unless vorbisparse.h got exported).
Comment 28 John McCutchan 2006-10-01 21:40:40 UTC
Will this work on flac files with vorbis tags?
Comment 29 Tim-Philipp Müller 2006-10-03 09:09:49 UTC
> Will this work on flac files with vorbis tags?

It won't, no. A flac retagging element should be fairly easy to write though.


Comment 30 James "Doc" Livingston 2006-10-03 10:10:35 UTC
IIRC 0.8 had a "flactag" element that could probably be ported.
Comment 31 Tim-Philipp Müller 2006-10-03 11:57:54 UTC
Thanks for the patch, committed to CVS:

 2006-10-03  Tim-Philipp Müller  <tim at centricular dot net>

        Patch by: James "Doc" Livingston <doclivingston at gmail com>

        * ext/vorbis/Makefile.am:
        * ext/vorbis/vorbis.c: (plugin_init):
        * ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
        (vorbis_parse_parse_packet), (vorbis_parse_chain):
        * ext/vorbis/vorbisparse.h:
        * ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
        (gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
        (gst_vorbis_tag_parse_packet):
        * ext/vorbis/vorbistag.h:
          Add new vorbistag element which derives from vorbisparse
          and is essentially the same as well, only that it implements
          the GstTagSetter interface and can modify the stream's
          vorbiscomment on the fly (#335635).

        * tests/check/Makefile.am:
        * tests/check/elements/.cvsignore:
        * tests/check/elements/vorbistag.c: (setup_vorbistag),
        (cleanup_vorbistag), (buffer_probe), (start_pipeline),
        (get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
        (_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
          Add unit test for new vorbistag element.

with some minor changes: two fixes in the gobject macros, one in the boilerplate macro (we derive from GstVorbisParse, not GstElement), and I added a ::parse_packet vfunc to vorbis parse so we don't have to do the whole save-the-old-chain-function business.