Hi,
I also managed to get transcoding for ts (mpeg2video, mpeg2audio) -> ts (h264, ac3) and ts (h264, ac3) -> ts (h264, ac3) working by using gstreamer.
SW:
Raspberry Pi reference 2018-06-27 image
tvheadend 4.3-1273~g610c6fa74~raspbianstretch
gstreamer1.0-omx-rpi-config 1.10.4-1+rpt3
gstreamer1.0-omx-rpi 1.10.4-1+rpt3
Then I added a new stream profile (Configuration -> Stream) from MPEG-TS Spawn/built-in template and the following command line:
CMD:
gst-launch-1.0 fdsrc fd=0 ! decodebin name=decoder decoder. ! queue ! avenc_ac3 ! mpegtsmux name=mux ! fdsink fd=1 decoder. ! omxh264enc ! mux.
This profile can then be used in playlist's url by adding ?profile=transcoding. For example:
http://raspberrypi.lan:9981/playlist/channels?profile=transcoding
That's all.
The pipeline could be tuned further, but therefore I need to investigate on gstreamer's pipeline. For example program information could be added to the stream. The decodebin is used to transcode any source transparently. The fdsrc and fdsink elements won't produce any overhead by walking the network stack as it would with sources like souphttpsrc.
One error that occur is by stopping the playback. It seem the write pipe (stdout) is closed before fully empty. The error in tvheadend log is:
Aug 09 11:54:26 raspberrypi tvheadend[13380]: spawn: ERROR: from element /GstPipeline:pipeline0/GstFdSink:fdsink0: Could not write to resource.
Aug 09 11:54:26 raspberrypi tvheadend[13380]: spawn: Additional debug info:
Aug 09 11:54:26 raspberrypi tvheadend[13380]: spawn: gstelements_private.c(317): gst_writev_buffers (): /GstPipeline:pipeline0/GstFdSink:fdsink0:
Aug 09 11:54:26 raspberrypi tvheadend[13380]: spawn: Error while writing to file descriptor 1: Broken pipe
Another error relates to decoding mpeg2 with mmal. The log says:
Aug 09 11:53:45 raspberrypi tvheadend[13380]: spawn: mmal: mmal_vc_port_info_set: failed to set port info (2:0): EINVAL
Aug 09 11:53:45 raspberrypi tvheadend[13380]: spawn: mmal: mmal_vc_port_set_format: mmal_vc_port_info_set failed 0x6a018650 (EINVAL)
Aug 09 11:53:45 raspberrypi tvheadend[13380]: spawn: mmal: mmal_port_disable: port vc.ril.video_decode:in:0(MP2V)(0x6a018650) is not enabled
Aug 09 11:53:45 raspberrypi tvheadend[13380]: spawn: mmal: mmal_port_disable: port vc.ril.video_decode:out:0(0x6a018970) is not enabled
Aug 09 11:53:45 raspberrypi tvheadend[13380]: spawn: mmal: mmal_port_disable: port vc.ril.video_decode:ctr:0(0x6a018340) is not enabled
Maybe someone with rpi's mpeg license active could test the pipeline.
Cheers