Skip to content

h264 encoding for dlna(ln46a750)

How to convert HD(1080i/p 720p) content to something that plays on the DLNA client of the ln46a750 HDTV.

I recently spent time trying to convert recorded HDTV streams to a format playable with my Samsung TV’s DLNA client. I have been using a modified version of libdlna with ushare as the DLNA server. The TV spec lists a few resolutions that suport HD video

LN46a750 DLNA support
Extension Video codec Resolution Audio codec
avi Xvid 800X600 PCM
avi Xvid 800X600 ADPCM
avi H.264 MP 1920X1080 AC3
avi MPEG4 SP 800X600 PCM
avi MPEG4 SP 800X600 ADPCM
avi MPEG4 ASP 800X600 ADPCM
avi MJPEG 800X600 PCM
mp4 H.264 BP 1920X1080 AAC
mp4 H.264 MP 1920X1080 PCM
mp4 H.264 MP 1920X1080 AAC
mpg MPEG2 1920X1080 AC3
vro MPEG2 1920X1080 AC3
vob MPEG2 1920X1080 AC3

But in trying to use H264 with mp4 container I could never get the TV to accept the video codec. I even tried muxing with MP4Box When I used an avi container I could get video but no good audio. Finally I stumbled upon the possability of using mpegts stream as the container. This allows me to use mencoder/ffmpeg to encode/multiplex usable video.
I still have yet to try mp4creator to mux to mp4.

First Test: HD Clubmed Slideshow test2006.flv

Sometime back I created a 1920×1080, 1 fps, flv version of my CM2006 slideshow. I use this as an HD reference for conversion being carefull to create an appropriate new framerate as required. My first sucessfull test was using x264 defaults at a 24 fps frame rate.

ffmpeg -i Clubmed/test2006.flv -r 24000/1001 -ar 48000 -ab 224k -acodec ac3 -vcodec libx264 -b 1000k -crf 20 t2006.ts

I then tried various x264 “improvements” to check the abilities of the video decoder. It seems to be able to take high profile(8x8dct, etc), but for the moment I want faster encoding speed.

x264opts2="-coder 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 24 -keyint_min 24 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1"
ffmpeg -i Clubmed/test2006.flv -r 24000/1001 -ar 48000 -ab 224k -acodec ac3 -vcodec libx264 $x264opts2 -crf 25 t2006g.ts

This works but the file is huge 10min = 527MB. So I tryed changing the frame rate and got 15 fps to work, but the muxing rate seems to matter for the audio to be good. Also keyint, gop maybe a factor

x264opts2="-coder 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 24 -keyint_min 24 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1"
ffmpeg -i Clubmed/test2006.flv -r 15/1 -ar 48000 -ab 224k -acodec ac3 -vcodec libx264 $x264opts2 -crf 20 -b 1000k t2006j.ts

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: