Forums » Tutorial and setups »
having issue with piping bash script on tvheadend on synology nas
Added by Ryan Gong over 7 years ago
Thanks for the wonderful program first of all, so let me get to the point.
In mux, i can add a pipe command like this and mux will generate service and it's watchable.
pipe:///usr/local/ffmpeg/bin/ffmpeg -i INPUT_LINK -vcodec copy -acodec copy -f mpegts pipe:1
The same, I put this command in a bash script like this named /volume1/appdata/t.sh:
#!/bin/bash /usr/local/ffmpeg/bin/ffmpeg -i INPUT_LINK -vcodec copy -acodec copy -f mpegts pipe:1
then make it executable using:
chmod 755 /volume1/appdata/t.sh
I test the script using stdout and will generate video file.
then pipe in mux like this:
pipe:///volume1/appdata/t.sh
when running the mux, it will not generate anything, just says no data. here's the log
2017-06-14 14:25:42.284 spawn: Executing "/volume1/appdata/t.sh" 2017-06-14 14:25:42.284 subscription: 0019: "HTTP" subscribing to mux "test", weight: 10, adapter: "IPTV", network: "test", service: "Raw PID Subscription", hostname="10.0.0.119", client="NSPlayer/7.10.0.3059" 2017-06-14 14:25:42.300 iptv: stdin pipe unexpectedly closed: No data 2017-06-14 14:25:58.273 subscription: 0019: service instance is bad, reason: No input detected
This is on synology ds916+, with HTS Tvheadend 4.3.28042017
I suspect that it can not execute because some kind of permission issue, but I have also use chown to make internal user cs-tvheadend-testing as the owner of t.sh, and put it under tvheadend home folder and still no data.
Because this NAS support hardware accel, so I can use the following command with very fast encoding speed, about 170fps
/volume1/@appstore/VideoStation/bin/ffmpeg-vaapi -loglevel fatal -flags +global_header -vaapi_device "/dev/dri/card0" -hwaccel vaapi -hwaccel_output_format vaapi -i INPUT_LINK -c:v h264_vaapi ts.mp4
however, if pipe it, not even in a bash script, just pipe it like this:
pipe:///volume1/@appstore/VideoStation/bin/ffmpeg-vaapi -loglevel fatal -flags +global_header -vaapi_device "/dev/dri/renderD128" -hwaccel vaapi -hwaccel_output_format vaapi -i INPUT_LINK -c:v h264_vaapi -f mpegts -tune zerolatency pipe:1
The error is that somehow, tvheadend can not access dev/dri/renderD128, while command line can,
2017-06-15 08:57:38.617 spawn: [AVHWDeviceContext @ 0x3381580] No VA display found for device: "/dev/dri/renderD128". 2017-06-15 08:57:38.617 spawn: [vaapi @ 0x17daa50] Failed to create a VAAPI device 2017-06-15 08:57:38.618 iptv: stdin pipe unexpectedly closed: No data
and that's why i think there's some king of permission issue.
Could anyone please help and see how to resolve this?
Thanks.
Replies (4)
RE: having issue with piping bash script on tvheadend on synology nas - Added by Robert Cameron over 7 years ago
What user are you running the command line version from? Is this the same user that Tvheadend is running as? What are the permissions of your DRI devices? Does the user that Tvheadend runs as have permissions to access the DRI device?
Also, the -tune
options in ffmpeg are for the libx264 encoder, and have no effect on the h264_vaapi encoder.
RE: having issue with piping bash script on tvheadend on synology nas - Added by Ryan Gong over 7 years ago
Thanks for the reply.
I was using the command line as root for hardware encoding, and i can't get it work with admin account. I'm not sure what are the steps to add this permission to the tvheadend user...
Can you share some suggestions please?
RE: having issue with piping bash script on tvheadend on synology nas - Added by Ryan Gong over 7 years ago
Robert Cameron wrote:
What user are you running the command line version from? Is this the same user that Tvheadend is running as? What are the permissions of your DRI devices? Does the user that Tvheadend runs as have permissions to access the DRI device?
Also, the
-tune
options in ffmpeg are for the libx264 encoder, and have no effect on the h264_vaapi encoder.
ok, here is what i have tried and all of them produce the same result:
In synology nas, i modified the /etc/shadow file so that sc-headend-testing user have the same information as root; tested it
then I go into /var/packages/tvheadend-testing/conf folder, modify the privilege all user to root, tested it
Then i go into /var/packages/tvheadend-testing/scripts folder, modify start-stop-status so all sc-user and legacy user set to root, tested it.
After all of the above does not work,
then I stop the package installed and manually start the tvheadend using the following command as root:
/usr/local/tvheadend-testing/bin/tvheadend -f -u root -c /usr/local/tvheadend-testing/var
the result are the same, both bash script and hardware encoding produce no data.
I even use the ffmpeg which installed with tvheadend bin folder in the bash script, which i would think tvheadend should have permission to no matter what.
I don't know what else to do. Please help!
RE: having issue with piping bash script on tvheadend on synology nas - Added by Ryan Gong over 7 years ago
ok, i basically found out why and how to fix it.
Basically, you can't edit the script file using windows notepad. so I created the exact same file using vi on ssh and worked perfectly.
I found this out because i was trying to run the following command in ssh with out sh:
/volume1/appdata/t.sh
and it give a error "/bin/bash^M: bad interpreter: No such file or directory", and I searched online, that it's because windows and linux use different line feeds, use vi to create the same file, worked perfectly even the script with vaapi.
In tvheadend, the orignal vaapi pipe line (no bash script) won't work, but if i create another line with exact same pipe command, it will work. So it's a little strange there.
And now, if I start tvheadend using command line as root, then in mux, i pipe the vaapi, will also work.
But if i start tvheadend in package center, vappi pipe command mux won't work (no device), but put in a script and it will.
This is just really strange, but I'm glad it's working now.
Hope this help people who may have the same question.