<p>I didn't find an actual answer, more a work around. As this was all part of a bigger, involving plex, I found a proxy (<a href="https://github.com/xteve-project/xTeVe" rel="nofollow noreferrer">xteve</a>) that includes ffmpeg transcoding, and I can set the options for ffmpeg.  That is good enough for what I was trying to do.</p>

<p>Hope this save someone else a little time.</p>

CC BY-SA 4.0
2020-03-05T01:44:52.997Z
2020-03-05T01:44:52.997Z
Netspud2K
<p>First post, so be kind please :)</p>

<p>So a quick bit of history. I am using tvheadend, and the inbuilt transcoder murders my CPU, and provides average quality output (it's powered by ffmpeg), if I pipe the output from tvheadend through ffmpeg I get much lower CPU usage and better quality (weird but true). (I am having to transcode because of limited player abilities)</p>

<p>So in tvheadend the http link goes from something like</p>

<p><a href="http://avideostream" rel="nofollow noreferrer">http://avideostream</a></p>

<p>to</p>

<pre><code>pipe:///usr/bin/ffmpeg -loglevel fatal -i http://avideostream -tune zerolatency -vcodec libx264 -preset veryfast -crf 28 -maxrate 1200k -bufsize 3500k -vf "scale='min(1280,iw)':'min(720,ih)'" -acodec aac -b:a 128K -f mpegts pipe:1
</code></pre>

<p>Big difference as you can see.</p>

<p>This all works, BUT if I want to change the settings in the my above pipe, i have to change them for all links (which I do through a script), but that means tvheadend re-imports and tests all of the links (as it see them as changed links, which is fair enough).</p>

<p>So what I want to do is wrap ffmpeg in something, so I can change the wrapper. (This is all happening on a up to date ubuntu server).</p>

<p>Now I am happy to say I am not a Ubuntu expert (not even close), although I have been running my own home servers for a few years now. So I don't fully understand all the aspects of "pipe".</p>

<p>The three options I see for above (as to date I have found no way for chosing an external transcoder option for tvheadend, without moving into weird builds, which I would like to avoid) are:</p>

<p>Use an external options file for ffmpeg (which I can get to work from the console, but not as part of the pipe, e.g. sudo ffmpeg -i amovie.mp4 $(cat ffmpegoptions.txt) convertedmovie.mp4, it might be as simple as file access rights, but I didn't do much debugging)</p>

<p>Put the ffmpeg stuff in a .sh file (but that just seems to break the pipe, and I have no idea where to even start with that)</p>

<p>put the ffmpeg in some sort of python script (I didn't even start investigating that, a step too far for me, I can write python, but that is currently out of my league)</p>

<p>Short version, I want to go from:</p>

<p>tvheadend >> piped to ffmpeg >> back to tvheadend >> off to player</p>

<p>To either</p>

<p>tvheadend >> piped to .sh or script wrapper >> piped to ffmpeg >> back to tvheadend >> off to player</p>

<p>or</p>

<p>tvheadend >> piped to ffmpeg (controlled by an external options file) >> back to tvheadend >> off to player</p>

<p>Any suggestions/help would be much appreciated. Let me know if I missed any important info out.</p>

<video><ffmpeg><streaming><linux>
how to pipe:/// through a .sh or Python script, or use some sort of setting files with FFMPEG
Netspud2K
# how to pipe:/// through a .sh or Python script, or use some sort of setting files with FFMPEG

(Asked by: username_0 on 2020-03-03)

First post, so be kind please :)
So a quick bit of history. I am using tvheadend, and the inbuilt transcoder murders my CPU, and provides average quality output (it's powered by ffmpeg), if I pipe the output from tvheadend through ffmpeg I get much lower CPU usage and better quality (weird but true). (I am having to transcode because of limited player abilities)
So in tvheadend the http link goes from something like
http://avideostream
to
pipe:///usr/bin/ffmpeg -loglevel fatal -i http://avideostream -tune zerolatency -vcodec libx264 -preset veryfast -crf 28 -maxrate 1200k -bufsize 3500k -vf "scale='min(1280,iw)':'min(720,ih)'" -acodec aac -b:a 128K -f mpegts pipe:1

Big difference as you can see.
This all works, BUT if I want to change the settings in the my above pipe, i have to change them for all links (which I do through a script), but that means tvheadend re-imports and tests all of the links (as it see them as changed links, which is fair enough).
So what I want to do is wrap ffmpeg in something, so I can change the wrapper. (This is all happening on a up to date ubuntu server).
Now I am happy to say I am not a Ubuntu expert (not even close), although I have been running my own home servers for a few years now. So I don't fully understand all the aspects of "pipe".
The three options I see for above (as to date I have found no way for chosing an external transcoder option for tvheadend, without moving into weird builds, which I would like to avoid) are:
Use an external options file for ffmpeg (which I can get to work from the console, but not as part of the pipe, e.g. sudo ffmpeg -i amovie.mp4 $(cat ffmpegoptions.txt) convertedmovie.mp4, it might be as simple as file access rights, but I didn't do much debugging)
Put the ffmpeg stuff in a .sh file (but that just seems to break the pipe, and I have no idea where to even start with that)
put the ffmpeg in some sort of python script (I didn't even start investigating that, a step too far for me, I can write python, but that is currently out of my league)
Short version, I want to go from:
tvheadend >> piped to ffmpeg >> back to tvheadend >> off to player
To either
tvheadend >> piped to .sh or script wrapper >> piped to ffmpeg >> back to tvheadend >> off to player
or
tvheadend >> piped to ffmpeg (controlled by an external options file) >> back to tvheadend >> off to player
Any suggestions/help would be much appreciated. Let me know if I missed any important info out.

**Tags:** video, ffmpeg, streaming, linux


---

## 1 answers

### Answer by username_0 on 2020-03-05. Score: 1

I didn't find an actual answer, more a work around. As this was all part of a bigger, involving plex, I found a proxy ([xteve](https://github.com/xteve-project/xTeVe)) that includes ffmpeg transcoding, and I can set the options for ffmpeg. That is good enough for what I was trying to do.

Hope this save someone else a little time.


---

