DEFENDORe / pseudotv

Create live TV channels from your own media. Access the streams using the simulated HDHomerun tuner or the generated M3U URl.
MIT License
229 stars 35 forks source link

ffmpeg and several other errors mostly with direct stream. #33

Closed Liquidbings closed 4 years ago

Liquidbings commented 4 years ago

[mpegts @ 0x563facec66e0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly [mpegts @ 0x563facec66e0] first pts value must be set av_interleaved_write_frame(): Invalid data found when processing input frame= 1 fps=0.0 q=-1.0 Lsize= 18kB time=-00:00:00.52 bitrate=N/A speed=N/A video:14kB audio:13kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Conversion failed!

FFMPEG ERROR {

code: 1, cmd: '/usr/bin/ffmpeg -threads 20 -ss 1720.252 -t 4669.172 -re -i http://192.168.1.25:32400/library/parts/9553/1562451807/file.avi?X-Plex-Token=qmtjiNjuBiCVNdAKfRro -map VIDEOSTREAM -map 0:1 -c:v copy -c:a copy -metadata service_provider="PseudoTV" -metadata service_name="RiffTrax" -f mpegts -output_ts_offset 0 -muxdelay 0 -muxpreload 0 pipe:1' } _http_outgoing.js:526 throw new ERR_HTTP_HEADERS_SENT('set'); ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

at ServerResponse.setHeader (_http_outgoing.js:526:11) at ServerResponse.header (/home/node/app/node_modules/express/lib/response.js:771:10) at ServerResponse.contentType (/home/node/app/node_modules/express/lib/response.js:599:15) at ServerResponse.send (/home/node/app/node_modules/express/lib/response.js:145:14) at FFMPEG. (/home/node/app/src/video.js:75:29) at FFMPEG.emit (events.js:310:20) at ChildProcess. (/home/node/app/src/ffmpeg.js:208:22) at ChildProcess.emit (events.js:310:20) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) { code: 'ERR_HTTP_HEADERS_SENT' } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! pseudotv@1.0.0 start: node index.js npm ERR! Exit status 1

npm ERR! Failed at the pseudotv@1.0.0 start script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-05-20T22_32_46_547Z-debug.log

pseudotv@1.0.0 start /home/node/app node index.js

This happens often when I try and switch channels and the docker crashes and shuts off.

I also can't seem to get Nvenc working. I have it working in plex for HW transcoding but using the same variables in docker config and turning it on in pseudotv just causes it to fail.

Other than that absolutely loving the work here and thank everyone involved very kindly. I'll glad to give any more info or assistance where I can to help. I was wondering if you guys mind if I share the link for this over on the PseudoTv/Pseudotv Live page on the kodi forums as there a bunch of people over there waiting for new development on something like this and I believe they would be as excited as I or more and would likely want to assist.

powdermilkman commented 4 years ago

Of course you can link to this project. As far as Nvenc goes, are you using the nvidia unraid template?

The ffmpeg error is known and something we plan to design better with the rewrite. For now direct play works best if you have a channel consisting of a single codec/container that you know is working.

Liquidbings commented 4 years ago

Thank you kindly for the quick response. Appreciate the feedback. I've gotten a few other errors I've forgotten to document. But will be avid on it for now. I sent the link over the the great folks over on the Kodi site and hopefully a few will pop over here and give some hands in helping out 👍👌💯❤️

For the Nvenc correct I do use the Nvidia unraid template and have it working correctly for Plex and emby.

I tried the direct play method as I was having trouble getting the transcoding working well. I had lots of stuttering, pausing and crashing. I'm still learning about much of the finer details of how alot of this works so wasn't sure on a bunch of the settings.

Definitely learned tons in the last year and loving every moment of it. Thanks again for all of everyone's hard work on this amazing project. I've been a fan of the Kodi pseudotv for years and this project seems like the next best step for this project. Much love and thanks

powdermilkman commented 4 years ago

When transcoding try using the hevc_nvenc video encoder

Liquidbings commented 4 years ago

When transcoding try using the hevc_nvenc video encoder

When I try it won't play any videos. Let me set it up again and see what the log gives us

-threads 10 -ss STARTTIME -t DURATION -re -i INPUTFILE -map VIDEOSTREAM -map AUDIOSTREAM -c:v hevc_nvenc -b:v 100000k -s 1920x1080 -r 30 -flags cgop+ilme -sc_threshold 1000000000 -minrate:v 100000k -maxrate:v 100000k -bufsize:v 100000k -flags cgop+ilme -sc_threshold 1000000000 -minrate:v 100000k -maxrate:v 100000k -bufsize:v 100000k -c:a ac3 -ac 2 -ar 48000 -b:a 192k -metadata service_provider="PseudoTV" -metadata CHANNELNAME -f mpegts -output_ts_offset TSOFFSET -muxdelay 0 -muxpreload 0 OUTPUTFILE

Anything seem overly off? I tried cranking the threads to see if that would help but didn't make a ton of difference. Its a 20 core 40 thread xeon setup

powdermilkman commented 4 years ago

What video card are you using?

Liquidbings commented 4 years ago

1050ti

Stream starting. Channel: 1 (Adult Swim) No Subtitles ffmpeg version 3.2.14-1~deb9u1 Copyright (c) 2000-2019 the FFmpeg developers

built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516 configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared

libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libavresample 3. 1. 0 / 3. 1. 0 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100 Input #0, matroska,webm, from 'http://192.168.1.25:32400/library/parts/3893/1563606840/file.mkv?X-Plex-Token=****': Metadata: CREATION_TIME : 2015-12-12T17:52:32Z ENCODER : Lavf55.12.0 Duration: 00:21:33.38, start: 0.167000, bitrate: 924 kb/s Stream #0:0: Video: hevc (Main), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 23.97 fps, 23.97 tbr, 1k tbn, 23.98 tbc (default) Metadata: BPS : 799092 BPS-eng : 799092 DURATION : 00:21:33.376000000 DURATION-eng : 00:21:33.376000000 NUMBER_OF_FRAMES: 31008 NUMBER_OF_FRAMES-eng: 31008 NUMBER_OF_BYTES : 129190815 NUMBER_OF_BYTES-eng: 129190815 _STATISTICS_WRITING_APP: mkvmerge v8.6.1 ('Flying') 64bit _STATISTICS_WRITING_APP-eng: mkvmerge v8.6.1 ('Flying') 64bit _STATISTICS_WRITING_DATE_UTC: 2015-12-13 12:54:51 _STATISTICS_WRITING_DATE_UTC-eng: 2015-12-13 12:54:51 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default) Metadata: title : Stereo LANGUAGE : eng BPS : 122744 BPS-eng : 122744 DURATION : 00:21:33.354000000 DURATION-eng : 00:21:33.354000000 NUMBER_OF_FRAMES: 60626 NUMBER_OF_FRAMES-eng: 60626 NUMBER_OF_BYTES : 19844032 NUMBER_OF_BYTES-eng: 19844032 _STATISTICS_WRITING_APP: mkvmerge v8.6.1 ('Flying') 64bit _STATISTICS_WRITING_APP-eng: mkvmerge v8.6.1 ('Flying') 64bit _STATISTICS_WRITING_DATE_UTC: 2015-12-13 12:54:51 _STATISTICS_WRITING_DATE_UTC-eng: 2015-12-13 12:54:51 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES Stream #0:2: Video: png, rgba(pc), 300x300, 90k tbr, 90k tbn, 90k tbc Metadata: filename : TAG.png mimetype : image/png Input #1, png_pipe, from 'http://192.168.1.25:8000/images/adultswim.png': Duration: N/A, bitrate: N/A Stream #1:0: Video: png, rgba(pc), 161x109, 25 tbr, 25 tbn, 25 tbc [hevc_nvenc @ 0x557ee048b280] Cannot load libcuda.so.1 Stream mapping: Stream #0:0 (hevc) -> overlay:main (graph 0) Stream #1:0 (png) -> scale (graph 0) yadif (graph 0) -> Stream #0:0 (hevc_nvenc) Stream #0:1 -> #0:1 (aac (native) -> ac3 (native)) Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

FFMPEG ERROR {

code: 1, cmd: /usr/bin/ffmpeg -threads 10 -ss 132.697 -t 1160.678 -re -i http://192.168.1.25:32400/library/parts/3893/1563606840/file.mkv?X-Plex-Token=***** -i http://192.168.1.25:8000/images/adultswim.png -filter_complex [1:v]scale=120:-1[icn];[0:0][icn]overlay=W-w-20:H-h-20:enable='between(t,0,60)'[v1];[v1]yadif[v] -map [v] -map 0:1 -c:v hevc_nvenc -b:v 100000k -s 1920x1080 -r 30 -flags cgop+ilme -sc_threshold 1000000000 -minrate:v 100000k -maxrate:v 100000k -bufsize:v 100000k -flags cgop+ilme -sc_threshold 1000000000 -minrate:v 100000k -maxrate:v 100000k -bufsize:v 100000k -c:a ac3 -ac 2 -ar 48000 -b:a 192k -metadata service_provider="PseudoTV" -metadata service_name="Adult Swim" -f mpegts -output_ts_offset 0 -muxdelay 0 -muxpreload 0 pipe:1 }

Stream ended. Channel: 1 (Adult Swim)

This is what happens when I try the Nvenc none of the channels play (edited token)

powdermilkman commented 4 years ago

[hevc_nvenc @ 0x557ee048b280] Cannot load libcuda.so.1 Are you sure your docker container has the nvidia runtime loaded? The parameter is --runtime=nvidia

Liquidbings commented 4 years ago

durr... Should have figured I missed something so simple...

Working again. not as quick to swap channels as direct play but smooth unlike lib Appreciated. Keep up the amazing work bud

powdermilkman commented 4 years ago

If you didn't notice there is a pre-made template for pseudotv on unraid Glad it's working for you, things should get a lot better with the rewrite.

Liquidbings commented 4 years ago

Yeah That was how I got it working. I tried the old way back when you were on gitlab and couldnt seem to get it going but the template worked a charm.

I'm glad to see you passionate about the project and hope to be of some sort of contribution one way or another. Been waiting for an awesome working version such as this. Over the years theres been a lot of interesting similar type builds and apps to go along with them but I have to say this seems to be the most promising and proper way to go about it I've seen, Much prefer this over having to have addons running over kodi personally.

If there is a donate button lead me to it!

powdermilkman commented 4 years ago

ok, the only reason I ask is the nvidia runtime should have been included in the unraid template. Oh well, it's working now.

And @DEFENDORe deserves all the praise!