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

[Python] Using stdout for stopping livestream download #16916

Closed
Pipoderoso opened this issue Jul 6, 2018 · 1 comment
Closed

[Python] Using stdout for stopping livestream download #16916

Pipoderoso opened this issue Jul 6, 2018 · 1 comment

Comments

@Pipoderoso
Copy link

@Pipoderoso Pipoderoso commented Jul 6, 2018

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2018.07.04. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2018.07.04

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones
  • Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

I am trying to download a youtube livestream that is always up, but broadcast the important content at a certain time of the day. When I start the download I want to use the information from stdout for setting when to stop the download with a CTRL+C Signal.

This is the segment I am interested on:

frame=  299 fps=4.7 q=-1.0 Lsize=     387kB time=00:00:10.00 bitrate= 316.9kbits/s speed=0.159x

My problem is, that I can't find where to get this string when downloading. The logger doesn't receive all stdout.

I am using the example python embedded code.

from __future__ import unicode_literals
import youtube_dl


class MyLogger(object):

    def debug(self, msg):
        with open("debug.txt", "a") as text_file:
            text_file.write(msg)

    def warning(self, msg):
        with open("warning.txt", "a") as text_file:
            text_file.write(msg)

    def error(self, msg):
        with open("error.txt", "a") as text_file:
            text_file.write(msg)


def my_hook(d):
    if d['status'] == 'finished':
        print('Done downloading, now converting ...')

ydl_opts = {
    'format': 'bestvideo+bestaudio/best',
    'noplaylist' : True,
    'logger': MyLogger(),
    'progress_hooks': [my_hook],
}

stream_url="https://www.youtube.com/watch?v=05K00cYTFO8"
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([stream_url])
@Pipoderoso
Copy link
Author

@Pipoderoso Pipoderoso commented Jul 6, 2018

I solved it by using only the command line and not the python api

ffmpeg -i $(youtube-dl -f best -g "$URL") -c:v copy -c:a aac -strict experimental -t 00:45:00 $VID_NAME.mp4

@Pipoderoso Pipoderoso closed this Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.