Scenario
I have a movie library which I'm looking to make streamable to my androidAndroid tablet using VLC for playback. I want to use H264+AAC for best possible visual quality over a mobile internet connection. I also wish to use a Matroska container which supports text subtitles as opposed to bitmap subtitles that MPEG2TS supports.
I have Mediatomb installed and UPnP is working as it should, I can stream video and audio fine without transcoding.
Problem
While I can transcode and downsample to MPEG2 just fine, but Both H264 I can transcode and MP2downsample to MPEG2 just fine. But H264 playback stops after 10-40 seconds (Exactlyon exactly the same place every time for any one video but different places for every video). The playback doesn't even start on VLC on the PC (stops after first frame).
Although I could go with MPEG2, I would prefer H264 as I'm going to be streaming to the tablet over 3G/4G and I'd like good video quality.
Configs
I'm using this script
#!/bin/bash
LINES=720
PRESET=veryfast
PROFILE=main
TUNE=zerolatency
AUDIO="-c:a libfaac -b:a 128k -ar 48000 -ac 2 -async 1"
# Works well
VIDEO="-c:v mpeg2video -b 8192k"
# Freezes after a few seconds seconds.
#VIDEO="-c:v libx264 -preset ${PRESET} -tune ${TUNE} -profile ${PROFILE}"
SUBTITLES="-c:s copy"
exec /usr/bin/ffmpeg -threads 2 -i "${1}" -filter:v scale=-1:720 $VIDEO \
$AUDIO $SUBTITLES -f matroska -y "${2}" &> /store/tmp/log
My mediatomb config with relevant section:
<profile name="h264stream" enabled="yes" type="external">
<mimetype>video/h264<x-matroska</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<sample-frequency>48000</sample-frequency>
<audio-channels>2</audio-channels>
<agent command="/etc/mediatomb/ffmpeg.sh" arguments="%in %out"/>
<buffer size="104857600" chunk-size="262144" fill-size="524288"/>
</profile>
Versions:
ffmpeg 1.0.7 built with gcc 4.6.3
libx264 0.0.2011220
Gentoo Linux 3.3.8 kernel
If I do tail -f /store/tmp/log
I can see that the FFMPEG process is still encoding even after the playback stops on the tablet. Infact, it's quite happily chewing away. And it is also encoding at a rate that is faster than the source material so it's not lagging behind. The playback on the tablet is smooth until it suddenly stops.
I've tried using different preset, profile and tune paramters to no avail, the time until it freezes seems to be inversely proportional to how fast the encoder is running (High encoding speed, short time to freeze)
I'm at my wits end, please help me! :3