Plan 9: Play Invidious Video

 

Play Youtube videos directly in Plan 9 via Invidious. 

  • Invidious is an alternative front-end to YouTube
  • treason is the video player in Plan 9
  • nvi is the interface to Youtube (via Invidious API) and Peertube 
nvi -A 140 -V 134 -s /mnt/v1 ciWzklgc98o
# Use lang id when available 
nvi -A 140:lang -V 134 -s /mnt/v1 ciWzklgc98o
# Exit
echo exit > /mnt/v1/ctl 
 
treason -a /mnt/v1/audio /mnt/v1/video
 
# Download mode
nvi -A 140 -V 134 -a /tmp/audio -v /tmp/video  ciWzklgc98o
treason file.mp4 
 

 

Installation

Download the treason package - includes codecs and mcfs.

rm -rf /tmp/treason
mkdir /tmp/treason
cd /tmp/treason
hget https://ftrv.se/_/treason.gz | gunzip | disk/mkext -d .
./treason/install.rc
  

Replace treason, nvi and mcfs from repositories listed in Code section.

 

Plumbing

Make sure youtube rule comes before browser rules. 

# youtube urls to nvi/treason
type is text
data matches 'https?://(www\.|m\.)?(youtube\.com/watch\?([^ ]*&)?v=|youtu\.be/)([A-Za-z0-9_\-]+).*'
plumb start window -scroll yt $4

# video
type is text
data matches '([a-zA-Z¡-￿0-9_\-.,/]+)\.(mp4|MP4|avi|mkv)'
arg isfile    $0
plumb to video
plumb start window -scroll treason $file
  

 

Lessons Learnt

  1. Use audio to sync the video instead of vice versa since audio drop is more perceptible. This means during mute, there needs to be delay even when no audio sample is written to the device.

 

Troubleshooting

libvpx compilation error 

vp8_cx_iface.c:21393] set and not used: ctx 
/usr/glenda/vplay/libvpx/vp8/vp8_cx_iface.c:1364[vp8/vp8_cx_iface.c:21655] incomplete structure: vpx_codec_vp8_cx_algo
/usr/glenda/vplay/libvpx/vp8/vp8_cx_iface.c:1344[vp8/vp8_cx_iface.c:21635] more initializers than structure: vpx_codec_vp8_cx_algo
mk: 6c -FTVw -I. ...  : exit status=6c 3724: error
  

If libvpx fails with the above error, use the following fix for CODEC_INTERFACE() macro:

#define CODEC_INTERFACE(id)                          \
  vpx_codec_iface_t *id(void) { return &id##_algo; } \
  vpx_codec_iface_t id##_algo

#define CODEC_INTERFACE(id)                          \
  vpx_codec_iface_t *id(void) { return &id##_algo; } \
  const struct vpx_codec_iface id##_algo
  


Code

 

References

  1. Treason, mcfs and nvi by Sigrid 

 

Comments

Popular posts from this blog

Plan 9 : The Infinity Notebook

Plan 9: Quick Boot with UEFI

Plan 9: Key Visualizer