Salve o vídeo reproduzido em mpv --ytdl em um arquivo durante a reprodução

Salve o vídeo reproduzido em mpv --ytdl em um arquivo durante a reprodução

Eu gostaria de poder jogaresalve um vídeo com mpv --ytdl. Como faço para fazer isso? O que é particularmente importante é que o buffer também seja salvo.

Basicamente, eu gostaria de reproduzir um vídeo do YouTube, sair do MPV e ainda poder continuar assistindo o vídeo até o momento em que foi carregado - é por isso que também preciso que os buffers sejam salvos em um arquivo.

Eu já tentei usar youtube-dl -o - para transmitir o vídeo para stdout e depois canalizá-lo com mpv, ou seja

youtube-dl -o - | mpv -

(com a ideia de que eu poderia usar tee para dividir o stream e simplesmente gravá-lo em um arquivo) - no entanto, isso tem o problema de não poder usar mpv para navegar pelo vídeo - é apenas um stream fixo vindo de stdin depois todos. Outra ideia que tive foi usar a opção -o do mpv para especificar um arquivo de saída. Isso não salva o buffer interno, entretanto.

Responder1

Outra opção, ainda altamente experimental, é usar o próprio mpv --record-file:

mpv --record-file=video.mkv https://www.youtube.com/watch?v=…

Tive sucesso limitado com isso. Como os arquivos de origem que o youtube-dl está capturando, é necessário corresponder à extensão do arquivo que você especificou para o arquivo de gravação. No entanto, isso parece o mais próximo do que está descrito na pergunta.

Deo manual (atualmente estável):

--record-file=<file>

Grave o fluxo atual no arquivo de destino fornecido. O arquivo de destino sempre será sobrescrito sem solicitação.

Isso remuxula o fluxo de origem sem recodificação, o que torna esse recurso altamente frágil e experimental. É perfeitamente possível que isso grave arquivos quebrados, que não sejam compatíveis com os padrões, que não possam ser reproduzidos com todos os reprodutores (incluindo MPV) ou incompletos.

O formato do arquivo de destino é determinado pela extensão do nome do arquivo de destino. Recomenda-se usar o mesmo contêiner de destino que o contêiner de origem, se possível, e preferir Matroska como substituto.

Buscar durante a gravação de fluxo ou ativar/desativar a gravação de fluxo durante a reprodução pode cortar dados ou produzir "buracos" no arquivo de saída. Estas são restrições técnicas. Em particular, dados de vídeo ou legendas que foram lidos antecipadamente podem produzir tais falhas, o que pode causar problemas de reprodução em vários reprodutores (incluindo MPV).

O comportamento desta opção pode mudar no futuro, como alterá-la para um modelo (semelhante a --screenshot-template), ser renomeada, removida ou qualquer outra coisa, até que seja declarada semi-estável.

Responder2

--record-filefoi preterido, em favor de --stream-record. ambos não são uma solução perfeita, porque o avanço rápido além do cache resultará em um salto no arquivo de saída.

na página de manual do mpv:

 --record-file=<file>
       Deprecated, use --stream-record, or the dump-cache command.

       Record the current stream to the given target file. The target
       file will always be overwritten without asking.

       This was deprecated because it isn't very nice to use. For one,
       seeking while this is enabled will be directly reflected in  the
       output, which was not useful and annoying.
 --stream-record=<file>
        Write  received/read  data from the demuxer to the given output
        file.  The output file will always be overwritten without asking.
        The output format is determined by the extension of the output
        file.

        Switching streams or seeking during recording might result in
        recording being stopped and/or broken files. Use with care.

        Seeking outside of the demuxer cache will result in "skips" in
        the output file, but seeking within  the demuxer cache should
        not affect  recording.  One exception is when you seek back far
        enough to exceed the forward buffering size, in which case the
        cache stops actively reading.  This will return in dropped data
        if it's a live stream.

        If this is set at runtime, the old file is closed, and the new
        file is opened.  Note that this will write only data that  is
        appended at the end of the cache, and the already cached data
        cannot be written.  You can try the dump-cache command as an
        alternative.

        External files (--audio-file etc.) are ignored by this, it works
        on the "main" file only. Using this with  files  using  ordered
        chapters or EDL files will also not work correctly in general.

        There  are  some  glitches with this because it uses FFmpeg's
        libavformat for writing the output file.  For example, it's
        typical that it will only work if the output format is the same
        as the input format.  This is the case even if it works with
        the  ffmpeg tool.  One reason for this is that ffmpeg and its
        libraries contain certain hacks and workarounds for these issues,
        that are unavailable to outside users.

        This replaces --record-file.  It is similar to the ancient/removed
        --stream-capture/-capture options, and provides better  behavior
        in most cases (i.e. actually works).

uso: mpv --stream-record=$HOME/Downloads/path/name.mp4 <URL>

Responder3

youtube-dl -o - | tee video.mp4 | mpv -

Responder4

url do youtube-dl --exec mpv

Isso não é transmitido, mas reproduzido após o download, mas você não saberá a diferença, a menos que tenha uma conta dial-up ou algo assim.

informação relacionada