Wie verwende ich ffmpeg -t, wenn Sie eine Live-YouTube-Quelle mit youtube-dl verwenden?

3458
gat00n

Ich wollte einen Youtube-Stream von https://www.youtube.com/watch?v=0R0T0mQmx7 herunterladen. Ich füge die Zeit hinzu, die ich mag. Daher bekomme ich mit youtube-dl alle Formate:

$ youtube-dl --list-formats https://www.youtube.com/watch?v=0R0T0mQmx7I [youtube] 0R0T0mQmx7I: Downloading webpage [youtube] 0R0T0mQmx7I: Downloading video info webpage [youtube] 0R0T0mQmx7I: Extracting video information [youtube] 0R0T0mQmx7I: Downloading MPD manifest [info] Available formats for 0R0T0mQmx7I: format code extension resolution note 140 m4a audio only DASH audio 144k, m4a_dash container, mp4a.40.2@128k 160 mp4 256x144 144p 124k, avc1.42c00b, 30fps, video only 133 mp4 426x240 240p 258k, avc1.4d4015, 30fps, video only 134 mp4 640x360 360p 646k, avc1.4d401e, 30fps, video only 135 mp4 854x480 480p 1171k, avc1.4d401f, 30fps, video only 136 mp4 1280x720 720p 2326k, avc1.4d401f, 30fps, video only (best) 

Mir wurde klar, dass Audio und Video in verschiedenen Formaten vorliegen, so dass es nicht einfach sein wird. Also benutze ich den folgenden Befehl, um Audio und Video zu extrahieren:

$ ffmpeg -i $(youtube-dl -f 136 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) -i $(youtube-dl -f 140 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) -c:v copy -c:a aac -strict experimental -t 00:02:00 output.mp4 

Aber es geht nicht. Es nimmt nur bis zu 5 Sekunden auf und das ist alles. Ich habe versucht, den Parameter "-t 00:02:00" an verschiedenen Stellen zu verschieben und funktioniert nicht. Kennt jemand die Lösung? Vielen Dank !!

BEARBEITET: Ausgabe hinzufügen

