0

ffmpeg $(youtube-dl -g 'https://www.youtube.com/watch?v=zSyNOO_gvUY' | sed "s/.*/-ss 02:04 -i &/") -t 02:18 -c copy out.mkv

from How to download portion of video with youtube-dl command?

i use windows, ubuntu app, shell bash

EVERYTHING WORKING Made updates to ffmpeg, youtube-dl from bash, deleted env path's to old ones in win, pc restart

Timer Tak
  • 1
  • 2
  • When you change the command as suggested and get a different result, please [edit] your question, leave the original code as is, add some text that you tried a modified version, copy&paste the modified code and the corresponding output/error. Without seeing your modified command we don't know if you might have made a mistake. Please also add all additional information to the question instead of writing comments. – Bodo Dec 09 '20 at 20:27
  • 1
    The related question (I also linked this as duplicate of) How to download portion of video with youtube-dl command – thanasisp Dec 10 '20 at 06:10

1 Answers1

1

Your youtube-dl command prints two lines, two URLs:

$ 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

As NickD pointed, both URLS are needed for video and audio, like into this answer. So this should work (note also .mkv instead of .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

Also $() should not be quoted as two parameters will be formed from this.

thanasisp
  • 8,122
  • The two URLs correspond to the video and audio streams: you need both. The answer in the related question that @thanasisp mentions in a comment seems to be a correct way to extract a portion with both video and audio. – NickD Dec 09 '20 at 22:30
  • I get both URLs smooshed into one line in the value of x, separated by a space. Do you get them separated by a newline? WIth a space, the parsing of the two URLs does not work. – NickD Dec 09 '20 at 23:03