Tag Archives: video

How to Create iPad Formatted Videos Using HandBrake or FFMpeg

This is for those who may want to load a video onto their iPad with iTunes that isn’t in the correct format. I needed to do this because I was trying to put an iTunes University video on my iPad a couple days ago and iTunes complained that it wasn’t in the correct format for the iPad. I’m not sure exactly how that could be but I decided to take the opportunity to see if I could use HandBrake to easily convert it to an iPad friendly format. There is currently no pre-loaded iPad configuration for HandBrake like there is for the iPhone and iPod Touch so I created a few profiles that can easily be imported into HandBrake to output different sizes for the iPad:

Note that when you import videos using iTunes the iPad puts them in their own Videos app unlike the iPhone where they show up under the iPod app. You will want to find the Videos icon if you don’t already know where it is:

iPad Videos Screenshot

After verifying that the above 4×3 version worked for the iTunes University video, I went about testing it on a couple of other video formats. I tested the Big Buck Bunny video that I also used for my post on iPad video streaming in both 640×360 and 1024×576 output formats. Both resolutions looked great. In between these tests, I took a short break to play ?? ??, which provided a nice distraction. I also tried converting a DVD. If you decide to convert a DVD, you will probably want to turn on de-interlacing in HandBrake. You do that by first selecting the “Picture Settings” option:

HandBrake Picture Settings Screenshot

Then the filters tab and then select the type of de-interlace you want (fast, slow, slowest):

HandBrake DeInterlace Settings Screenshot

If you want to use FFMpeg to do all this you can. The following is a slightly modified version of the streaming command I’m using that will output a high bitrate version of the input video:

[code lang=”bash”]
ffmpeg -y -i input.avi -acodec aac -ar 48000 -ab 128k -ac 2 -s 1024×768 -vcodec libx264 -b 1200k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 1200k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 16:9 -r 30 -g 90 -async 2 output.mp4
[/code]

iPhone Windowed HTTP Live Streaming Server

After some more work I have enhanced the HTTP segmenter and uploading script from my iPhone streaming using AWS S3 and Cloudfront post. I added a number of features and tried to pull together some of the ideas from the comments. I’ll go over some of the features here and there is a full list of configuration options on the HTTP Live Video Streaming server project page and the source is available at the github repo.

So the major changes I have added are:

  • Yaml based configuration file. See the project page for a complete list of options.
  • Ability to transfer segments via copy, ftp, scp and s3.
  • Added the ability to do variable bitrate streams.
  • Added re-streaming support.
  • Added logging to a file and better debug output.

The variable bitrate streams where done by using pipes. I have done a large amount of testing via ITT Systems and it seems to work fairly well. I am able to stream a live HD video source into 3 different bitrates on a fairly old PC. Here are a couple clips I created to show the progressive enhancement in action, you probably want to switch to the HD version of the video and watch it full screen to get the bet view:


The configuration file will allow for any number of encoding options or transfer options and they can be put together in a number of different ways. Here are a couple examples of both, see the example configuration files for more.

An encoder example:

[code lang=”text”]
ep_128k:
ffmpeg_command: "ffmpeg -er 4 -y -i %s -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 320×240 -vcodec libx264 -b 128k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 128k -maxrate 128k -bufsize 128k -rc_eq ‘blurCplx^(1-qComp)’ -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 – | %s %s %s %s %s"
bandwidth: 128000
[/code]

Transfer configuration example:

[code lang=”text”]
ftp_dev:
transfer_type: ‘ftp’
remote_host: ‘192.168.1.1’
user_name: ‘user’
password: ‘pass’
directory: ‘html/streamingvideo’
[/code]

As a final note on changes, you are no longer able to use the segmenter without the script now really. If you want to do that you should use the original version of the segmenter source.

Please note that there is still some work to be done on the script to be complete. If I have time my next enhancement will be to add encryption and I will probably try to test builds on other distributions (maybe attempt to create segmenter binaries).

iPhone Windowed HTTP Live Streaming Using Amazon S3 and Cloudfront Proof of Concept

This post should be seen as a proof of concept. I’m working on creating a more concise and easier to use package of everything covered here but I felt like getting the knowledge out sooner rather than later would be of help to people looking for a way to do this. If you are interested keep an eye on the HTTP live video stream segementer and distributor project page as well as the github git repository.

After my post on using FFMpeg and an open source segmenter to create videos for the iPhone that conform to the HTTP live streaming protocol I decided to see if I could get the same segmenter to work on a live stream. As it turns out it didn’t take much modification to work.

If you are looking for something you can buy out of the box it appears that Akamai is doing iPhone video streaming now. I believe that the following solution using Amazon S3 and Cloudfront is probably as good as what Akamai can offer but it may be a better choice if you don’t want to have to maintain the configuration.

I put together a quick diagram of the process of transferring the video stream from source to final destination that will hopefully help people understand the full picture before jumping into the details:

HTTP Live Streaming Diagram

Continue reading

iPhone HTTP Streaming with FFMpeg and an Open Source Segmenter

With the release of the iPhone OS 3 update came the ability to do live streaming. There are a few types of streaming and each requires a certain encoding and segmentation. I’ve put together a cheat sheet on how I went about building a static stream using FFMpeg and an example segmenter that someone has posted. I’m not covering windowed streams in this post but if you are thinking about implementing a windowed stream the following will help you make a step in that direction and read about the Ethernet broadband benefits data so that it’s received in real-time.
Many professional broadcasters use live streaming software in addition to their online video platforms. Video streaming software typically provides tools for encoding, transcoding, adding on-screen effects, and more.

If you are looking for a no-frills, lightweight tool for broadcast live stream production and other video tasks, FFmpeg may be the software for you. You can use FFmpeg to create rtmp streams.

This feature-rich tool is primarily designed for advanced broadcasters. To help lower the learning curve, we’ve put together this guide to break down some of the code and functions available on FFmpeg. This FFmpeg tutorial will help you understand how it works.

In this post, we’ll cover how to set up FFmpeg on Linux, Mac, and Windows, and how to use FFmpeg to broadcast live streams.

Before getting started it is best to read over the Apple documentation on HTTP live streaming. Start out with the iPhone streaming media overview. This document covers the basics of how the streaming works and has some nice diagrams.

If you want even more information after reading the overview you can take a look at the HTTP Live streaming draft proposal that was submitted to the IETF by Apple. It covers the streaming protocol in complete detail and has examples of the stream file format for reference.

Once you are ready to start grab a decent quality video clip to use. If you don’t have one handy I found a nice list of downloadable HD clips in various formats for testing.

Continue reading

Converting videos (flv,wmv,avi,etc) into a format that will work with the iPhone/iTunes

I have had an iPhone for a while now and I keep running into instances where I want to have videos outside of youtube in some format that I can watch on the device. These include windows WMV formatted videos from PDC as well as FVL formatted videos on Flex. I finally broke down and found a working solution to convert pretty much any video into a iPhone/iTunes format using mencoder.

Continue reading