Tag: video

  • iOS: Getting a Thumbnail for a Video

    iOS: Getting a Thumbnail for a Video

    smart phone taking a picture
    Credit: Pixabay / SplitShire

    Between various things being deprecated, and the new Photos framework (which looks cool but seemed a bit heavyweight for this purpose) finding this took me a while!

    When the image picker returns with a video it has a url in info[UIImagePickerControllerMediaURL]. Then we can use AVAsset and AVAssetGenerator to get a thumbnail.

    // Gets the asset - note ALAsset is deprecated, not AVAsset.
    AVAsset *asset = [AVAsset assetWithURL:mediaUrl];
    
    // Calculate a time for the snapshot - I'm using the half way mark.
    CMTime duration = [asset duration];
    CMTime snapshot = CMTimeMake(duration.value / 2, duration.timescale);
    
    // Create a generator and copy image at the time.
    // I'm not capturing the actual time or an error.
    AVAssetImageGenerator *generator =
        [AVAssetImageGenerator assetImageGeneratorWithAsset:asset];
    CGImageRef imageRef = [generator copyCGImageAtTime:snapshot
                                            actualTime:nil
                                                 error:nil];
    
    // Make a UIImage and release the CGImage.
    UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);
    
    // TODO: Do something with the image!

    Also useful when using the simulator: test videos. Download, open on the simulator, and then save via the share button as for images.

    This is something I was working on for Digital Fan Clubs.

  • Inspiring Educators

    sunflowers
    Credit: flickr / marcomagrini

    I’ve had a post in mind for a while now, about how I accidentally mis-branded myself as an educator, why that was a problem, and how I managed to turn it into a selling point.

    And then I watched the video embedded below. And it made me re-evaluate the value that I place on being an educator, and question why I don’t want to inspire the way that guy clearly does. Is it because of the lack of value society places upon educators? We pay them badly, and disparage with the expression “those that can’t, teach”. However, teachers unionize and resist attempts at making them improve and be accountable – enforcing every bad opinion (I read a great article I think in the NYT about this recently, but I can’t find it).

    If you check out Ken Robinson’s Ted Talk, perhaps the biggest reason not to be an educator is that you’re entering a fundamentally broken system. I remember school. I was good at it, but I didn’t enjoy it.

    But this guy… is passionate, inspirational, making a difference. So perhaps the next time you encounter an educator, instead of wondering what they couldn’t do, you might be meeting one of the – in my experience very few – who really, genuinely, believe they can.

  • Did You Know?

    The latest – 4.0 – is different and, I think, better, than the previous ones. Should give you something to think about today!

  • Great Debate: Is the Catholic Church a Force for Good?

    Sorry – I’m (very) atheist but mostly that remains off this blog. However earlier I saw an excellent debate featuring the awesome Christopher Hitchens and the wonderful Stephen Fry. It’s in 5 parts and it was annoying when the part finished at a climatic moment and I was trying to find the next one, so I thought I’d assemble it in one place before I linked to it.

    I think this debate is worth watching, whichever side you’re on, as it is a focused question and they’re debating the same question. Often when atheist meets religious, they’re talking about different things. That is not the case here. They also polled the audience before and after, and there was a massive change in opinion.

    Part 1: Archbishop and Christopher Hitchens

    Part 2: Christopher Hitchens and Ann Widdecombe

    Part 3: Ann Widdecombe and Stephen Fry

    Part 4: Audience Questions

    Part 5: Summary