$ ffmpeg -i $(youtube-dl -f 136 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) -i $(youtube-dl -f 140 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) -c:v copy -c:a aac -strict experimental -t 00:02:00 output.mp4 ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609 configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://r1---sn-j5cax8pnpvo-x1xe6.googlevideo.com/videoplayback?keepalive=yes&source=yt_live_broadcast&pl=24&itag=136&mime=video%2Fmp4&expire=1521354001&c=WEB&sparams=aitags%2Ccmbypass%2Cei%2Cgcr%2Cgir%2Chang%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clive%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnoclen%2Cpl%2Crequiressl%2Csource%2Cexpire&aitags=133%2C134%2C135%2C136%2C160&signature=727E04BDE2851159A8A9327CDBAB503BBDC37267.2168845A24D2FFD5496AA2F5D2D6AACA59BB69D2&cmbypass=yes&ipbits=0&hang=1&beids=%5B9466592%5D&ms=lv&mt=1521331971&mv=u&live=1&key=yt6&ip=152.168.37.75&id=0R0T0mQmx7I.0&gir=yes&mm=32&mn=sn-j5cax8pnpvo-x1xe6&ei=sbCtWvOcLJTWxAS644e4Ag&noclen=1&gcr=ar&requiressl=yes&ratebypass=yes': Metadata: major_brand : dash minor_version : 0 compatible_brands: iso6avc1mp41 creation_time : 2018-03-17 07:02:10 Duration: 00:00:05.00, start: 0.000000, bitrate: 2419 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2413 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default) Metadata: creation_time : 2018-03-17 07:02:10 handler_name : VideoHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'https://r1---sn-j5cax8pnpvo-x1xe6.googlevideo.com/videoplayback?ip=152.168.37.75&mm=32&mn=sn-j5cax8pnpvo-x1xe6&expire=1521354004&pl=24&gir=yes&signature=16F13864FDF56FFDF2E08B248355CD1257D2E4FF.C7DBD2A865733005704660CD0EA82A90EFCFC03D&id=0R0T0mQmx7I.0&mt=1521331971&mv=u&ms=lv&hang=1&ipbits=0&itag=140&gcr=ar&requiressl=yes&source=yt_live_broadcast&keepalive=yes&ei=s7CtWsq0Ko7UxQT__pSgBA&noclen=1&sparams=cmbypass%2Ccompress%2Cei%2Cgcr%2Cgir%2Chang%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clive%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnoclen%2Cpl%2Crequiressl%2Csource%2Cexpire&cmbypass=yes&compress=yes&key=yt6&mime=audio%2Fmp4&c=WEB&live=1&ratebypass=yes': Metadata: major_brand : dash minor_version : 0 compatible_brands: iso6mp41 creation_time : 2018-03-17 07:02:09 Duration: 00:00:04.99, start: 0.000000, bitrate: 130 kb/s Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default) Metadata: creation_time : 2018-03-17 07:02:09 handler_name : SoundHandler [mp4 @ 0x264eb20] Codec for stream 0 does not use global headers but container format requires global headers Output #0, mp4, to 'output.mp4': Metadata: major_brand : dash minor_version : 0 compatible_brands: iso6avc1mp41 encoder : Lavf56.40.101 Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2413 kb/s, 30 fps, 30 tbr, 90k tbn, 90k tbc (default) Metadata: creation_time : 2018-03-17 07:02:10 handler_name : VideoHandler Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: creation_time : 2018-03-17 07:02:09 handler_name : SoundHandler encoder : Lavc56.60.100 aac Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help frame= 150 fps=0.0 q=-1.0 Lsize= 1557kB time=00:00:04.99 bitrate=2555.6kbits/s  video:1473kB audio:79kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.353100% 
3
Können Sie die vollständige, ungeschnittene Ausgabe von ffmpeg hinzufügen? bertieb vor 6 Jahren 0
Ich habe die gesamte Ausgabe hinzugefügt. Vielen Dank! gat00n vor 6 Jahren 1
Funktioniert es * ohne * `-t`? Und funktioniert Ihr `-t`-Befehl mit heruntergeladenen Dateien anstelle von URLs? Peter Cordes vor 6 Jahren 0
Erste Frage: Ohne "-t" nur 5 Sekunden aufnehmen Zweitens: Die Verwendung anderer URLs funktioniert einwandfrei, aber ich habe noch nie zwei Eingaben in ffmeg verwendet. Die Aufnahme von nur 5 Sekunden scheint etwas komisch zu sein ... gat00n vor 6 Jahren 0

1 Antwort auf die Frage

3
bertieb

tl; dr : Update ffmpeg± youtube-dl.

Die Ausgabe der Konsole war hilfreich!

Ihre Eingaben werden nur als 5 Sekunden erkannt

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://r1---sn-j5cax8pnpvo-x1xe6.googlevideo.com/videoplayback?keepalive=yes&source=yt_live_broadcast&pl=24&itag=136&mime=video%2Fmp4&expire=1521354001&c=WEB&sparams=aitags%2Ccmbypass%2Cei%2Cgcr%2Cgir%2Chang%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clive%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnoclen%2Cpl%2Crequiressl%2Csource%2Cexpire&aitags=133%2C134%2C135%2C136%2C160&signature=727E04BDE2851159A8A9327CDBAB503BBDC37267.2168845A24D2FFD5496AA2F5D2D6AACA59BB69D2&cmbypass=yes&ipbits=0&hang=1&beids=%5B9466592%5D&ms=lv&mt=1521331971&mv=u&live=1&key=yt6&ip=152.168.37.75&id=0R0T0mQmx7I.0&gir=yes&mm=32&mn=sn-j5cax8pnpvo-x1xe6&ei=sbCtWvOcLJTWxAS644e4Ag&noclen=1&gcr=ar&requiressl=yes&ratebypass=yes': Metadata: ... Duration: 00:00:05.00, start: 0.000000, bitrate: 2419 kb/s  Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'https://r1---sn-j5cax8pnpvo-x1xe6.googlevideo.com/videoplayback?ip=152.168.37.75&mm=32&mn=sn-j5cax8pnpvo-x1xe6&expire=1521354004&pl=24&gir=yes&signature=16F13864FDF56FFDF2E08B248355CD1257D2E4FF.C7DBD2A865733005704660CD0EA82A90EFCFC03D&id=0R0T0mQmx7I.0&mt=1521331971&mv=u&ms=lv&hang=1&ipbits=0&itag=140&gcr=ar&requiressl=yes&source=yt_live_broadcast&keepalive=yes&ei=s7CtWsq0Ko7UxQT__pSgBA&noclen=1&sparams=cmbypass%2Ccompress%2Cei%2Cgcr%2Cgir%2Chang%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clive%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnoclen%2Cpl%2Crequiressl%2Csource%2Cexpire&cmbypass=yes&compress=yes&key=yt6&mime=audio%2Fmp4&c=WEB&live=1&ratebypass=yes': Metadata: ... Duration: 00:00:04.99, start: 0.000000, bitrate: 130 kb/s 

Deine ffmpegVersion ist ziemlich alt

ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers

2.8 stammt aus etwa Anfang 2016, was ich sagen kann. Es wird dringend empfohlen, auf das neueste zu aktualisieren ffmpeg. vorzugsweise die neueste git HEAD, aber ansonsten könnte diese PPA für Ubuntu von Nutzen sein .

Aktualisieren Sie auch Ihre youtube-dlVersion

Ich bekomme eine ganz andere Ausgabe von Ihnen für dieselbe URL:

$ youtube-dl --list-formats https://www.youtube.com/watch?v=0R0T0mQmx7I [youtube] 0R0T0mQmx7I: Downloading webpage [youtube] 0R0T0mQmx7I: Downloading video info webpage [youtube] 0R0T0mQmx7I: Extracting video information [youtube] 0R0T0mQmx7I: Downloading m3u8 information [youtube] 0R0T0mQmx7I: Downloading MPD manifest [info] Available formats for 0R0T0mQmx7I: format code extension resolution note 91 mp4 256x144 HLS 197k, avc1.42c00b, 30.0fps, mp4a.40.5@ 48k 92 mp4 426x240 HLS 338k, avc1.4d4015, 30.0fps, mp4a.40.5@ 48k 93 mp4 640x360 HLS 829k, avc1.4d401e, 30.0fps, mp4a.40.2@128k 94 mp4 854x480 HLS 1380k, avc1.4d401f, 30.0fps, mp4a.40.2@128k 95 mp4 1280x720 HLS 2593k, avc1.4d401f, 30.0fps, mp4a.40.2@256k (best) $ youtube-dl --version 2018.03.14 

Mit einem aktuellen ffmpegund youtube-dlVersion, erhalten Sie das erwartete Ergebnis:

$ ffmpeg -i $(youtube-dl -f 91 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) \ -i $(youtube-dl -f 95 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) \ -c:v copy -c:a aac -strict experimental -t 00:02:00 output.mp4  (...)  $ ffprobe output.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.83.100 Duration: 00:02:00.02, start: 0.000000, bitrate: 1784 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1648kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default) Metadata: handler_name : SoundHandler 

Beispielausgabe (Video), angepasst an das Upload-Limit von 2 MB:

enter image description here

Volle Ausgabe vom ffmpegAufruf .

Vielen Dank !! Es funktioniert, aber beim Ansehen des Ausgabevideos wurde mir klar, dass es mehrmals einfriert. Wissen Sie, ob es etwas mit einem fehlenden Parameter zu tun haben könnte? Ich verwende cmd: $ ffmpeg -i $ (youtube-dl -f 95 -g https://www.youtube.com/watch?v=0R0T0mQmx7I) -t 00:02:00 output.ts` gat00n vor 6 Jahren 0
Der Fehler scheint darin zu liegen, 5 Segmente vorauszusagen, abgelaufen von den Wiedergabelisten, dass es in der Ausgabe steht. Ich weiß nicht, wie ich damit umgehen soll ... gat00n vor 6 Jahren 0
Hilfe beim Überspringen von Segmenten? gat00n vor 6 Jahren 0
@ gat00n Ich sehe diese Meldungen nicht in der Ausgabe, die ich hier habe; Ich muss mir die 2 Minuten Probe ansehen, die ich produziert habe, um zu sehen, ob es irgendwelche Sprünge gibt. Das klingt nach einer [neuen Frage] (https://superuser.com/questions/ask) (die möglicherweise als Referenz auf diese Frage verweist), da es sich um ein anderes Thema handelt :) bertieb vor 6 Jahren 0
Das ist sicher. Ich habe deine Antwort bestätigt. Vielen Dank! gat00n vor 6 Jahren 0
@ gat00n Danke :) Ich werde nach der dazugehörigen Frage Ausschau halten! bertieb vor 6 Jahren 0