[mythtv-users] V32 issued with mythexternrecorder and youtube-dl

Peter Bennett pb.mythtv at gmail.com
Mon Mar 28 12:58:06 UTC 2022


On 3/27/22 20:21, OpenMedia Support wrote:
>>> On 3/27/22 02:37, OpenMedia Support wrote:
>>>> Just upgraded from Ubuntu 18.04 -> 20.04 and MythTV V31 -> V32
>>>>
>>>> I had a nicely working external recorder working with our local FTA
>>>> channels, and even documented the process for others to use under
>>>>
>>>>    -https://github.com/steven-ellis/mypvr-nz-iptv
>>>>
>>>> I'm using
>>>>    -
>>>> https://github.com/steven-ellis/mypvr-nz-iptv/blob/main/external/youtube-dl-nz.conf
>>>>    -
>>>> https://github.com/steven-ellis/mypvr-nz-iptv/blob/main/external/youtube-dl-nz-channels.conf
>>>>
>>>> With the upgrade to V32 the youtube-dl command just exits almost
>>>> immediately and I can't debug any reasonable reason why.
>>>>
>>>>
>>>> If I run youtube-dl on the command line and pipe the output to mpv
>>>> playback works
>>>>
>>>> mythfe at mythtv:/tmp$ /usr/bin/youtube-dl -q -o - --hls-use-mpegts
>>>> --external-downloader-args "-hide_banner -nostats -loglevel panic -re"
>>>> "https://i.mjh.nz/nz/tv.9.m3u8"  | mpv - --vo=x11
>>>> [file] Reading from stdin...
>>>> WARNING: Could not send HEAD request to
>>>> https://d2ce82tpc3p734.cloudfront.net/v1/master/b1f4432f8f95be9e629d97baabfed15b8cacd1f8/TVNZ_1/master.m3u8:
>>>> HTTP Error 404: Not Found
>>>>    (+) Video --vid=1 (h264 1280x720 25.000fps)
>>>>    (+) Audio --aid=1 (aac 2ch 48000Hz)
>>>> [vo/x11] Warning: this legacy VO has bad performance. Consider fixing
>>>> your
>>>> graphics drivers, or not forcing the x11 VO.
>>>> ALSA lib conf.c:5187:(snd_config_expand) Unknown parameters
>>>> CARD=Generic,DEV=0
>>>> ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM
>>>> hdmi:CARD=Generic,DEV=0
>>>> [ao/alsa] Playback open error: Invalid argument
>>>> [ao] Failed to initialize audio driver 'alsa'
>>>> [ao] This audio driver/device was forced with the --audio-device
>>>> option.
>>>> [ao] Try unsetting it.
>>>> Could not open/initialize audio device -> no sound.
>>>> Audio: no audio
>>>> VO: [x11] 1280x720 yuv420p
>>>> [vo/x11] Shared memory not supported
>>>> [vo/x11] Reverting to normal Xlib
>>>> [vo/x11] Shared memory not supported
>>>> [vo/x11] Reverting to normal Xlib
>>>> V: 00:00:00 / 00:00:00 (2%) Cache: 0.6s/162KB
>>>> [vo/x11] Shared memory not supported
>>>> [vo/x11] Reverting to normal Xlib
>>>> [vo/x11] Shared memory not supported
>>>> [vo/x11] Reverting to normal Xlib
>>>> V: 00:00:02 / 00:00:02 (82%) Cache: 0.3s/99KB
>>>>
>>>>
>>>> Exiting... (Quit)
>>>> ERROR: ffmpeg exited with code 1
>>>>
>>>>
>>>> If I try to debug the external recorder I can see it tries to start
>>>> youtube-dl but it appears to exit immediately
>>>>
>> .....
>>>> Any tips on additional debugging steps.
>>> I have scripts for an external recorder that are working fine.
>>> (https://github.com/bennettpeter/MythTV-LeanCapture).
>>>
>>> If youtube-dl is outputting an error message you may not see it, the
>>> error output may be getting lost. For my external recorder I use shell
>>> scripts for all of the commands. The error output is redirected to a
>>> file.
>>>
>>> I don't know if a redirect on the command line in the conf file will
>>> work. You could try that:
>>>
>>> command="/usr/bin/youtube-dl --hls-use-mpegts --external-downloader-args
>>> \"-hide_banner -nostats -loglevel panic -re\" -o - \"%URL%\"
>>> 2>>/tmp/youtube-dl.log"
>>>
>>> Alternatively create a shell script that calls the command with the
>>> redirect of stderr
>>>
>>> Also in the shell script you may want to log the return code from
>>> youtube-dl
>>>
>> Hi Peter
>>
>> Thanks for the tips. I was thinking along the same lines
>>
>> I created a wrapper to dump all the arguments out and then call the real
>> command and I get the following
>>
>>
>> RUNNING: /usr/bin/youtube-dl -q -o - --hls-use-mpegts
>> --external-downloader-args "-hide_banner -nostats -loglevel panic -re"
>> "https://i.mjh.nz/nz/tv.9.m3u8"
>> ERROR: '"https://i.mjh.nz/nz/tv.9.m3u8"' is not a valid URL. Set
>> --default-search "ytsearch" (or run  youtube-dl
>> "ytsearch:"https://i.mjh.nz/nz/tv.9.m3u8"" ) to search YouTube
>> /usr/bin/youtube-dl failed with 1
>>
>> Yet if I run the following on the command line it works without issue.
>> Odd.
>>
>> /usr/bin/youtube-dl -q -o - --hls-use-mpegts --external-downloader-args
>> "-hide_banner -nostats -loglevel panic -re"
>> "https://i.mjh.nz/nz/tv.9.m3u8" | mpv - -vo=x11
>>
> Ok this is now seriously weird.
>
> I also put ffmpeg into debug mode and it appears there is an issue with
> the way arguments are being passed from
>
>
> If I use my wrapper in /usr/local/bin/youtube-dl to ignore the arguments
> being passed in from mythexternrecorder except for the URL and then call
> /usr/bin/youtube-dl with
>
> -q -o - --hls-use-mpegts --external-downloader-args "-hide_banner -nostats
> -loglevel panic -re" ${URL}
>
> everything works without issue.
>
> If I try to run youtube-dl directly with
>
> command="/usr/bin/youtube-dl -q -o - --hls-use-mpegts
> --external-downloader-args \"-hide_banner -nostats -loglevel panic -re\"
> \"%URL%\""
>
> or
>
> command="/usr/bin/youtube-dl -q -o - --hls-use-mpegts
> --external-downloader-args \"-hide_banner -nostats -loglevel panic -re\"
> %URL%"
>
> I end up with ffmpeg having an issue with the external-downloader-args
> still getting quoted - which is very very odd.
>
>
> ffmpeg -y -loglevel quiet "-hide_banner -nostats -loglevel panic -re"
> -headers "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.66
> Safari/537.36\x0d\x0aAccept-Charset:
> ISO-8859-1,utf-8;q=0.7,*;q=0.7\x0d\x0aAccept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\x0d\x0aAccept-Encoding:
> gzip, deflate\x0d\x0aAccept-Language: en-us,en;q=0.5\x0d\x0a" -i
> https://d2ce82tpc3p734.cloudfront.net/v1/manifest/b1f4432f8f95be9e629d97baabfed15b8cacd1f8/TVNZ_1/44be7345-abf7-44f7-a446-acd2838bec99/4.m3u8
> -c copy -f mpegts -
> ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
>    built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
>    configuration: --prefix=/usr --extra-version=1ubuntu0.1
> --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
> --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
> --disable-stripping --enable-avresample --disable-filter=resample
> --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom
> --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
> --enable-libcdio --enable-libcodec2 --enable-libflite
> --enable-libfontconfig --enable-libfreetype --enable-libfribidi
> --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
> --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
> --enable-libopus --enable-libpulse --enable-librsvg
> --enable-librubberband --enable-libshine --enable-libsnappy
> --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
> --enable-libtwolame --enable-libvidstab --enable-libvorbis
> --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
> --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi
> --enable-lv2 --ena  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
> Splitting the commandline.
> Reading option '-y' ... matched as option 'y' (overwrite output files)
> with argument '1'.
> Reading option '-loglevel' ... matched as option 'loglevel' (set logging
> level) with argument 'quiet'.
> Reading option '-hide_banner -nostats -loglevel panic -re' ...Unrecognized
> option 'hide_banner -nostats -loglevel panic -re'.
> Error splitting the argument list: Option not found
>
>
> I've removed my debug wrapper and I'm still seeing ffmpeg report the same
> error, so there must be some weird escaping happening between
> mythexternrecorder-> youtube-dl -> ffmpeg
>
> any thoughts / ideas?
>
> Running off the Ubuntu 20.04 PPA with
>   - mythtv-backend 2:32.0+fixes.202203250633.f69ce764b7~ubuntu20.04.1
>   - youtube-dl     2020.03.24-1
>   - ffmpeg         7:4.2.4-1ubuntu0.1
>
> Steven
>
>
> _______________________________________________

I suggest it will be easier to solve if you put your command in a shell 
script, with simple or no arguments to the shell script. That way you 
can more easily control what goes into the programs. You can specify a 
shell script in the external black box recorder command path and in the 
conf file command= lines for example my recorder command in the conf 
file is this

command=/opt/mythtv/leancap/leancap_encode.sh leancap1

This way you can also test your shell scripts stand alone rather than 
having to set up recordings in order to test it.

Peter



More information about the mythtv-users mailing list