Blog Archives

microsoft expressions split clips into multiple files

open expressions (select transcode project)

file->new job

import file

select all your encoding video/audio settings

set your clips (click on location in timeline then on the “insert edit at playhead button”)

at this point you may have assumed clips would have encoded into separate files but this is not how expressions works inherently

save your job in case you make a mistake

right click on the job file in the media window at the bottom left and select duplicate

all of your video/audio encoding settings and clips you set will be duplicated

you can now duplicate as many times for as many clips as you have and remove the excess clips, using the clips tab (window->clips) to make sure you don’t make mistakes by referencing the start/stop times

click encode and watch as many files are queued!

References
http://msdn.microsoft.com/en-us/library/cc294634(v=expression.40).aspx
http://msdn.microsoft.com/en-us/library/cc294622(v=expression.40).aspx

Advertisements

asp .net grid control common gridview operations update edit cancel sort paging

There are many ways to accomplish the end result of what is displayed below.

To display multiple records of data on the same page, you may alternatively use Repeater (my favorite of the dataview controls), DataList or ListView (also great).

FormView and DetailsView are similar, but should be limited to smaller sets of data IMO or in a system where limited results are only displayed in this control after selection from a search or query filter.

The control on the HTML design side:

<asp:UpdatePanel ID="upnlContent" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
            <ContentTemplate>
  <div id="modal" style="display: none;" title="Application Message">
                    <asp:Label ID="lblError" runat="server"></asp:Label>
                </div>
<asp:GridView ID="gvDataList" runat="server" AllowPaging="True" OnRowEditing="gvDataList_EditRecord"
                        OnRowCancelingEdit="gvDataList_CancelRecord" OnRowUpdating="gvDataList_UpdateRecord"
                        AutoGenerateColumns="False" AllowSorting="true" PageSize="50" DataKeyNames="TreeID"
                        OnRowCommand="gvDataList_RowCommand" OnSorting="gvDataList_Sorting" OnPageIndexChanging="gvDataList_PageIndexChanging">
                        <AlternatingRowStyle BackColor="#EFEFEF" />
                        <Columns>
                            <asp:BoundField DataField="TreeID" HeaderText="TreeID" InsertVisible="False" SortExpression="TreeID"
                                ReadOnly="True" />
                            <asp:TemplateField HeaderText="ActiveStatus" SortExpression="ActiveStatus">
                                <ItemTemplate>
                                    <asp:Label ID="lblActiveStatus" runat="server" Text='<%# Eval("ActiveStatus")%>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:CheckBox ID="chkActiveStatus" runat="server" Checked='<%# Convert.ToBoolean(Eval("ActiveStatus")) %>'
                                        Enabled='<%# GetEditPermission("activestatus") %>' />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                <ItemTemplate>
                                    <asp:HyperLink ID="Name" runat="server" NavigateUrl='<%# "~/Pages/ExistingOrange.aspx?TreeID=" + Eval("TreeID")%>'>
                        <%# Eval("Name")%>
                                    </asp:HyperLink>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="tbtreename" runat="server" Text='<%# Eval("Name") %>' />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                                <ItemTemplate>
                                    <asp:HyperLink ID="hltreedescription" runat="server" NavigateUrl='<%# "~/Pages/ExistingOrange.aspx?TreeID=" + Eval("TreeID")%>'>
                        <%# Eval("Description")%>
                                    </asp:HyperLink>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="tbtreedescription" runat="server" Text='<%# Eval("Description") %>' />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Country" SortExpression="CountryID" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="lblCountryID" runat="server" Text='<%# getcountryname(Eval("CountryID"))%>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlCountryID" runat="server" Enabled='<%# GetEditPermission("allowregion") %>'
                                        DataSource='<%# countriesdropdown %>' DataTextField='Description' DataValueField="CountryID" />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="LastUpdated" HeaderText="Last Updated" SortExpression="LastUpdated"
                                ReadOnly="true" />
                            <asp:BoundField DataField="ExpirationDate" HeaderText="Expiration Date" InsertVisible="False"
                                SortExpression="ExpirationDate" ReadOnly="True" />
                            <asp:BoundField DataField="runcount" HeaderText="Pick Count" InsertVisible="False"
                                SortExpression="PickCount" ReadOnly="True" />
                            <asp:CommandField ButtonType="Button" EditText="Edit" UpdateText="Update" CancelText="Cancel"
                                HeaderText="Edit Row" ShowEditButton="true" />
                            <asp:ButtonField CommandName="NewOrange" ButtonType="Button" Text="Create" HeaderText="New Orange" />
                        </Columns>
                    </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>

