ffmpeg $(youtube-dl -g 'https://www.youtube.com/watch?v=zSyNOO_gvUY' | sed "s/.*/-ss 02:04 -i &/") -t 02:18 - c 复制出.mkv
我使用 Windows、ubuntu 应用程序、shell bash
一切正常,从 bash 更新了 ffmpeg、youtube-dl,删除了 win 中旧路径的环境路径,重启电脑
答案1
您的youtube-dl
命令打印两行、两个 URL:
$ youtube-dl -g 'https://www.youtube.com/watch?v=zSyNOO_gvUY'
https://r2---sn-vuxbavcx-5uik.googlevideo.com/videoplayback?expire=1607567417&ei=2TPRX-SuI8T9gAeIyZLQCQ&ip=2a02%3A587%3A2842%3A6400%3Ab699%3Afa7c%3A31d8%3A6cc1&id=o-AAcjRTgUT2T-n1BD565dtHH13_Xk-rO4Y2wTc2RccIYd&itag=299&aitags=133%2C134%2C135%2C136%2C160%2C242%2C243%2C244%2C247%2C278%2C298%2C299%2C302%2C303&source=youtube&requiressl=yes&mh=UA&mm=31%2C29&mn=sn-vuxbavcx-5uik%2Csn-4g5e6nsz&ms=au%2Crdu&mv=m&mvi=2&pl=36&initcwndbps=561250&vprv=1&mime=video%2Fmp4&ns=PEzwRrxyZjziBZla7m7o0IkF&gir=yes&clen=74141495&dur=355.499&lmt=1587833453663441&mt=1607545489&fvip=2&keepalive=yes&c=WEB&txp=5432432&n=b2QaOqTbS7KW643y&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANg2PZbMdOJ_jxHP9wg4wWgv0XuTMLYG0580c5iND6reAiEAya8-pi3kNi9x-Wrn9OUxgxjMkigiAQs5SPqXltstnKg%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgHwvGqlKR2YhHl4yuUKgGvBppwVqycYkM5nceha8moZcCIFmZOzbLeha7kZZiHgVPoAd3J5fAEeP7uoQs9v0oFoaR&ratebypass=yes
https://r2---sn-vuxbavcx-5uik.googlevideo.com/videoplayback?expire=1607567417&ei=2TPRX-SuI8T9gAeIyZLQCQ&ip=2a02%3A587%3A2842%3A6400%3Ab699%3Afa7c%3A31d8%3A6cc1&id=o-AAcjRTgUT2T-n1BD565dtHH13_Xk-rO4Y2wTc2RccIYd&itag=251&source=youtube&requiressl=yes&mh=UA&mm=31%2C29&mn=sn-vuxbavcx-5uik%2Csn-4g5e6nsz&ms=au%2Crdu&mv=m&mvi=2&pl=36&initcwndbps=561250&vprv=1&mime=audio%2Fwebm&ns=PEzwRrxyZjziBZla7m7o0IkF&gir=yes&clen=4768230&dur=355.601&lmt=1587833261724868&mt=1607545489&fvip=2&keepalive=yes&c=WEB&txp=5431432&n=b2QaOqTbS7KW643y&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAMsIKPks0_5GLe3qFb-_W1BUX-nhaRNE5LwusgGeEBW9AiEAnVmnSL6hsH5TGdelWPXn7SbreG0rHCj9jx9Rzutk6Ko%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgHwvGqlKR2YhHl4yuUKgGvBppwVqycYkM5nceha8moZcCIFmZOzbLeha7kZZiHgVPoAd3J5fAEeP7uoQs9v0oFoaR&ratebypass=yes
作为尼克·D指出,视频和音频都需要两个 URL,就像这样回答。所以这应该有效(也请注意.mkv
而不是.mp4
):
ffmpeg $(youtube-dl -g 'https://www.youtube.com/watch?v=zSyNOO_gvUY' | sed 's/.*/-ss 02:04 -i &/') -to 02:18 -c copy out.mkv
也不$()
应该引用,因为将由此形成两个参数。