I'm using mediatomb to share my media files across my home LAN, and a friend pointed me at stream-chan which would stream live TV from my HDHomeRun via DLNA. Way cool! Except that the main endpoints in my network are phones and tablets, which are none too happy about trying to play mpeg2 streams, to say nothing of my poor gasping wifi network which ends up crippled due to the 30+ Mbps that a single stream wants to sustain. So clearly some transcoding was called for. I chose mp4 as most devices have hardware assist when decoding x264+mp3, so even the oldest and slowest would have at least a chance to play it.
The incantations for this were gleaned from all over the net and also avconv manpages. This being so, and with many non-obvious problems along the way, I figured sharing it here might be helpful to the world at large.
avconv -i - -codec:v libx264 -s vga -preset ultrafast -f mpegts -codec:a libmp3lame -ac 2 -y OUTFILE
So now, an explanation:
-i - means 'input from stdin' -codec:v libx264 means use the libx264 codec for video output -s vga means make vga-sized output (in a bid to lower computation cost) -preset ultrafast is an argument to the libx264 codec to tell it to be fast rather than accurate -f mpegts means output format of mpegts -codec:a libmp3lame means transcode to mp3 output -ac 2 means use the first two channels and drop the rest because x264 doesn't handle >2 audio channels -y means overwrite
After all that, it seems my ancient little NAS is too slow a machine to do realtime A/V transcoding. Ah well, at least I know how now - new hardware is a different issue. And maybe this will help someone!