Video to jpeg: embedding timecode into the jpegs

Graham Leggett minfrin at sharp.fm
Mon Aug 17 17:34:08 PDT 2015


On 05 Aug 2015, at 1:45 AM, Thiago Santos <thiagoss at osg.samsung.com> wrote:

> gst-launch-1.0 won't push tags for you automatically.
> 
> gst-launch-1.0 videotestsrc num-buffers=1 ! jpegenc ! taginject tags="datetime=2015-05-05" ! jifmux ! filesink location=/tmp/test.jpg
> 
> This will save a single jpeg image with the datetime tag but you can't change the tags value from gst-launch-1.0 so you need to write an application to be able to change it for each buffer.
> 
> Don't use taginject in your application, it is not meant for that. Just use a probe and events or the tagsetter interface as I suggested.

What I’ve done so far is put together a plugin that will count frame numbers and place them in the taglist by hooking into transform_ip.

I am getting some very confusing behaviour though. The variable videotag->image_number increments once per frame as I expect it to, but at the point where the EXIF code is written to the jpeg the value in the taglist is suddenly 1 on every frame.

Am I using the correct API to set the tag?

First, we fire off an event containing a tag with the number 432 in it as follows:

Breakpoint 4, gst_video_tag_transform_ip (trans=0x1f0090, buf=0x6b9510d8)
    at gstvideotag.c:195
195	{
(gdb) next
196	  GstVideoTag *videotag = GST_VIDEO_TAG (trans);
(gdb) 
progressreport2 (00:21:10): 17 seconds
199	  GValue val = G_VALUE_INIT;
(gdb) 
201	  GST_DEBUG_OBJECT (videotag, "transform_ip");
(gdb) 
203	  taglist = gst_tag_list_new_empty ();
(gdb) 
205	  g_value_init (&val, G_TYPE_UINT);
(gdb) 
206	  g_value_set_uint (&val, videotag->image_number++);
(gdb) 
209	        GST_TAG_IMAGE_NUMBER, &val);
(gdb) print val
$13 = {g_type = 28, data = {{v_int = 432, v_uint = 432, v_long = 432, 
      v_ulong = 432, v_int64 = 432, v_uint64 = 432, v_float = 6.05360937e-43, 
      v_double = 2.1343635900341851e-321, v_pointer = 0x1b0}, {v_int = 0, 
      v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, 
      v_float = 0, v_double = 0, v_pointer = 0x0}}}
(gdb) next
208	  gst_tag_list_add_value (taglist, GST_TAG_MERGE_REPLACE,
(gdb) 
211	  g_value_unset (&val);
(gdb) 
213	  gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (videotag),
(gdb) 
216	  return GST_FLOW_OK;
(gdb) 
217	}

Later on the tag written above is serialised as an EXIF tag, however mysteriously the tag has taken on the value “1”:

Breakpoint 2, write_exif_integer_tag_from_taglist (writer=0x6eafcf38, 
    taglist=0x7130ba30, exiftag=0x7651ffdc) at gstexiftag.c:1031
1031	{
(gdb) next
1033	  guint32 num = 0;
(gdb) 
1034	  gint tag_size = gst_tag_list_get_tag_size (taglist, exiftag->gst_tag);
(gdb) 
1036	  if (tag_size != 1) {
(gdb) 
1041	  value = gst_tag_list_get_value_index (taglist, exiftag->gst_tag, 0);
(gdb) 
1044	  switch (G_VALUE_TYPE (value)) {
(gdb) print *value
$14 = {g_type = 28, data = {{v_int = 1, v_uint = 1, v_long = 1, v_ulong = 1, 
      v_int64 = 1, v_uint64 = 1, v_float = 1.40129846e-45, 
      v_double = 4.9406564584124654e-324, v_pointer = 0x1}, {v_int = 0, 
      v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, 
      v_float = 0, v_double = 0, v_pointer = 0x0}}}

Can anyone see where I have gone wrong?

Regards,
Graham
—



More information about the gstreamer-devel mailing list