+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / Sitefinity Stopped Creating Video Thumbnails

Sitefinity Stopped Creating Video Thumbnails

12 posts, 0 answered
  1. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    10 May 2010
    Link to this post
    Since I moved my Sitefinity site from my local machine to our development server, it will no longer generate thumbnails for uploaded videos. I copied the database (using SQL backup and restore) from my local installation to the development server when we did the migration. Videos that I uploaded on my local installation have thumbnails, are still in the database, and show up on the development site without a problem. However, when I upload a video on the development server, the area above the name of the video, in the Library Thumbnail Listing, is blank. If I switch it to List view, I get the same thing -- no thumbnail.

    Based on the upload folder location in the code snippet on this post, I tried adding full permissions to the App_Data and App_Data\Temp folders for IUSR, ASPNET, NETWORK SERVICE, and IIS_WPG and none of those worked. I even tried one of the videos that previously generated a thumbnail. I uploaded the same video (.wmv) to a new Library, and it would not generate a thumbnail. Is this just a configuration problem?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    10 May 2010
    Link to this post
    Hi VectorLord,

    Could you verify that the you have AspNetHostingPermission - PermissionState.Unrestricted? The thumbs for video are generated only in full trust.
    Another reason is that the worker process cannot create temp directory in App_Data folder due to insufficient permissions.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    10 May 2010
    Link to this post
    I am unfamiliar with where this is set: AspNetHostingPermission - PermissionState.Unrestricted.

    Also, directory creation is not an issue because it already exists (copied over from my local copy most likely).

    Thanks.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    10 May 2010
    Link to this post
    Hi VectorLord,

    Do you run the website in full trust on the new server? It is obvious that the problem comes from some server settings, since the thumbs are generated locally.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    11 May 2010
    Link to this post
    I tried this...

    1. I executed 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\\\COMPUTERNAME\SHARENAME\*" FullTrust -exclusive on' in a command prompt on the server (substituting computername and sharename appropriately, of course).

    2. I made the Application Pool Identity user an admin on the server.

    3. I added the following to the system.web section of the site's web.config...
    <securityPolicy>
      <trustLevel name="Full" policyFile="internal" />
    </securityPolicy>

    None of these solved the thumbnail problem. :(

    VectorLord
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 May 2010
    Link to this post
    Hello VectorLord,

    Check whether there is a record about the thumb image in [sf_CmsContentThumbnail]

    SELECT * FROM [CMDEV3].[dbo].[sf_CmsContentThumbnail] where Title='NAME OF YOUR CONTENT ITEM - SEARCH BY NAME!'

    If there is a record the problem could be in some handler. Do you have the same problem when you upload images  or the issue is related only to video files?

    Make sure that you have Interop.DexterLib.dll in your bin folder.

    You could use the code below to narrow down the issue to zero. The code generates thumb for a given content item, so you could see whether it fails somewhere at your end. Replace the variables with the relevant data for your IContent and ILibrary.

    void Button2_Click(object sender, EventArgs e)
        {
     
               var libManager = new LibraryManager("Libraries");
                ILibrary vl = libManager.GetLibrary("video");
                IContent c = libManager.GetContent(new Guid("d009e249-3522-4d2c-9fc3-2f4841be8ca9"));
                byte[] byteArray = (byte[])c.Content;
                Stream s = new MemoryStream(byteArray);
                TestThumb(s, vl, c);
        }
     
     
     
     
     
        public void TestThumb(Stream data, ILibrary lib, IContent cnt)
        {
     
            var libManager = new LibraryManager("Libraries");
            IContent currentItem = null;
            ILibrary selectedLibrary = null;
     
            selectedLibrary = lib;
            currentItem = cnt;
     
            if (currentItem.MimeType.StartsWith("video", true, CultureInfo.InvariantCulture) &&
                        (selectedLibrary.TypeName == LibraryInfo.Library_Video_Name || selectedLibrary.TypeName == LibraryInfo.Library_Custom_Name))
            {
                bool fullTrust = System.Security.SecurityManager.IsGranted(new AspNetHostingPermission(PermissionState.Unrestricted));
                if (fullTrust)
                {
                    string baseDir = System.AppDomain.CurrentDomain.BaseDirectory + "App_Data\\Temp\\";
                    string currentItemId = currentItem.ID.ToString().Replace("-", string.Empty);
       
                    string videoFile = baseDir + currentItemId + ".video";
                    string imageFile = baseDir + currentItemId + ".jpg";
     
                    try
                    {
                
                        if (!Directory.Exists(baseDir))
                            Directory.CreateDirectory(baseDir);
     
                        using (FileStream videoWriterStream = new FileStream(videoFile, FileMode.OpenOrCreate, FileAccess.Write))
                        {
     
                            StreamHelper.CopyStream(data, videoWriterStream, true, libManager.Provider);
                        }
     
                        Type type = Type.GetType("DexterLib.MediaDetClass, Interop.DexterLib");
                        object instance = Activator.CreateInstance(type);
     
                        PropertyInfo fileNameInfo = type.GetProperty("Filename");
                        fileNameInfo.SetValue(instance, videoFile, null);
     
                        PropertyInfo currentStreamInfo = type.GetProperty("CurrentStream");
                        currentStreamInfo.SetValue(instance, 0, null);
     
                        MethodInfo writeBitmapBitsInfo = type.GetMethod("WriteBitmapBits");
                        object[] parameters = new object[] { 0, 640, 480, imageFile };
                        writeBitmapBitsInfo.Invoke(instance, parameters);
     
                        using (FileStream imageStream = new FileStream(imageFile, FileMode.Open, FileAccess.Read))
                        {
                            byte[] thumbData = StreamHelper.ReadToEnd(imageStream, false);
                            currentItem = SaveThumbnail("video/x-ms-wmv", currentItem, thumbData);
                            imageStream.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        // do nothing.
                    }
                    finally
                    {
                        // clean up.
                        if (File.Exists(videoFile))
                            File.Delete(videoFile);
                        if (File.Exists(imageFile))
                            File.Delete(imageFile);
                    }
                }
            }
     
        }
     
        private IContent SaveThumbnail(string mimeType, IContent currentItem, byte[] thumbData)
        {
            var cntManager = new ContentManager("Libraries");
            string name = (string)currentItem.GetMetaData("Name");
            IThumbnail t = cntManager.AddThumbnail(currentItem, thumbData, mimeType, ".jpg", name, true);
            cntManager.SaveThumbnail(t);
            currentItem = cntManager.GetContent(currentItem.ID);
            cntManager.SaveContent(currentItem);
            return currentItem;
        }
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    11 May 2010
    Link to this post
    Well...

    1. The query is returning a NULL result set, so it's not making it into the database.

    2. Interop.DexterLib.dll is in the bin folder.

    3. Thumbnails for images work just fine.

    4. I tried creating a test page with your code inside a button click event; however, I could not find StreamHelper in any of the Telerik DLLs. I used Object browser to search them all, including Telerik.Cms.Engine.dll, with no luck. I have version 3.7 of Sitefinity installed. When I searched the DLLs in the Sitefinity install folder in C:\Program Files\, I couldn't find it in there either. I assume, if similar code is used in the upload process, this could be the point of failure.

    VectorLord
  8. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    24 May 2010
    Link to this post
    I still have not found a resolution to this problem because I've been working on other areas. However, please refer to my previous post to see the results of my last attempt. Do you have any ideas beyond those you offered before?

    My fall-back plan is to simply make a static HTML page of thumbnails that link to the videos. This page is not updated on a regular basis, so that would be sufficient for the near future; on the other hand, I would like to have the list automated so we don't add videos a year from now and then wonder why it's not updating because we've forgotten about the work-around.

    Thanks,
    VectorLord
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 May 2010
    Link to this post
    Hello VectorLord,

    StreamHelper is a class used in Sitefinity 3.7. You could remove the references and try the code I sent you. I do not see any other possible reason for not generating the thumbs.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. Cagri Karahan
    Cagri Karahan avatar
    2 posts
    Registered:
    25 Sep 2012
    25 Sep 2010
    Link to this post
    I have the same problem,

    I tried every way you tried but still does not work!

    Can you help?
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    26 Sep 2010
    Link to this post
    Hello Cagri,

    Check this post Video Thumbnail issue when moving to WS2008 and IIS7

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    27 Sep 2010
    Link to this post
    Cagri,
        Unfortunately, we never got this resolved. We resorted to using a static Generic Content block with our manually generated thumbnails laid out in a table and just linked to the video files. Not the ideal solution, but uploading videos is a rare occasion for us, so it's not that big of a deal.

        BTW, we're running Sitefinity 3.7.2022 on Win 2003/IISv6.0.

    VectorLord
Register for webinar
12 posts, 0 answered