private static bool GenerateThumbnail(string movieFilePath, byte[] thumbnailData) { bool _result = false; if (File.Exists(movieFilePath) && thumbnailData.Length != 0 && !string.IsNullOrEmpty(TemplateTempPath) && File.Exists(TemplateTempPath)) { string _templateFilename = Path.Combine(Path.GetDirectoryName(movieFilePath), DEST_FILE_NAME); try { File.Copy(TemplateTempPath, _templateFilename, true); _result = true; } catch { } if (_result) { _result = false; try { // open file IntPtr ptr = MP4V2Wrapper.MP4Modify(ref _templateFilename, 0, 0); if (ptr != IntPtr.Zero) { VBMP4Tags vb = new VBMP4Tags(); IntPtr tags = MP4V2Wrapper.VBMP4TagsAlloc(); MP4V2Wrapper.VBMP4TagsFetch(ref vb, ptr); MP4V2Wrapper.MP4TagsRemoveArtwork(tags, 0); MP4V2Wrapper.VBMP4SetCoverArt(thumbnailData, thumbnailData.Length); MP4V2Wrapper.MP4TagsStore(tags, ptr); MP4V2Wrapper.VBMP4TagsFree(ref vb); MP4V2Wrapper.MP4Close(ptr); _result = true; } } catch { } } } return(_result); }
internal static extern void VBMP4TagsFree(ref VBMP4Tags vb);
internal static extern void VBMP4TagsFetch(ref VBMP4Tags vb, IntPtr file);