Bump on this request.
There already appears to be ways of doing this using ffmpeg and VLC. This is a snapshot of the source code for another project out there called hdhomerunstreamserver on github (
https://github.com/zaren678/HdhomerunSt ... reamServer). Below is a snapshot of the code that does the heavy lifting. Keep in mind this is c# .Net, but should easily be adapted to Java.
private string buildVlcArguments()
{
StringBuilder cmdList = new StringBuilder();
//cmdList.Append("--file-logging ");
//cmdList.Append("--log-verbose=-1 ");
//cmdList.Append("--logmode=html ");
//cmdList.Append("--logfile=" + System.IO.Directory.GetCurrentDirectory() + "\\log.html ");
cmdList.Append("--no-crashdump ");
cmdList.Append("--sout-ffmpeg-strict=-2 ");
cmdList.Append("-V dummy ");
cmdList.Append("-I dummy ");
cmdList.Append("-vvv ");
cmdList.Append("udp://@:" + VideoInputPort + " ");
cmdList.Append("--audio-desync=-50 ");
//cmdList.Append("--network-caching=4096 ");
//cmdList.Append("--udp-caching=4096 ");
cmdList.Append("--no-sout-rtp-sap ");
cmdList.Append("--sout-rtp-caching=3000 "); //TODO supposedly should do something with this for different bitrates but not sure what yet
cmdList.Append("--sout-rtp-sdp=rtsp://:" + VideoOutputPort + "/stream.sdp ");
cmdList.Append("--sout-rtp-mp4a-latm ");
cmdList.Append("--sout-transcode-threads=" + Environment.ProcessorCount + " " );
cmdList.Append("--sout-transcode-high-priority ");
cmdList.Append("--sout-keep ");
cmdList.Append("--sout-transcode-venc=x264 ");
cmdList.Append("--sout-x264-profile=baseline ");
cmdList.Append("--sout-x264-level=3 ");
cmdList.Append("--sout-x264-keyint=50 ");
cmdList.Append("--sout-x264-bframes=0 ");
cmdList.Append("--no-sout-x264-cabac ");
cmdList.Append("--sout-x264-ref=1 ");
cmdList.Append("--no-sout-x264-interlaced ");
cmdList.Append("--sout-x264-vbv-maxrate=" + BitRate + " ");
cmdList.Append("--sout-x264-vbv-bufsize=" + Math.Round((decimal)BitRate / 2) + " ");
cmdList.Append("--sout-x264-aq-mode=0 ");
cmdList.Append("--no-sout-x264-mbtree ");
cmdList.Append("--sout-x264-partitions=none ");
cmdList.Append("--no-sout-x264-weightb ");
cmdList.Append("--sout-x264-weightp=0 ");
cmdList.Append("--sout-x264-me=dia ");
cmdList.Append("--sout-x264-subme=0 ");
cmdList.Append("--no-sout-x264-mixed-refs ");
cmdList.Append("--no-sout-x264-8x8dct ");
cmdList.Append("--sout-x264-trellis=0 ");
cmdList.Append("--sout-transcode-vcodec=h264 ");
cmdList.Append("--sout-transcode-vb=" + BitRate + " ");
cmdList.Append("--sout-transcode-vfilter=canvas ");
cmdList.Append("--canvas-width=" + ResH + " ");
cmdList.Append("--canvas-height=" + ResV + " ");
cmdList.Append("--canvas-aspect=" + ResH + ":" + ResV + " ");
cmdList.Append("--canvas-padd ");
//cmdList.Append("--canvas-pAppend ");
cmdList.Append("--sout-transcode-soverlay ");
cmdList.Append("--sout-transcode-aenc=ffmpeg ");
cmdList.Append("--sout-ffmpeg-aac-profile=low ");
cmdList.Append("--sout-transcode-acodec=mp4a ");
cmdList.Append("--sout-transcode-samplerate=44100 ");
cmdList.Append("--sout-transcode-ab=128 ");
cmdList.Append("--sout-transcode-channels=2 ");
cmdList.Append("--sout-transcode-audio-sync ");
cmdList.Append("--sout ");
cmdList.Append("#transcode{}:rtp{}");
System.Console.WriteLine(cmdList.ToString());
return cmdList.ToString();
}
Also, there is a Mac version of a realtime h.264 transcoder available here.
https://www.silicondust.com/forum2/view ... ng#p106710