The Events and functions attached to the control on the code behind side:

 private void LoadData(string sort, bool asc)
        {
            DAL.AC_DataClassesDataContext dc = new DAL.AC_DataClassesDataContext();
            var data = (from Trees in dc.Trees
                        join Oranges in dc.Oranges on new { TreeID = Trees.TreeID } equals new { TreeID = Convert.ToInt32(Oranges.TreeID) } into Oranges_join
                        from Oranges in Oranges_join.DefaultIfEmpty()
                        group new { Oranges, Trees } by new
                        {
                            Trees.TreeID,
                            Trees.ActiveStatus,
                            Trees.Name,
                            Trees.Description,
                            Trees.CountryID,
                            Trees.LastUpdated
                        } into g
                        select new
                        {
                            TreeID = (System.Int32?)g.Key.TreeID,
                            ExpirationDate = (System.DateTime?)g.Max(p => p.Oranges.PickDate),
                            PickCount = g.Count(),
                            ActiveStatus = (System.Byte?)g.Key.ActiveStatus,
                            g.Key.Name,
                            g.Key.Description,
                            g.Key.CountryID,
                            LastUpdated = (System.DateTime?)g.Key.LastUpdated
                        });

            data = data.OrderByField(sort, asc); //OrderByField uses dynamic linq library which is a free additional open source download from MS

                try
                {
                    data = data.Where(g => g.TreeID == Convert.ToInt32(ddlTreeIDs.SelectedValue));
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.ToString();
                    utils.ShowJQueryModal(this, ex); //static custom class I created to show dialog containing lblerror text
                }

            gvDataList.DataSource = data;
            gvDataList.DataBind();
            upnlContent.Update();
        }

        protected void gvDataList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "NewOrange")
            {
                string redirecturl = "~/Pages/NewOrange.aspx?TreeID={0}"; //this page should be pretty self explanatory
                string TreeID = (((GridView)sender).Rows[Convert.ToInt32(e.CommandArgument)].Cells[0]).Text;
                redirecturl = String.Format(redirecturl, TreeID);
                Response.Redirect(redirecturl);
            }
        }

		//example of a mechanism that can be used to change style or visibility of controls specific to user access
        public bool GetEditPermission(string permtype)
        {
            switch (permtype.ToLower())
            {
                case "other":
                    if (utils.usergroup == "admin")
                    {
                        return true;
                    }
                    else return false;
                case "allowregion":
                    if (utils.usergroup == "admin")
                    {
                        return true;
                    }
                    else return false;
                default:
                    return true;
            }
        }

        protected void gvDataList_UpdateRecord(object sender, GridViewUpdateEventArgs e)
        {
            DAL.AC_DataClassesDataContext dc = new DAL.AC_DataClassesDataContext();

            int TreeID, activestatus, CountryID;
            string Name, Description;

            try
            {
                TreeID = Convert.ToInt32(e.Keys[0]); //should be 0
                activestatus = Convert.ToInt32(((CheckBox)gvDataList.Rows[e.RowIndex].FindControl("chkActiveStatus")).Checked);
                Name = Convert.ToString(((TextBox)gvDataList.Rows[e.RowIndex].FindControl("tbName")).Text);
                Description = Convert.ToString(((TextBox)gvDataList.Rows[e.RowIndex].FindControl("tbDescription")).Text);
                CountryID = Convert.ToInt32(((DropDownList)gvDataList.Rows[e.RowIndex].FindControl("ddlCountryID")).SelectedValue);
            }
            catch (Exception ex)
            {
                //throw new Exception("Error retrieving grid values for update.");
                lblError.Text = "Error retrieving grid values for update. Details: " + ex.ToString();
                utils.ShowJQueryModal(this);
                upnlContent.Update();
                return; //unassigned local variables if this is skipped or exception now thrown
            }

            int result = dc.ExecuteCommand("update Trees set ActiveStatus={1}," +
           "Name={2},Description={3}," +
           "CountryID={4} where TreeID={0}",
                      TreeID, activestatus, Name, Description,
                      CountryID);

            if (result == 1)
            {
            }
            else
            {
                lblError.Text = "Record failed to update.";
                utils.ShowJQueryModal(this); //static custom class I created to show modal dialog containing lblerror text
            }
            gvDataList.EditIndex = -1;
            LoadData();
        }

        protected void gvDataList_EditRecord(object sender, GridViewEditEventArgs e)
        {
            gvDataList.EditIndex = e.NewEditIndex;
            LoadData();
        }

        protected void gvDataList_CancelRecord(object sender, GridViewCancelEditEventArgs e)
        {
            gvDataList.EditIndex = -1;
            LoadData();
        }

        private string ConvertSortDirectionToSql(SortDirection sortDirection)
        {
            string newSortDirection = String.Empty;

            switch (sortDirection)
            {
                case SortDirection.Ascending:
                    newSortDirection = "ASC";
                    break;

                case SortDirection.Descending:
                    newSortDirection = "DESC";
                    break;
            }

            return newSortDirection;
        }

        protected void gvDataList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvDataList.PageIndex = e.NewPageIndex;
            gvDataList.DataBind();
        }

        protected void gvDataList_Sorting(object sender, GridViewSortEventArgs e)
        {

            bool asc = true; //default to true per usual .net behavior
            if (ViewState[e.SortExpression] != null)
            {
                asc = (!(bool)ViewState[e.SortExpression]);
                ViewState[e.SortExpression] = asc;
            }
            else
            {
                ViewState[e.SortExpression] = true;
            }

            LoadData(e.SortExpression, asc);
        }

        //Show modal dialog using jquery. Requires javascript reference/link to jquery in the page.
        public static void ShowJQueryModal(Page PageInstance, Exception ex)
        {
            ClientScriptManager ClientScript = PageInstance.ClientScript;
            AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(PageInstance, PageInstance.GetType(), "preparemodal",
                "<script type=\"text/javascript\">$('#modal').dialog({autoOpen: false, modal: true });</script>", false);
            AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(PageInstance, PageInstance.GetType(), "loadmodal",
                "<script type=\"text/javascript\">$('#modal').dialog('open');</script>", false);
        }

