Skip to content

ffmpeg not reconnect when youtube URL is expired #12

@fanadol

Description

@fanadol

Hi, so i have been using your package for build my discord bot. Its great thank you.

I found this problem when i playing around with my bot. When playing music (from youtube using ytdl package) its stop in the middle of the song. The error said it's EOF. But the song is not finished yet.

When i print the encodingSession.FFMPEGMessages() its shows something like this:

ffmpeg message ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, matroska,webm, from 'https://r1---sn-h8oxupq-jb3e.googlevideo.com/videoplayback?c=WEB&clen=3527654&dur=217.701&ei=jG1zXvK2FsGDssUP07Gk-Aw&expire=1584644588&fvip=3&gir=yes&id=o-AJXrW4xcFCgVXlnPGCHr51o9dRz-dgyP9UvexvPh6ec3&initcwndbps=323750&ip=103.8.78.14&itag=251&keepalive=yes&lmt=1575023145707784&lsig=ABSNjpQwRQIgIjFTB6fN1SfHZ30_XtaFRYFq1NIpcqt0Vu4tCAJr8kACIQDixfhd0Rtib3QfmfKakfaTNMdR_Z2qXc8_gTyDmKQ0oA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&mh=mM&mime=audio%2Fwebm&mm=31%2C29&mn=sn-h8oxupq-jb3e%2Csn-npoeenee&ms=au%2Crdu&mt=1584622906&mv=m&mvi=0&pcm2=no&pcm2cms=yes&pl=24&ratebypass=yes&requiressl=yes&sig=ADKhkGMwRQIhAP2gpJasp4VRgXqdPefpkyszHb2l90mnICnZr7nytENNAiAqagp5zDRdhtaxNyFzjjfjcbWiNuhdyi3ClDuKJed8eQ%3D%3D&source=youtube&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cpcm2%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&txp=5531432&vprv=1':
  Metadata:
    encoder         : google/video-file
  Duration: 00:03:37.70, start: -0.007000, bitrate: 129 kb/s
    Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Stream mapping:
  Stream #0:0 -> #0:0 (opus (native) -> opus (libopus))
Press [q] to stop, [?] for help
Output #0, ogg, to 'pipe:1':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0(eng): Audio: opus (libopus), 48000 Hz, stereo, flt, 96 kb/s (default)
    Metadata:
      encoder         : Lavc58.54.100 libopus
[tls @ 0x7fa970e07580] Error in the pull function.
[matroska,webm @ 0x7fa971000c00] Read error
[tls @ 0x7fa970e07580] The specified session has been invalidated for some reason.
    Last message repeated 1 times
https://r1---sn-h8oxupq-jb3e.googlevideo.com/videoplayback?c=WEB&clen=3527654&dur=217.701&ei=jG1zXvK2FsGDssUP07Gk-Aw&expire=1584644588&fvip=3&gir=yes&id=o-AJXrW4xcFCgVXlnPGCHr51o9dRz-dgyP9UvexvPh6ec3&initcwndbps=323750&ip=103.8.78.14&itag=251&keepalive=yes&lmt=1575023145707784&lsig=ABSNjpQwRQIgIjFTB6fN1SfHZ30_XtaFRYFq1NIpcqt0Vu4tCAJr8kACIQDixfhd0Rtib3QfmfKakfaTNMdR_Z2qXc8_gTyDmKQ0oA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&mh=mM&mime=audio%2Fwebm&mm=31%2C29&mn=sn-h8oxupq-jb3e%2Csn-npoeenee&ms=au%2Crdu&mt=1584622906&mv=m&mvi=0&pcm2=no&pcm2cms=yes&pl=24&ratebypass=yes&requiressl=yes&sig=ADKhkGMwRQIhAP2gpJasp4VRgXqdPefpkyszHb2l90mnICnZr7nytENNAiAqagp5zDRdhtaxNyFzjjfjcbWiNuhdyi3ClDuKJed8eQ%3D%3D&source=youtube&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cpcm2%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&txp=5531432&vprv=1: Input/output error
size=    2369kB time=00:03:24.30 bitrate=  95.0kbits/s speed=1.04x
video:0kB audio:2352kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.702825%

When i try to google this error, it's turn out that the youtube URL was expired. So the ffmpeg immediately return EOF.

The specified session has been invalidated for some reason.

I am able to solve this issue (maybe) to add reconnect flag in ffmpeg command. I will try to link my PR to this issue.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions