I'm trying to set up a Raspberry 2 as a TvH transcoder right now.
With the help of gkreidl I got it totranscode DVB-S and DVB-T MPEG-2TS streams to H264 entirely on the gpu
This is possible with a command like this:
http-launch 3335 /video.mkv video/mkv verbose souphttpsrc location="http://10.0.55.8/stream/channelid/882609712?profile=MPEG2" ! tsdemux name=demux demux. ! queue ! mpegvideoparse ! omxmpeg2videodec ! videoconvert ! omxh264enc target-bitrate=2097152 control-rate=variable ! video/x-h264,stream-format=byte-stream,profile=high,width=720,height=576,framerate=25/1 ! h264parse ! matroskamux name=stream streamable=truedemux.audio_0101 ! queue ! mpegaudioparse ! mpg123audiodec ! audioconvert dithering=0 ! audio/x-raw,channels=2 ! voaacenc bitrate=65536 ! stream.
Important parts:
-use gkreidl's http-launch:
https://www.raspberrypi.org/forums/viewtopic.php?f=75&t=108700
-you have to get the audio stream pid and insert it in HEX as e.g demux.audio_200 etc..
This transcodes live MPEG2 with 720x575 to h264 in realtime, the pi stays idle at 90%!
I tried this as a input in TVH:
pipe://gst-launch-1.0 souphttpsrc location="http://10.0.55.10:9981/stream/channelid/882609712?profile=MPEG2" ! tsdemux name=demux demux. ! queue ! mpegvideoparse ! omxmpeg2videodec ! videoconvert ! omxh264enc target-bitrate=2097152 control-rate=variable ! video/x-h264,stream-format=byte-stream,profile=high,width=720,height=576,framerate=25/1 ! h264parse ! matroskamux name=stream streamable=true demux.audio_0101 ! queue ! mpegaudioparse ! mpg123audiodec ! audioconvert dithering=0 ! audio/x-raw,channels=2 ! voaacenc bitrate=65536 ! filesink location=/dev/stdout stream.
But unfortunately, it fails. I'm still figuring out where....
EDIT: I've read
pipe:// only accepts MPEG TS as source, so I changed to:
pipe://gst-launch-1.0 souphttpsrc location="http://10.0.55.10:9981/stream/channelid/882609712?profile=MPEG2" ! tsdemux name=demux demux. ! queue ! mpegvideoparse ! omxmpeg2videodec ! videoconvert ! omxh264enc target-bitrate=2097152 control-rate=variable ! video/x-h264,stream-format=byte-stream,profile=high,width=720,height=576,framerate=25/1 ! h264parse !mpegtsmux name=stream streamable=true demux.audio_0101 ! queue ! mpegaudioparse ! mpg123audiodec ! audioconvert dithering=0 ! audio/x-raw,channels=2 ! voaacenc bitrate=65536 ! filesink location=/dev/stdout stream.
But still doesn't work :/
EDIT 2:
This finally works like a charm :)
Outputs h264 AVC with AAC
I use this line:
pipe://gst-launch-1.0 souphttpsrc location="http://tvh:9981/stream/channelid/882609712?profile=MPEG2" \
! tsdemux name=demux demux. ! queue \
! mpegvideoparse ! omxmpeg2videodec ! videoconvert \
! omxh264enc target-bitrate=2097152 control-rate=variable \
! video/x-h264,stream-format=byte-stream,profile=high,width=720,height=576,framerate=25/1 \
! h264parse ! mpegtsmux name=stream demux.audio_0101 ! queue \
! mpegaudioparse ! mpg123audiodec ! audioconvert dithering=0 ! audio/x-raw,channels=2 ! voaacenc bitrate=65536 ! stream.
You need to create a MPEG2 profile on your source TVH to reduce the stream to 1 audio channel, otherwise gst fails (it needs the pid of the stream in HEX - audio_0101).
Transcoding works fine with multiple SD channels, HD transcoding works too!
The reason I use this is because my TVH server is a Synology NAS without transcoding video support,
I had a PC set up with WOL to act as a transcoder for now, but I love to use the PI now simply because it's on 24/7
(it's even driven from the NAS's usb port!)
The quality of the transcoded stream is quite acceptable for SD streams, but you notice some artifacts when watching HD.
(Software encoder may be better, but won't work with the pi :)