Youtube video und audio separat downloaden und mit ffmpeg mergen
Youtube video und audio separat downloaden und mit ffmpeg mergen
Ich weiß wie ich mit youtube-dl oder yt-dlp automatisch downloaden und automatisch mergen kann. Leider spielt mein DVB-T Tuner nur das Video ab, aber nicht den Ton, wenn ich das mit yt-dlp gemergte mp4 Video abspielen möchte. Der vlc spielt Video und Ton ab. Mit *.mkv als Kontainer habe ich das gleich Problem.
Deswegen möchte ich Video und Audio separat downloaden und mit ffmpeg mergen.
An den von Youtube angebotenen vor-gemerged'ten mp4 Videos (22) bin ich nicht interessiert. Die gehen nur bis 1280x720. Ich möchte das Video in 1920x1080 mp4 Videoformat und dazu das passende Audio. Ich weiß nicht was das passende Audioformat ist, aber ich denke es ist m4a, wenn ich als Ausgabe *.mp4 haben möchte.
Kann mir bitte jemand einen Tipp geben, wie ich das mit ffmpeg merge und welches Audioformat ich downloaden muß?
Deswegen möchte ich Video und Audio separat downloaden und mit ffmpeg mergen.
An den von Youtube angebotenen vor-gemerged'ten mp4 Videos (22) bin ich nicht interessiert. Die gehen nur bis 1280x720. Ich möchte das Video in 1920x1080 mp4 Videoformat und dazu das passende Audio. Ich weiß nicht was das passende Audioformat ist, aber ich denke es ist m4a, wenn ich als Ausgabe *.mp4 haben möchte.
Kann mir bitte jemand einen Tipp geben, wie ich das mit ffmpeg merge und welches Audioformat ich downloaden muß?
-
- Beiträge: 265
- Registriert: 21.07.2009 13:50:22
- Lizenz eigener Beiträge: GNU General Public License
- Wohnort: Köln
Re: Youtube video und audio separat downloaden und mit ffmpeg mergen
Der Youtube Downloader zeigt dir einiges an.
Mit diesem Befehl:
zum Beispiel für Audio
Mit diesem Befehl:
Code: Alles auswählen
yt-dlp --help
Gruß soundrolfPost-Processing Options:
-x, --extract-audio Convert video files to audio-only files (requires
ffmpeg and ffprobe)
--audio-format FORMAT Specify audio format to convert the audio to when -x
is used. Currently supported formats are: best
(default) or one of aac, flac, mp3, m4a, opus,
vorbis, wav, alac
--audio-quality QUALITY Specify ffmpeg audio quality to use when converting
the audio with -x. Insert a value between 0 (best)
and 10 (worst) for VBR or a specific bitrate like
128K (default 5)
--remux-video FORMAT Remux the video into another container if necessary
(currently supported: mp4, mkv, flv, webm, mov, avi,
mka, ogg, aac, flac, mp3, m4a, opus, vorbis, wav,
alac). If target container does not support the
video/audio codec, remuxing will fail. You can
specify multiple rules; Eg. "aac>m4a/mov>mp4/mkv"
will remux aac to m4a, mov to mp4 and anything else
to mkv.
--recode-video FORMAT Re-encode the video into another format if re-
encoding is necessary. The syntax and supported
formats are the same as --remux-video
--postprocessor-args NAME:ARGS Give these arguments to the postprocessors. Specify
the postprocessor/executable name and the arguments
separated by a colon ":" to give the argument to the
specified postprocessor/executable. Supported PP are:
Merger, ModifyChapters, SplitChapters, ExtractAudio,
VideoRemuxer, VideoConvertor, Metadata,
EmbedSubtitle, EmbedThumbnail, SubtitlesConvertor,
ThumbnailsConvertor, FixupStretched, FixupM4a,
FixupM3u8, FixupTimestamp and FixupDuration. The
supported executables are: AtomicParsley, FFmpeg and
FFprobe. You can also specify "PP+EXE:ARGS" to give
the arguments to the specified executable only when
being used by the specified postprocessor.
Additionally, for ffmpeg/ffprobe, "_i"/"_o" can be
appended to the prefix optionally followed by a
number to pass the argument before the specified
input/output file. Eg: --ppa "Merger+ffmpeg_i1:-v
quiet". You can use this option multiple times to
give different arguments to different postprocessors.
(Alias: --ppa)
Re: Youtube video und audio separat downloaden und mit ffmpeg mergen
Genau das wollte ich vermeiden, weil - ich schrieb es in meinem Eingangspost - ich das bereits getestet habe und es hat nicht funktioniert. Ich habe jetzt nicht alle Optionen getestet, das dauert sicherlch Manntage, aber die Optionen die ich testete, ergaben bei mir ein video bei dem der Ton von meinem DVB-T Tuner nicht abgespielt wird. Deswegen wollte ich das einzeln Downloaden.soundrolf hat geschrieben:19.06.2022 12:54:46Der Youtube Downloader zeigt dir einiges an.
Mit diesem Befehl:zum Beispiel für AudioCode: Alles auswählen
yt-dlp --help
Gruß soundrolfPost-Processing Options:
-x, --extract-audio Convert video files to audio-only files (requires
ffmpeg and ffprobe)
--audio-format FORMAT Specify audio format to convert the audio to when -x
is used. Currently supported formats are: best
(default) or one of aac, flac, mp3, m4a, opus,
vorbis, wav, alac
--audio-quality QUALITY Specify ffmpeg audio quality to use when converting
the audio with -x. Insert a value between 0 (best)
and 10 (worst) for VBR or a specific bitrate like
128K (default 5)
--remux-video FORMAT Remux the video into another container if necessary
(currently supported: mp4, mkv, flv, webm, mov, avi,
mka, ogg, aac, flac, mp3, m4a, opus, vorbis, wav,
alac). If target container does not support the
video/audio codec, remuxing will fail. You can
specify multiple rules; Eg. "aac>m4a/mov>mp4/mkv"
will remux aac to m4a, mov to mp4 and anything else
to mkv.
--recode-video FORMAT Re-encode the video into another format if re-
encoding is necessary. The syntax and supported
formats are the same as --remux-video
--postprocessor-args NAME:ARGS Give these arguments to the postprocessors. Specify
the postprocessor/executable name and the arguments
separated by a colon ":" to give the argument to the
specified postprocessor/executable. Supported PP are:
Merger, ModifyChapters, SplitChapters, ExtractAudio,
VideoRemuxer, VideoConvertor, Metadata,
EmbedSubtitle, EmbedThumbnail, SubtitlesConvertor,
ThumbnailsConvertor, FixupStretched, FixupM4a,
FixupM3u8, FixupTimestamp and FixupDuration. The
supported executables are: AtomicParsley, FFmpeg and
FFprobe. You can also specify "PP+EXE:ARGS" to give
the arguments to the specified executable only when
being used by the specified postprocessor.
Additionally, for ffmpeg/ffprobe, "_i"/"_o" can be
appended to the prefix optionally followed by a
number to pass the argument before the specified
input/output file. Eg: --ppa "Merger+ffmpeg_i1:-v
quiet". You can use this option multiple times to
give different arguments to different postprocessors.
(Alias: --ppa)
Eigentlich muß ich nur wissen, ob m4a as Audiodatei OK ist. Den Teil mit ffmpeg kläre ich danach sicherlich selbst. Danke für den Tipp mit --help.
Re: Youtube video und audio separat downloaden und mit ffmpeg mergen
m4a ist nur eine Dateiendung, wo dann meistens ein AAC-Audio drin steckt. Aber ja, m4a ist ok. Im Übrigen benutzen youtube-dl und yt-dlp intern (wenn nicht anders konfiguriert) ffmpeg zum Zusammenführen der Spuren...mino23 hat geschrieben:19.06.2022 16:01:47Eigentlich muß ich nur wissen, ob m4a as Audiodatei OK ist. Den Teil mit ffmpeg kläre ich danach sicherlich selbst. Danke für den Tipp mit --help.
Re: Youtube video und audio separat downloaden und mit ffmpeg mergen
mino23 hat geschrieben: Eigentlich muß ich nur wissen, ob m4a as Audiodatei OK ist [...]
Code: Alles auswählen
yt-dlp -F https://www.youtube.com/watch?v=WLXhoFfV-YI
Muster:
Code: Alles auswählen
yt-dlp -f 136+140 https://www.youtube.com/watch?v=WLXhoFfV-YI
wobei f140 das Audio ist .m4a = acc
gruss MaGe
Wir müssen uns vor der Klimaerwärmung nicht fürchten.
Uns rottet die soziale Kälte viel früher aus.
Uns rottet die soziale Kälte viel früher aus.
Re: Youtube video und audio separat downloaden und mit ffmpeg mergen
Bei mir nicht!mino23 hat geschrieben: Bei *.mp4 und *.m4a zu mp4 wird die Audiospur neu codiert und die Datei ist unwesentlich kleiner. [...]
Muster: Video,Audio,getrennt
Code: Alles auswählen
time ffmpeg -i *.mp4 -i *.m4a -c copy JAMES_BOND-Trailer.mp4
gruss MaGe
Wir müssen uns vor der Klimaerwärmung nicht fürchten.
Uns rottet die soziale Kälte viel früher aus.
Uns rottet die soziale Kälte viel früher aus.
Re: Youtube video und audio separat downloaden und mit ffmpeg mergen
Hallo!
Da ich auch öfters Video und Audio zusammenfügen muß, da HD-Videos bei youtube-dl oft die Tonspur nicht enthalten, hatte ich mir mal ein kleines Script gemacht. Du mußt dafür aber noch "yad" installieren:
Die Dateinamen von Audio und Video sollten am besten keine Leerzeichen, Punkte, Ausrufungszeichen oder andere "Sonderzeichen" enthalten.
Da ich auch öfters Video und Audio zusammenfügen muß, da HD-Videos bei youtube-dl oft die Tonspur nicht enthalten, hatte ich mir mal ein kleines Script gemacht. Du mußt dafür aber noch "yad" installieren:
Code: Alles auswählen
#!/bin/bash
IFS="|"
if [ -e $HOME/.audio_und_video_zusammenfuegen ]
then
verzeichnis=`cat $HOME/.audio_und_video_zusammenfuegen`
cd "$verzeichnis"
fi
verzeichnis=`yad --width 800 --height 650 --center --title "Ziel-Verzeichnis wählen:" --file --directory`
case $? in
1) exit ;;
esac
echo "$verzeichnis" > $HOME/.audio_und_video_zusammenfuegen
cd "$verzeichnis"
yad --button "Start" --button Beenden \
--title "Audio und Video zusammenfügen" \
--form --center --align=right --width 600 \
--field "Audio-Datei wählen:":FL " " \
--field "Video-Datei wählen:":FL " " \
--field "Seitenverhältnis":CB 'Seitenverhältnis beibehalten!4:3!16:9' > .einlesen.tmp
case $? in
1) rm .einlesen.tmp; exit ;;
esac
audio=`cut -d"|" -f1 .einlesen.tmp`
video=`cut -d"|" -f2 .einlesen.tmp`
aspect=`cut -d"|" -f3 .einlesen.tmp`
i=-i
dateiname=`echo $video | cut -d"." -f1`
dateiname=`echo $dateiname | rev | cut -d"/" -f1 | rev`
endung=`echo $video | rev | cut -d"." -f1 | rev`
audio1=`echo $audio | rev | cut -d"/" -f1 | rev`
if [ "$audio1" = " " ]
then
audio=""
i=""
fi
case $aspect in
"Seitenverhältnis beibehalten") aspect1= aspect2= ;;
"4:3") aspect1="-aspect" aspect2="1.3333" ;;
"16:9") aspect1="-aspect" aspect2="1.7777" ;;
esac
# xterm -T "Kopiervorgang mit [q] beenden" -geometry 1111x20 -e
ffmpeg -i $video $i $audio \
-c copy \
$aspect1 $aspect2 \
-threads:1 4 \
$dateiname"_"$(date +%H-%M-%S).$endung
rm .einlesen.tmp
exit