
배경
지정된 시간 범위(처음 30초, 20-55초 등)의 Youtube 비디오에서 최고 품질의 mp3를 다운로드한 다음 병합하여 하나의 출력 파일을 만들려고 합니다. 사용되는 도구는 Mac에서 youtube-dl
및 입니다.fmpeg
1 단계
youtube-dl
시간 범위 내 오디오 다운로드 명령:
youtube-dl -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 <YoutubeUrl> --no-check-certificate --output "1.mp3" --external-downloader ffmpeg --external-downloader-args "-ss 00:00:00.00 -to 00:00:56.00"
2 단계
출력 파일 이름은 다음과 같습니다 input.txt
.
file '1.mp3'
file '2.mp3'
3단계
ffmpeg
모든 mp3 파일을 병합하는 명령:
ffmpeg -f concat -safe 0 -i input.txt -c copy output.mp3 -c:a libmp3lame
문제
mp3 파일 병합 중 다음 오류가 깜박입니다.
[mp3 @ 0x7fdd4e812600] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
질문
- 어떻게 해결하나요? 인코딩에 문제가 있는 것 같습니다.
- 2단계와 3단계를 하나의 명령으로 결합하는 것에 대한 권장 사항이 있습니까?
답변1
concat
필터를 사용하여 2단계와 3단계를 하나의 명령으로 결합할 수 있습니다 .
ffmpeg -i 1.mp3 -i 2.mp3 -filter_complex "[0:a][1:a]concat=n=2:v=0:a=1[a]" -map "[a]" -c:a libmp3lame output.mp3
이 명령으로 다른 문제도 해결되는지 알려주세요.