나는 놀 수 있기를 원한다그리고mpv --ytdl을 사용하여 비디오를 저장합니다. 어떻게 해야 합니까? 특히 중요한 점은 버퍼도 저장된다는 것입니다.
기본적으로 YouTube에서 비디오를 재생한 다음 mpv를 종료하고 비디오가 로드된 지점까지 비디오를 계속 볼 수 있기를 원합니다. 그래서 파일에 저장하려면 버퍼도 필요합니다.
나는 이미 youtube-dl -o를 사용해 보았습니다. 비디오를 stdout으로 스트리밍한 다음 mpv로 파이핑했습니다. 즉,
youtube-dl -o - | mpv -
(티를 사용하여 스트림을 분할하고 간단히 파일에 쓸 수 있다는 아이디어로) - 그러나 mpv를 사용하여 비디오를 탐색할 수 없다는 문제가 있습니다. 이는 표준 입력에서 나오는 고정 스트림일 뿐입니다. 모두. 내가 가진 또 다른 아이디어는 mpv의 -o 옵션을 사용하여 출력 파일을 지정하는 것이었습니다. 그러나 내부 버퍼는 저장되지 않습니다.
답변1
아직 실험적인 또 다른 옵션은 mpv 자체를 사용하는 것입니다 --record-file
.
mpv --record-file=video.mkv https://www.youtube.com/watch?v=…
나는 그것으로 제한된 성공을 거두었습니다. youtube-dl이 캡처하는 소스 파일은 녹음 파일에 대해 지정한 파일 확장자와 일치해야 합니다. 그러나 이것은 질문에 설명된 내용에 가장 가까운 것 같습니다.
에서(현재 안정) 매뉴얼:
--record-file=<file>
현재 스트림을 지정된 대상 파일에 기록합니다. 대상 파일은 묻지 않고 항상 덮어쓰여집니다.
이는 재인코딩 없이 소스 스트림을 재다중화하므로 매우 취약하고 실험적인 기능입니다. 깨지거나, 표준을 준수하지 않거나, 모든 플레이어(mpv 포함)에서 재생할 수 없거나, 불완전한 파일을 쓰는 것은 전적으로 가능합니다.
대상 파일 형식은 대상 파일 이름의 파일 확장자에 따라 결정됩니다. 가능하면 소스 컨테이너와 동일한 대상 컨테이너를 사용하고 대체 수단으로 Matroska를 선호하는 것이 좋습니다.
스트림 녹화 중에 탐색하거나 재생 중에 스트림 녹화를 활성화/비활성화하면 데이터가 잘리거나 출력 파일에 "구멍"이 생길 수 있습니다. 이는 기술적 제한 사항입니다. 특히, 미리 읽어온 영상 데이터나 자막 등은 이러한 구멍을 발생시켜 다양한 플레이어(mpv 포함)에서 재생 문제를 일으킬 수 있습니다.
이 옵션의 동작은 나중에
--screenshot-template
반안정적으로 선언될 때까지 템플릿으로 변경( 과 유사), 이름 변경, 제거 등으로 변경될 수 있습니다.
답변2
--record-file
를 선호하여 더 이상 사용되지 않습니다 --stream-record
. 캐시를 넘어서 빨리 감으면 출력 파일이 건너뛰기 때문에 둘 다 완벽한 솔루션은 아닙니다.
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).
용법:
mpv --stream-record=$HOME/Downloads/path/name.mp4 <URL>
답변3
youtube-dl -o - | tee video.mp4 | mpv -
답변4
youtube-dl url --exec mpv
스트리밍되지는 않지만 다운로드 후 재생되지만 전화 접속 계정 등이 없으면 차이를 알 수 없습니다.