Sunday, February 10, 2013

Frame Sizes, Bit Rates and Comparative File Sizes of HD Broadcast TV Transcoded to MPEG-4 with WinFF Presets

I’ve been testing combinations of ATSC and cable TV tuner sticks and related software for time-shifting broadcast TV and transcoding it to MPEG4 and MP4/H.264 files for playback on Microsoft Surface RT and Google Nexus 7 tablets, as well as MiniPC sticks with HDMI outputs, such as the CozySwan UG007.

imageMost ATSC TV tuner sticks, such as the Pinnacle/Hauppauge PCTV series, and their included personal video recorder (PVR) software, save broadcast TV programs in MPEG-2 transport stream *.ts files.

The full transcoding process involves these steps:

  1. Record ATSC/cable content to MPEG transport stream files.
  2. Transcode transport stream to MPEG-2 *.mpg files of common format profiles and frame sizes with source bit rates using Pinnacle TVCenter software or an equivalent utility.
  3. Edit programs to be archived with free trimming software, such as Mpg2cut2 to remove spurious leading and trailing footage.
  4. Transcode MPEG-2 to MPEG-4 or MPG4/.H264 *.mp4 files with the ffMPEG command-line tool or a GUI ffMPEG wrapper, such as WinFF.

For more information about ATSC TV tuner sticks, see the Using Pinnacle/Hauppauge Video Tuner/Decoders section of my First Look at the CozySwan UG007 Android 4.1 MiniPC Device post (updated 2/8/2013.)

ffMPEG offers almost infinite permutations and combinations of transcoding options. WinFF v1.4.2 and later provides the five built-in MPEG-4 presets with command-line parameters shown in the table below:

Preset Label/Name ffMPEG Command-Line Parameters
MP4 Fullscreen /
x264HQFS
-f mp4 -r 29.97 -vcodec libx264 -vf scale=640:480 -aspect 4:3 -flags +loop -cmp +chroma -deblock 0:0 -b:v 1250k -maxrate 1500k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me_method umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 2 -qdiff 4 -direct-pred 3 -wpredp 2 -rc_lookahead 50 -acodec libfaac -b:a 112k -ar 48000 -ac 2
MP4 Widescreen /
x264HQWS
-f mp4 -r 29.97 -vcodec libx264 -vf scale=704:384 -b:v 1250k -aspect 16:9 -flags +loop -cmp +chroma -deblock 0:0 -maxrate 1500k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me_method umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 2 -qdiff 4 -direct-pred 3 -wpredp 2 -rc_lookahead 50 -acodec libfaac -b:a 112k -ar 48000 -ac 2
MPEG-4 H.264 video (high quality) /
MPEG4VideoHQ
-crf 35.0 -vcodec libx264 -acodec libfaac -ar 48000 -b:a 128k -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 0 -qmax 69 -qdiff 4 -bf 3 -refs 5 -direct-pred 3 -trellis 1 -wpredp 2 -rc_lookahead 50 -threads 0
MPEG-4 H.264 video (very high quality) /
MPEG4VideoVHQ
-crf 25.0 -vcodec libx264 -acodec libfaac -ar 48000 -b:a 160k -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 0 -qmax 69 -qdiff 4 -bf 3 -refs 8 -direct-pred 3 -trellis 2 -wpredp 2 -rc_lookahead 60 -threads 0
MPEG-4 H.264 video (super high quality) /
MPEG4VideoSHQ
-crf 15.0 -vcodec libx264 -acodec libfaac -ar 48000 -b:a 192k -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 0 -qmax 69 -qdiff 4 -bf 8 -refs 16 -direct-pred 3 -trellis 2 -wpredp 2 -rc_lookahead 60 -threads 0

Notes:

  1. WinFF has similar presets specific to Google Android transcoding.
  2. ffMPEG won’t accept filenames with special characters, such as diacriticals.

To decode the parameter names, see the ffMPEG documentation’s Options settings here.

Following are the video properties for PBS’s Nova: Building Pharaoh's Chariot episode:

image

The trimmed file has a net length of 00:52:39. Following are its video properties, as well as those for the five transcoded files, as reported by the free MediaInfo application:

Preset Format Profile Bitrate Max. Bitrate Display File Size
Source MPEG2 Main@High 11.9 Mbps 24 Mbps 1080i 4.8 GB
x264HQFS AVC High@L3.0 1.250 kbps 1,500 kbps 640x480p 526 MB
x264HQWS AVC High@L3.0 1,250 kbps 1,500 kbps 704x384p 526 MB
MPEG4VideoHQ AVC High@L5.0 990 kbps   1080p 433 MB
MPEG4VideoVHQ AVC High@L5.0 3,712 kbps   1080p 1.5 GB
MPEG4VideoSHQ AVC High@L5.1 16.0 Mbps   1080p 6.3 GB

Following are Wikipedia’s descriptions of the above H.264/MPEG-4 AVC levels with maximum property values:

image

It’s clear from the table above that Level 5.1 is overkill for 1080i (and probably 1080p) source video. It appears to be intended for the new super-high resolution TVs with 4096x2304 (2304p) resolution. MPEG4VideoVHQ, which creates files about 1/3 the source MPEG file size, should be adequate for viewing with tablets, as well as most HDTV sets.

0 comments: