0

I am downloading channel audios with following script:

#!/bin/bash
...............
youtube-dl -o "%(upload_date)s %(title)s.%(ext)s" --write-annotations --download-archive "$ArchiveFile" --add-metadata --write-sub --sub-lang ru --write-auto-sub --sub-format srt -f "bestaudio[ext=webm]" -i "$ChannelPath"

With these parameters file names are written in following format:

yyyymmdd Corrected video title text.webm

After that I convert WEBM to MP3 with ffmpeg which takes over all the tags from WEBM file.

I would like that not only the file name, but also title written to ID3 tag is prepended with yyyymmdd time stamp, too. I could take some tool and write file name into corresponding ID3 tag.

The problem is that title in ID3 tag fully corresponds to video title and file name is a corrected title, with removed forbidden characters.

How to take the MP3 title from ID3 title tag and prepend it with time stamp?

2 Answers 2

0
  1. Convert the WebM to MP3 with ffmpeg:

    ffmpeg -i input.webm -map 0:a output.mp3
    
  2. Use ffprobe to get the embedded date and title metadata and write it with eyeD3 or id3v2:

    eyeD3 --title "$(ffprobe -v error -show_entries format_tags=DATE -of csv=p=0 "input.webm") $(ffprobe -v error -show_entries format_tags=title -of csv=p=0 "input.webm")" output.mp3
    

    ffmpeg can write ID3v2 tags, but it has some issues, so eyeD3 is recommended instead.

0

I ended up using a script like that:

#!/bin/bash
# File names will have following format "yyyymmdd Title.webm"
/usr/local/bin/youtube-dl -o "%(upload_date)s %(title)s.%(ext)s" --write-annotations --download-archive ".archive" --add-metadata -f "bestaudio[ext=webm]" -i "$ChannelPath"
for name in *.webm; do
  # Recode to MP3
  /usr/bin/ffmpeg -i "$name" -acodec libmp3lame "${name%.*}.mp3"
  # Get title from WEBM tag
  video_title=$(ffprobe -v error -show_entries format_tags=TITLE -of csv=p=0 "$name")
  # We know file name format, lets extract timestamp from it
  timestamp=${name%%[[:space:]]*}
  # Concatenate timestamp with internal title
  eyeD3 -t "$timestamp $video_title" "${name%.*}.mp3"
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.