Links and references to Dynamic LINQ may change over time (no pun intended).

At the time of writing this they can be found on MS and Scott Gu’s blog. If you cannot find it, send me an email and I can send it to you or you can refer to my post on OrderBy Column Name for the exact extension method.

How To Create Mac Icons using Pic2Icon and IconComposer

Using these steps any image you have can converted to an icon to use on Mac.

This following article is a condensed version of one found on MacInstruct. (see references below)

1) Download and Launch Pic2Icon.
2) Drag and drop image you want to create an icon of to the little window. Once it finishes processing, you should have a tiff file.
3) Download and Launch Icon Composer. It is part of the Apple Developer Tools.
4) Drag the tiff file to the bottom left 128×128 window in Icon Composer. Make sure you select “use scaled version” and “extract mask” until all windows are filled up.
5) Save with .icns extension and that’s it!

References
MacInstruct, http://www.macinstruct.com/node/59
Pic2Icon, http://www.download.com/Pic2Icon/3000-2256_4-8881968.html
Apple Developer Tools (Icon Composer), http://developer.apple.com/technologies/tools/

Convert Video to and from Adobe Flash .FLV format

The first three tools are Windows specific, with the last being cross-platform and especially necessary for linux users.

Super11
Link: http://www.videohelp.com/tools/SUPER
Not well known, but very robust software with good features and overall good functionality.

Riva FLV Encoder
Link: http://rivavx.com/?encoder
Similar to Any Video Converter (listed below). Depending on your needs, compare with Any and/or combine for best results. If you’re expecting some loss in quality and the end user won’t be watching playback in large streamed content then this or Any Video should work good for you.

Any Video Converter
Link: http://www.any-video-converter.com/products/for_video_free/
Good free product which gets the job done. A little less robust than Super in my opinion, and very similar to Riva as I stated above, but easier to use and probably better for quick youtube edits and uploads.

Adobe Media Encoder
Link: http://www.adobe.com/devnet/flash/quickstart/video_encoder.html
This product does the job pretty well, and I have personally used it for managing some quicktime and .flv video conversions. Visually it is more impressive than the others, but I found overall speed to actually be a bit slower after various testing. There were also some issues on .flv’s that didn’t play audio or video properly after conversion which seemed to work in other editors/converters. Especially interesting in these cases is the videos were output from another Adobe product.. Overall very surprised that Adobe didn’t come out on top with regards to their own platform.

FFmpeg
Link: http://www.ffmpeg.org/
FFmpeg is really at the core of much video conversion on the web, including some of those listed above. If you can master utilizing this tool from command line, or if you’re natively on linux, this is for you. Searching for ffmpeg GUI or frontend will also return some good results if you’re rather not run the commands manually.

Open TextEdit from command line on Mac OS X 10.6 Leopard

I found other articles online which mention editing ~/.bash.rc and ~./bash_profile but these are more work than necessary.

Simply use:

open -e [filename]

However, I noticed this functionality has some limitations concerning the files edited.

After trying the following commands on a secure file, it still would not save after making changes.

sudo open -e [filename]

sudo chmod 777 [filename]
sudo open -e [filename]

sudo chown -R [currentusershortname]:staff [filename]
sudo open -e [filename]

su
open -e [filename]

If you run into this issue where you cannot save after opening the file or any others with TextEdit, an awesome alternative and what I ultimately used is the tried and true vi.

See my “vi keyboard shortcuts quick reference” article for more info.

References
vi keyboard shortcuts quick reference, https://ronniediaz.com/2011/04/14/vi-keyboard-shortcuts-quick-reference