Saturday, July 26, 2014

ffmpeg shrink file

I got some mts files that has not been uploaded for a long time, and got some time today to do that.  Windows Movie Maker is nice but one by one upload is just too slow.

Did some research, so finally find a way to do it in batch:

1.  loop all files do:  ffmpeg -i input.mts -fv scale=720:-1 output.mp4

2. drop all the mp4 to youtube :)

Thursday, June 5, 2014

CallContext ThreadStatic and SQL transactions

Recently we changed all our DB calls to async/await, as they are much more "thread" efficient.

And most of our old code, the SQL transactions runs on Thread local.  This won't work on async/awaits since now they are all interrupt like and can run on any thread. (we are not running with coordinated transactions for other reasons)

One of our guys implemented the new way initially with a static context, and we have to pass the context name to all calls.  When it is time for me to fix some of the code, it just feels so unnatural, no only there are a lot of code changes, if you miss one they won't be in the transaction.

And during the research, someone found CallContext, it works very much like Thread Statistic, and I think Microsoft copies it to new threads, so with simple fixes everything is working again (of course anything in a transaction is synchronized again without the DTC, that we can live with for now).

Sunday, February 23, 2014

c# async model

I dislike the async/await way of doing things, thinking that it made the developer's life harder, hiding the threading for no reason (not to mention the messed up stock). Recently one of our companies project was done with that, and I was able to make the project faster by remove some of the async stuff (there is an operation that writes on a single pipe, so I made it single threaded and used a queue instead of the async way of doing things). However during a recent discussion, one of my college's comment kind of wake me up a bit. He said the reason async/await is better is that internally it actually queue things up. Now that made sense. I think MS should make it even better, that is on any IO operation on a task, it should immediately queue it and make the thread available for next queued task, this way we can actually do away with the async/await mess and the complexity will be handled internally without any developer mangling.