Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

(raw) image transcoding

emm_is
2008-04-15
2013-05-30
  • emm_is
    emm_is
    2008-04-15

    Is there any way to transcode camera raw images (cr2, nef, dng). I have tried with little success to show thumbnails using dc

     
    • emm_is
      emm_is
      2008-04-15

      ...continued

      Is there any way to transcode camera raw images (cr2, nef, dng). I have tried with little success to show thumbnails/transcode using dcraw with this xml:

      ...
            <map from="cr2"  to="image/cr2"/>
      ...
            <transcode mimetype="image/cr2" using="cr2"/>
      ...
            <profile name="cr2" enabled="yes" type="external">
              <mimetype>image/jpg</mimetype>
              <accept-url>yes</accept-url>
              <thumbnail>yes</thumbnail>
              <resolution>1536x1024</resolution>
              <agent command="dcraw_out" arguments="%in %out"/>
              <buffer size="500000" chunk-size="131072" fill-size="262144"/>
            </profile>

      where dcraw_out is the script

      #!/bin/sh
      dcraw -e -c "$1" > "$2"
      date=`dcraw -i -v "$1" | grep Timestamp | awk '{print $2" "$3" "$4" "$5" "$6}'`
      echo $1 $2 >> log
      touch -d "$date" "$2"

      Likewise without thumbnails -- though having both a quick jpg extract thumbnail and a slow raw conversion access would be great.

       
    • Jin
      Jin
      2008-04-16

      <thumbnail>yes</thumbnail>
      <resolution>1536x1024</resolution>

      This will not work, DLNA specs that a thumbnail must not exceed the resolution of 160x160, even if your device is not DLNA capable it will still look at the resolution and show the thumbnail only if it fits into the designated UI area. So if you want thumbnails you must either check if there really is a thumbnail in the raw image (i.e. similar to exif thumbnails) and extract that, or you have to scale down the image.

      Transcoding as such should work, if in doubt test your script with FIFOs on the command line like it is described in the transcoding documentation.

      Also beware: if you do not use exec to execute the transcoding application we will not be able to kill it.

      Kind regards,
      Jin

       
    • emm_is
      emm_is
      2008-04-16

      I tested the script and it works fine with a fifo.

      However, my cr2 files are not being 'recognised' as image/jpg. They show up in the web browser as image/cr2 and the transcoding script is never executed. When testing, should clicking on the item in the web browser send the original or the transcoded version?

      > Also beware: if you do not use exec to execute the transcoding application we will
      > not be able to kill it.

      is this important for still images?

      Any thoughts gratefully received.

          <mappings>
            <extension-mimetype ignore-unknown="yes">
              <map from="jpg"  to="image/jpeg"/>
              <map from="cr2"  to="image/cr2"/>
            </extension-mimetype>
          ...
          </mappings>

        <transcoding enabled="yes">
          <mimetype-profile-mappings>
            <transcode mimetype="image/cr2" using="cr2-jpg"/>
          </mimetype-profile-mappings>

          <profiles>
            <profile name="cr2-jpg" enabled="yes" type="external">
              <mimetype>image/jpg</mimetype>
              <agent command="/opt/bin/dcraw_out" arguments="%in %out"/>
              <accept-url>no</accept-url>
              <first-resource>yes</first-resource>
              <hide-original-resource>yes</hide-original-resource>
              <buffer size="500000" chunk-size="131072" fill-size="262144"/>
            </profile>
          </profiles>
        </transcoding>

       
    • Jin
      Jin
      2008-04-17

      I missed one detail in your profile: <mimetype>image/jpg</mimetype>

      It should be image/jpeg

      Btw, you can not use the UI to test transcoding, the UI always delivers the original file.

       
    • emm_is
      emm_is
      2008-04-17

      Excellent, can transcode cr2 files to jpg (well actually, I opted to extract the high res embedded jpg for performance) and view them!

      However, the date reported in obj.meta[M_DATE] reports 'undefined'.

      I know that libexif barfs at cr2 files (though others don't, e.g. exiv2). However, obj.meta[M_DATE] does not seem to have backtracked to the file date, which would be something.

      Any thoughts?

       
    • Jin
      Jin
      2008-04-19

      Well - we get the DATE via libexif, so if libexif does not like the cr2 files, then you will not get the obj.meta[M_DATE] information. We don't set the file date there but the exif date.

      There was a request to add an obj.aux[DATE] which would represent the file date, I guess I could add that for the next release, this could be a workaround for your issue. And btw, please tell the libexif guys about the date problem with cr2 files, if they fix it - then it will work with MT.

      Another possibility would be to check if libextractor is able to extract what you need, then you could recompile MediaTomb with libextractor support instead of libexif support.

      Kind regards,
      Jin

       
    • emm_is
      emm_is
      2008-04-22

      Looking through the forums in libexif it seems as if they have been musing about TIFF (as I understand, the container for CR2; libexif fails on TIFFs too) support since 2005. I'll raise the issue but can't say I hold out much hope.

      obj.aux[DATE] would certainly be a general and practical fallback.

      I see that in you codebase is the beginnings of a libexiv2 interface, are you letting that whither or plan on growing it?

       
    • Jin
      Jin
      2008-04-22

      We did have exiv2 support in the beginning, then we noticed that the library was leaking memory, so we went for libexif and never looked back at exiv2. This was about 2 years ago, since then our exiv2 code has not been touched.

      Btw, if you recompile MediaTomb with libextractor support, then you could possibly solve this problem: as far as I know libextractor added exif support via exiv2.

      I do not really plan to revive the exiv2 code, especially since the way via libextractor is possible.

      Kind regards,
      Jin