Absortio

Email → Summary → Bookmark → Email

GitHub - Saffron-sh/m2m: A minimal bash tool to convert video files to any other supported media files using yt-dlp and ffmpeg.

Extracto

A minimal bash tool to convert video files to any other supported media files using yt-dlp and ffmpeg. - Saffron-sh/m2m

Resumen

Resumen Principal

La herramienta m2m (Media to Media) se presenta como una utilidad de script bash altamente eficiente y versátil, diseñada para la descarga y conversión de contenido de video de YouTube a una amplia gama de formatos multimedia. Actuando como un puente entre la adquisición de medios y la transcodificación, m2m integra de manera fluida yt-dlp para la extracción de videos y ffmpeg para su conversión, automatizando un proceso que de otro modo sería manual y tedioso. Su arquitectura permite a los usuarios no solo descargar videos individuales o listas de reproducción enteras, sino también gestionar descargas por lotes, ofreciendo flexibilidad a través de modos limitados o infinitos. La característica distintiva de eliminar el archivo original después de la conversión optimiza el espacio de almacenamiento, mientras que la capacidad de personalizar los directorios de salida y el formato de los archivos finales confiere un control excepcional sobre la biblioteca multimedia personal, posicionando a m2m como una herramienta esencial para la gestión de contenido en entornos basados en terminal.

Elementos Clave

  • Proceso Integrado de Descarga y Conversión: m2m simplifica radicalmente el flujo de trabajo al combinar las potentes capacidades de yt-dlp para obtener el video desde una URL de YouTube y ffmpeg para realizar la conversión a cualquier formato de medios compatible. Este proceso es completamente automatizado: una vez que el video se

Contenido

m2m

A minimal bash tool to convert YouTube video files to any other supported media files.

"m2m" stands for Media to Media.

How it works:

  • Fetches the video from the URL using yt-dlp
  • Saves it in your $YTDIR directory ($YTDIR=$HOME/Music/ytdownloads by default)
  • Or in your $MULTI_DIR directory for batch downloads ($MULTI_DIR=$HOME/Music/ytdownloads/multi_mode by default)
  • Uses ffmpeg to convert the video to another file format
  • Deletes the original video file and saves the converted file to $YTDIR

Dependencies

Usage:

For single downloads:

m2m "https://www.youtube.com/watch?v=EYI489Dc4Sc" outputfile.mp3

Change the extension form .mp3 to anything you like.

For batch downloads:

You can change the 5 to the number of files you want to download.
(Or you can set is as n if you want it to run infinitely until you type done as the url.)
It would prompt you for the URL and then for the name you want to save the file as

m2m -m 2
Enter the URL: https://youtu.be/3JZ_D3ELwOQ
Enter the name to save it as: song_one.wav
Enter the URL: https://youtu.be/L_jWHffIx5E
Enter the name to save it as: song_two.mkv
[*] Initiating download for stream 1
[✓] Stream 1 downloaded
[*] Converting stream 1
[✓] Stream 1 saved to filesystem

[*] Initiating download for stream 2
[✓] Stream 2 downloaded
[*] Converting stream 2
[✓] Stream 2 saved to filesystem

... #And so on

For downloading Playlists from youtube

[usernorm@xarch ~]$ m2m -pl 'https://youtube.com/playlist?list=PLb9fYCYT16Y62EXx79LCfXc1jDxdsR9jf&si=hU-KoFIK4O6ob8pq'
[*] Aquiring playlist data from YouTube
[*] Playlist data aquired, choose an extension (default: wav) 
>>wav           # <--- You can choose any media format supported by ffmpeg
[*] Downloading stream 1 (Issam_Alnajjar__Hadal_Ahbek_Performance_Video)
[✓] Stream 1 downloaded 
[*] Converting stream 1 
[✓] Stream 1 saved to filesystem 

[*] Downloading stream 2 (Clandestina__Emma_Peters_lyrical_video_lyricalvideo_song_trending_music_shortsmusic)
[✓] Stream 2 downloaded 
[*] Converting stream 2 
[✓] Stream 2 saved to filesystem 

[*] Downloading stream 3 (Luis_Fonsi__Despacito_ft_Daddy_Yankee)
[✓] Stream 3 downloaded 
[*] Converting stream 3 
[✓] Stream 3 saved to filesystem 

[*] Downloading stream 4 (Gabry_Ponte_KEL__Tarantella)
[✓] Stream 4 downloaded 
[*] Converting stream 4 
[✓] Stream 4 saved to filesystem 

Infinite batch downloads:

m2m -m n

Enter the URL(type 'done' when you are done): https://youtu.be/oUfjhrSOFw8?si=GGCoI5J-5w4ejof-
Enter the name to save it as: stream01.mp4
Enter the URL(type 'done' when you are done): https://youtu.be/wN0x9eZLix4?si=2OXL-z7ldy7gAckO
Enter the name to save it as: stream02.mp4
Enter the URL(type 'done' when you are done): done
[*] Initiating download for stream 1 
[✓] Stream 1 downloaded 
[*] Converting stream 1 
[✓] Stream 1 saved to filesystem 

[*] Initiating download for stream 2 
[✓] Stream 2 downloaded 
[*] Converting stream 2 
[✓] Stream 2 saved to filesystem 

Notes

  • By default, downloads are saved in:
    • $HOME/Music/ytdownloads for single downloads.
    • $HOME/Music/ytdownloads/multi_mode for batch downloads.
    • $HOME/Music/ytdownloads/playlists for playlist downloads.
  • Also the error logs are saved in $HOME/.local/share by default, i'd personally suggest you keep it like that, but if you know what you are doing changing it would not have much effect.
  • You can add the -d flag followed by any path to have m2m save the file(s) there.
  • The playlist flags -pl|--playlist|-PL create a directory in $PLAYLIST_DIR by the name of the title of the playlist and all the files are saved in it.
  • You can change both $YTDIR and $MULTI_DIR as per your convenience.
  • You can convert to any media format supported by ffmpeg just don't forget to put the extension after the file name.
  • I have used -f best option for yt-dlp to fetch the highest quality stream available, however if you want to optimize m2m for less data usage, you can change that to any other stream you like.

Contributers

  • Big thanks to hamed for adding the output directory flag -d and the spinner download animation while file downloading and conversion.

Support

m2m was built mostly because I wanted it to exist.
If it helps you too, and you’d like to buy me a coffee (no pressure at all), you can tip a few sats here:

BTC (On-chain): bc1qsjjgj3yqvhe5dw0xlxqzch4zlqnlwqctchlztf

Every bit goes straight into caffeine and maintaining open-source code.

Fuente: GitHub