Filter Mono with Tvheadend in E2
Added by Marcos Santos almost 2 years ago
Is there any way to pass only right or left channel audio through tvheadend in enigma2?
The issue is that the audio language on some channels in my country are not transmitted in different streams, one language is transmitted on the left channel and another on the right channel, as I play the channels on Kodi, I cannot change the audio balance, since Kodi doesn't work with Mono and that makes the audio come out double, in 2 languages.
What would be the best solution?
Replies (18)
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
If you have ffmpeg available you can fix the audio by creating a new channel from either the problematic channel or the service for that channel using the pipe:// url in a new mux within an IPTV network.
If you don't have an IPTV network create one under networks tab.
Go to Muxes tab and add new mux selecting the IPTV network.
The URL: becomes a pipe:///usr/bin/ffmpeg command with the necessary options to pass video (-c:v copy) then map only left or right channel to both channels. for reference see https://trac.ffmpeg.org/wiki/AudioChannelManipulation.
Here is an example of a fix for a channel that spread the audio over three different PIDs....
pipe:///usr/bin/ffmpeg -loglevel fatal -i http://127.0.0.1:9981/stream/channelnumber/10510 -filter_complex [0:1][0:2[0:3]amerge=inputs=3[a] -map 0:v -map [a] -ac 2 -c:v copy -c:a eac3 -mpegts_flags system_b -f mpegts pipe:1
You would need to figure out the correct ffmpeg options to select L or R and put that in both channels.
Once the mux is created it will scan and create a new service. Map that to a channel an from now on any device tuning that channel will only hear correct audio.
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Great alternative, I believe it might work!
Being quite honest, I don't have such advanced knowledge in programming, so I'm having trouble finding a way to install ffmpeg on my platform, I'm using enigma2 with a Cortex A53 processor, that is, armv8, so I don't know if it's possible to enable and what would be the way.
Do you know something about this?
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Apparently I managed to install ffmpeg, but I'm getting this message in the tvheadend log:
iptv: libav: Could not open input 'pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b mpegts pipe:1': Invalid data found when processing input
HTTP/1.1 HEAD (2) /imagecache/2935 -- 404
I tried to follow the guide you gave, but I don't know if I assembled the code correctly.
Do you have any idea what might be going on?
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
Edit the MUX that you added and where it says Use A/V Library: Set that to Do not use then save. Try tuning the channel again. Log should look more like this....
2022-12-14 12:49:59.835 spawn: Executing "/usr/bin/ffmpeg"
2022-12-14 12:49:59.835 subscription: 0249: "HTTP" subscribing on channel
You are also missing the format switch should be -f mpegts
pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1
I can't say for sure if that filter_complex is doing exactly what you want. It runs and the channel plays with a single mono audio channel. If that doesn't get you what you want perhaps a channel map might work.
To use only left channel...
-filter_complex "channelmap=map=FL-FL|FL-FR:channel_layout=stereo"
or only right channel....
-filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo"
Hopefully those are correct. I'm not great with ffmpeg filter.
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Thank you for your help!
I tried exactly the way you demonstrated, but for some reason tvheadend doesn't seem to receive the signal when I add the ffmpeg command:
pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1
the scan result presents the result "Fail" and the log looks like this:
2022-12-14 17:25:22.996 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1 - tuning on IPTV #1
2022-12-14 17:25:23.050 spawn: Executing "/usr/bin/ffmpeg"
2022-12-14 17:25:23.050 subscription: 0088: "192.168.1.58 [ XXXX | Kodi Media Center ]" subscribing on channel "TEST CHANNEL", weight: 100, adapter: "IPTV #1", network: "IPTV", mux: "pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1", provider: "FFmpeg", service: "Service01", profile="htsp", hostname="192.168.1.58", username="XXXX", client="Kodi Media Center"
2022-12-14 17:25:23.113 iptv: stdin pipe 87 unexpectedly closed: No data
2022-12-14 17:25:38.284 subscription: 0088: service instance is bad, reason: No input detected
2022-12-14 17:25:38.284 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1 - tuning on IPTV #2
2022-12-14 17:25:38.328 subscription: 0088: "192.168.1.58 [ XXXX | Kodi Media Center ]" subscribing on channel "TEST CHANNEL", weight: 100, adapter: "IPTV #2", network: "IPTV", mux: "pipe:///usr/bin/ffmpeg -loglevel fatal -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1", provider: "FFmpeg", service: "Service01", profile="htsp", hostname="192.168.1.58", username="XXXX", client="Kodi Media Center"
2022-12-14 17:25:38.328 spawn: Executing "/usr/bin/ffmpeg"
2022-12-14 17:25:38.382 iptv: stdin pipe 50 unexpectedly closed: No data
2022-12-14 17:25:41.777 http: 192.168.1.58: HTTP/1.1 HEAD (2) /imagecache/2935 -- 404
If I remove the ffmpeg command the scan result changes to OK and the channel opens:
http://192.168.1.55:9981/stream/channelnumber/659
Any idea what I'm doing wrong?
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
OK so looks like it's not an authorization issue. Probably need to debug the ffmpeg command line.
I assume you have ssh access to the device or some way to access terminal on it to run commands.
First of all make sure the path to ffmpeg is correct.
$ which ffmpeg
/usr/bin/ffmpeg
If it's not at /usr/bin then set the correct path in the pipe:// url.
If that is not it then try running your ffmpeg command directly without -loglevel fatal so you can see what is happening.
/usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts test.ts
If that creates a playable file from the channel then I'm not sure why the pipe fails in TVHeadend.
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Yes, I have ssh access, I access it via Putty.
I checked the ffmpeg path and everything is right, the return is:
which ffmpeg
/usr/bin/ffmpeg
But this command is not accepted, for some reason tvheadend does not save the configuration when I put the url exactly like this:
/usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts test.ts
Any idea?
EDIT
Excuse my ignorance, now I understand that it was supposed to run the above command in ssh.
The conversion seems to work when I type this command into putty:
/usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "[0:a]channelsplit =channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts test.ts
Shows that a video file is being converted
Couldn't it be a question of permission of the tvheadend user?
I don't really know how this works or how to give tvh different access permissions, but I did a quick search and found some people commenting something like this
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
No, that is not for TVHeadend url. Run that command directly in your Putty terminal ssh session. We want to see if the ffmpeg version installed on your device can accept that command.
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
I see your edited message now.
OK, I am puzzled. When I create a new mux on my machine using your pipe url only changing the -i http:// part to point to an actual channel on my system it scans and creates a service no problem. The service will play OK.
Double check for any typos in your pipe:// url. What version TVHeadend? Some older versions pipe:// would fail if there were extra white spaces in the url.
Not sure what's up. It should work.
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Well then, it's something really weird...
I even did another test, I changed the url and added the filter_complex parameter that you suggested earlier and the audio of the generated file was exactly the way I needed it, which made me very excited to solve the problem.
my pipe url is exactly like this:
pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1
My TVH is in this version: HTS Tvheadend 4.3-2040~g604d81a29-dirty
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
I copied that url and pasted into a new mux. It scanned in a service and plays fine. TCM I only hear one language. Sounds like Portuguese.
EDIT
I'm also on 4.3. My last pull was Nov 3, 2021
https://github.com/tvheadend/tvheadend/commit/c6bb43d8554643a772aa40c5e56904717b55a95f
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Did you copy it with the pipe?
Here it still doesn't work, if you copied it with the pipe and it worked there, the problem is probably in my version of tvheadend, isn't it?
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
Yes. I created a new MUX in TVHeadend using that exact url copy and pasted. Mux scanned OK. Created a service. Service plays OK. Didn't map to a new channel, but as long as the service is good that won't be an issue.
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
This is very strange... I believe that the problem is between tvheadend communication with ffmpeg, but how to solve it I have no idea...
Could it be something related to the tvh user?
Maybe the user that tvh uses by default is not able to access the ffmpeg folder
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Ron L wrote:
Yes. I created a new MUX in TVHeadend using that exact url copy and pasted. Mux scanned OK. Created a service. Service plays OK. Didn't map to a new channel, but as long as the service is good that won't be an issue.
I just got to how I update tvheadend and I realized that the install configure is like this:
./configure --prefix=/usr \
--enable-omx \
--enable-libav \
--enable-tvhcsa \
--enable-hdhomerun_client \
--enable-cwc \
--disable-dvben50221 \
--disable-avahi \
--disable-inotify \
--disable-v4l \
--disable-ffmpeg_static \
--disable-libx264_static \
--disable-libx265_static \
--disable-libvpx_static \
--disable-libtheora_static \
--disable-libvorbis_static \
--disable-libfdkaac_static \
--disable-ddci \
--disable-libx264 \
--disable-libx265 \
--disable-libopus
ffmpeg is disabled when installing tvheadend, but I don't know if it needs to be enabled since apparently ffmpeg is used through Debian and not tvheadend...
Is this ok or do I need to remove "--disable-ffmpeg_static \" from the code?
RE: Filter Mono with Tvheadend in E2 - Added by Ron L almost 2 years ago
That would seem unlikely. You could test it by using either sudo or su command in a ssh session to run ffmpeg as the same user that TVHeadend runs under.
On the debugging tab you can enable low level debug messages and trace that might help figure out issue, but I'm not sure the name of the subsystem exactly. I guess maybe spawn,mpegts
EDIT
I think ffmpeg config options affect only built in transcoding options in TVH. I don't think that would affect using spawn to run external ffmpeg. I am just guessing at this though. I really don't know for certain.
It does seem to be an issue with your TVH install so doing a fresh pull and compile might fix what ever is off. I believe you are running a dirty (modified) version so the developers can't help with that as they don't know what has been changed in your code tree.
EDIT again
I suppose there is no way to compile on Enigma is there?
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
Got it, I'll try to compile again and install.
If it doesn't work, I think I'll leave it at that, I already had so much headache having to reconfigure Tvheadend... I want to avoid having to do that again as much as possible.
As for compiling in Enigma, yes it is possible, I use these commands here:
cd /opt
rm -r tvheadend
git clone https://github.com/tvheadend/tvheadend.git
cd tvheadend
export CFLAGS="-march=armv7ve -mtune=cortex-a53 -mfloat-abi=hard -mfpu=neon-vfpv4 -mvectorize-with-neon-quad"
export CPPFLAGS=$CFLAGS
./configure --prefix=/usr \
--enable-omx \
--enable-libav \
--enable-tvhcsa \
--enable-hdhomerun_client \
--enable-cwc \
--disable-dvben50221 \
--disable-avahi \
--disable-inotify \
--disable-v4l \
--disable-ffmpeg_static \
--disable-libx264_static \
--disable-libx265_static \
--disable-libvpx_static \
--disable-libtheora_static \
--disable-libvorbis_static \
--disable-libfdkaac_static \
--disable-ddci \
--disable-libx264 \
--disable-libx265 \
--disable-libopus
make
make install
Thank you very much for all your help and attention!
RE: Filter Mono with Tvheadend in E2 - Added by Marcos Santos almost 2 years ago
I compiled the tvheadend again and it still doesn't work, I compiled it using the code I posted above, now I'm on HTS Tvheadend 4.3-2064~gabcb0ea67-dirty
My tvheadend log keeps showing up like this:
2022-12-15 00:46:26.999 mpegts: pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1 - tuning on IPTV #1
2022-12-15 00:46:27.009 subscription: 0009: "HTTP" subscribing to service "IPTV/pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 --filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1/TCM", weight: 100, adapter: "IPTV #1", network: "IPTV", mux: "pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1",
2022-12-15 00:46:27.010 spawn: Executing "/usr/bin/ffmpeg"
2022-12-15 00:46:27.030 iptv: stdin pipe 46 unexpectedly closed: No data
2022-12-15 00:46:43.009 subscription: 0009: service instance is bad, reason: No input detected
2022-12-15 00:46:43.009 mpegts: pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1 - tuning on IPTV #2
2022-12-15 00:46:43.020 subscription: 0009: "HTTP" subscribing to service "IPTV/pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 --filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1/TCM", weight: 100, adapter: "IPTV #2", network: "IPTV", mux: "pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1",
2022-12-15 00:46:43.020 spawn: Executing "/usr/bin/ffmpeg"
2022-12-15 00:46:43.040 iptv: stdin pipe 46 unexpectedly closed: No data
2022-12-15 00:46:47.820 webui: Stop streaming /stream/service/bed095263c541552f04ef73edf469970?ticket=f23fe58037ae1ccafb0a64a994bfb6d696527430, timeout waiting for packets
2022-12-15 00:46:47.820 subscription: 0009: "HTTP" unsubscribing, hostname="192.168.1.1", client="VLC/3.0.17.4 LibVLC/3.0.17.4"
2022-12-15 00:46:47.830 mpegts: pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1 - tuning on IPTV #1
2022-12-15 00:46:47.841 subscription: 000A: "HTTP" subscribing to service "IPTV/pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 --filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1/TCM", weight: 100, adapter: "IPTV #1", network: "IPTV", mux: "pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1",
2022-12-15 00:46:47.842 spawn: Executing "/usr/bin/ffmpeg"
2022-12-15 00:46:47.862 iptv: stdin pipe 46 unexpectedly closed: No data
2022-12-15 00:47:03.831 subscription: 000A: service instance is bad, reason: No input detected
2022-12-15 00:47:03.831 mpegts: pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1 - tuning on IPTV #2
2022-12-15 00:47:03.842 spawn: Executing "/usr/bin/ffmpeg"
2022-12-15 00:47:03.843 subscription: 000A: "HTTP" subscribing to service "IPTV/pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 --filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1/TCM", weight: 100, adapter: "IPTV #2", network: "IPTV", mux: "pipe:///usr/bin/ffmpeg -i http://192.168.1.55:9981/stream/channelnumber/659 -filter_complex "channelmap=map=FR-FL|FR-FR:channel_layout=stereo" -c:v copy -c:a mp2 -mpegts_flags system_b -f mpegts pipe:1",
2022-12-15 00:47:03.862 iptv: stdin pipe 46 unexpectedly closed: No data
2022-12-15 00:47:07.831 webui: Stop streaming /stream/service/bed095263c541552f04ef73edf469970?ticket=f23fe58037ae1ccafb0a64a994bfb6d696527430, timeout waiting for packets
2022-12-15 00:47:07.831 subscription: 000A: "HTTP" unsubscribing, hostname="192.168.1.1", client="VLC/3.0.17.4 LibVLC/3.0.17.4"
I think the best way is to wait and see if someone else who has already had this problem appears, from personal experience, testing things on tvheadend ends up causing a headache...