New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transcoding via filter scripts to http streaming #274
Conversation
|
Ok, found why it did not work propperly. VLC uses diffrent caches for file(stdin is seen as file) and network input. And the default 300ms cache-time are not enough. #!/bin/bash
export DISPLAY=:0
exec cvlc --file-caching 1500 "--sout=#transcode{venc=va,threads=4,deinterlace,height=720,vb=-33}:std{access=file,mux=ts,dst=-}" - 2>/tmp/vlc.logA no-op passthrough-script could look like this: #!/bin/bash
exec cat <&0It's working flawlessly for me now! |
|
Is there a way to somehow be able to signal a proper mime type to the http server? For example I would like to encode audio to aac or vorbis using ffmpeg. Since I am dealing with raw audio proper mime type would be usefull so I can for example play the audio on android phone, symbian phone and even on a windows pc with winamp or foobar 2000. |
|
No, there is no easy way to influence what headers are sent. |
|
This can no longer be applied without editing. There are no functional differences just merge conflicts: http://pastie.org/8137891 |
|
This already is up-to-date with current master and applies cleanly. |
|
This seems like a way to get HLS (HTTP LIVE STREAMING) working! if the "filter" can have vlc transcode the stream then we could use vlc's ability to output a live stream that could then be used for native playback on mobile devices (aka iPhone) without the need for VLC to be installed! I could be wrong... but definitely worth looking into! |
|
HLS isn't a simple stream like normal http/rtmp Streaming. |
|
I understand how HLS works. Though it does appear you have the ability to take the live tv stream and feed it into a bash command. VLC has command line arguments to handle live transcoding to HLS. This is an example of code i've used in the past: So it seems to me that the HLS stream could at least be generated but as far as impacting how its accessed or how it impacts hts... that I don't know |
|
I think this would be easier to achive by setting up nginx-rtmp with a hls setup, which is configured to pull from tvh. |
src/webui/webui.c
Outdated
| if(fgets(mime, *mime_size, fp) == NULL) | ||
| *mime_size = 0; | ||
| fclose(fp); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some logging would perhaps be appropriate here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mime file is completely optional and it not existing or beeing empty is not an error or even worth a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right.
|
@BtbN maybe you could drop some of the cosmetic changes (mainly the "opening brace on next line" changes) and move those that fix bad indentation to a separate commit? |
|
Can you let me know the where to place transcoding script? I'm getting this in TVH log: 2014-04-13 14:03:42.585 webui: Transcoding stream with transcoder /home/vlc/.hts/tvheadend/transcoders/test |
|
@nhsman you'll have to use "test" as the transcoder script, not the full path. |
|
Thanks. But where to place actual script? I have it in "/home/vlc/.hts/tvheadend/transcoders/" and 2014-04-13 16:15:40.497 webui: Transcoding stream with transcoder test |
|
Have you made sure the script is executable? |
|
And does it really say "dir/transcoders/test"? |
|
Yes it says "dir/transcoders/test". And yes, the script is executable. Any ideas? |
|
Apparently it determines your configuration directory to be "No settings dir", which is why the script fails. How are you running tvheadend and under what user does it run (your posts would indicate the user is "vlc", is that correct)? |
|
I compiled TVH from source and run it as "sudo tvheadend -C -f". |
|
@nhsman don't run it as root. |
|
If I start tvheadend as non root, |
|
Mine runs as -u tvheadend and tvheadend is member of the video group. And remember, if you run tvh as root "ones", to chown -R your config directory (if init doesn't take care of that). |
|
Indeed, i'm not sure how to react in that case. Just abort and assume no script was present? |
|
Thanks. tvserver@SERVERTV:~$ tvheadend -C -f Any ideas? |
|
@BtbN: abort with something like "No configuration directory in use, unable to load transcoder scripts" |
|
@nhsman something is wrong with your Linux or your tvheadend installation. |
|
I use Ubuntu 13.04 x64 minimal. I had to upgrade kernel to 3.13 to get my tv adapter works. Then compiled TVH from here: https://github.com/BtbN/tvheadend using "simple_transcode" branch. |
|
Hi, I've compiled latest master with this PR and it seems to not work. Sorry guys, it's my bad. It should be: |
b30f05b
to
1bd1564
Compare
|
You might want to consider borrowing/stealing the UPnP / DNLA client profiles XML files from the latest Plex Media Server and use as a base to create custom MIME types in filter profile per reciever client for transcoding and/or remuxing , see: https://github.com/Hedda/Plex-DNLA-client-profiles/tree/master https://github.com/Hedda/Plex-DNLA-client-profiles/archive/master.zip PS Hope it is OK to have copies of these XML files on GitHub as Plex.tv don't have an source code repository available because rest of the software is closed source. |
c193390
to
9ca5166
Compare
|
This functionality was implemented like MPEG-TS Spawn streaming profile where users can configure the command which should be invoked for the original MPEG-TS stream. v4.3-344-gc349525b2, more commits, the main is 5bbddc9 . |
This adds a new parameter to the http streaming server.
Adding ?transcoder=test makes it pipe all http output through a "filter", which can do basicaly anything with it.
It searches for the trascoders in hts_settings_get_root()/transcoders
It also passess all GET parameters in hc_req_args as environment variables, prefixed with GET_, so the transcoder can get options via url parameters.
This also modifies the writing to the socket a bit, so it checks if it can write to the http stream, because it can no longer rely on write() errors, because it no longer directly writes to the tcp socket. I use select and poll for this.
There is still a problem somewhere, because in my tests a transcoding vlc throws a lot of warnings about broken input data. Connecting with vlc via http, which should bring the same data to vlc, works perfectly. But this only seems to happen with higher bandwith streams, so i guess it's some buffer overflowing.
But in general, this already works fine.