Skip to content
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

Watch JuliaCon in the Terminal #14

Open
carstenbauer opened this issue Jun 4, 2021 · 10 comments
Open

Watch JuliaCon in the Terminal #14

carstenbauer opened this issue Jun 4, 2021 · 10 comments

Comments

@carstenbauer
Copy link
Member

@logankilpatrick had an awesome idea on the JuliaCon call: Wouldn't it be super cool if one could watch JuliaCon (the YouTube streams) in the terminal? @IanButterworth, maybe VideoInTerminal.jl can help with this?

@IanButterworth
Copy link
Contributor

Yeah I thought the same. I wonder if we could expose a youtube stream to VideoIO

@carstenbauer
Copy link
Member Author

Maybe something along the lines of https://stackoverflow.com/questions/37040798/how-do-you-use-youtube-dl-to-download-live-streams-that-are-live ? Shouldn't it be somewhat similar to how the camera stream gets displayed with VideoIO?

Unfortunately I have no experience in this area ... :(

@carstenbauer
Copy link
Member Author

carstenbauer commented Jun 4, 2021

Would it be helpful if I would try to create a youtube-dl_jll? (youtube-dl is a python module / requires the python interpreter)

@IanButterworth
Copy link
Contributor

IanButterworth commented Jun 5, 2021

This was easier than I expected...
For the live videos we'd want to pipe the frames directly into julia, rather than download to file like this though

using HTTP, JSON3, FFMPEG, VideoInTerminal

function get_youtube(id = "j18ECUhkeY0")
    f, io = mktemp()
    dest = string(f,".mp4")

    r = HTTP.request("GET", "https://www.youtube.com/get_video_info?video_id=$(id)&html5=1")
    lines = split(HTTP.unescapeuri(String(r.body)), '&')
    for line in lines
        if startswith(line, "player_response")
            pr = JSON3.read(split(line, "player_response=", keepempty = false)[1])
            for format in pr[:streamingData][:adaptiveFormats]
                if format[:height] == 240
                    FFMPEG.exe("-i", format[:url], dest, collect=true)
                    return dest
                end
            end
        end
    end
    error("Could not find usable video")
end

function watch_juliacon(id = "TPuJsgyu87U")
    @info "Grabbing video..."
    vid = get_youtube(id)
    VideoInTerminal.play(vid)
end

Screen Shot 2021-06-05 at 12 38 46 AM

Screen Shot 2021-06-05 at 12 39 16 AM

name that talk...

@carstenbauer
Copy link
Member Author

This is awesome! Needs a little bit of tweaking though to handle live streams I guess? Example: id = 21X5lGlDOfg (https://www.youtube.com/watch?v=21X5lGlDOfg) doesn't work.

@carstenbauer
Copy link
Member Author

And, just for my understanding, we're still downloading to file in some sense right? (FFMPEG.exe("-i", format[:url], dest, collect=true)

@carstenbauer
Copy link
Member Author

Sorry, one more thing. Any idea how to make audio work ? 😀

@IanButterworth
Copy link
Contributor

Sorry, one more thing. Any idea how to make audio work ?

Nope. It might be possible to extract a subtitle file and print that underneath though

For live streams I think it would probably have to be through VideoIO via an AVInput, but I couldn't figure it out quickly

@oscardssmith
Copy link

If we want maximum style points, we could use the say command

@carstenbauer
Copy link
Member Author

I'd still love to have this... it's so cool :) Maybe we could try to use https://github.com/eschnett/SixelTerm.jl to get a reasonable quality? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants