bindestriche / srt_fix

yt-autosub-srt-fix a yt-dlp plugin to fix double lines of youtube subtitles converted to srt via ffmpeg
The Unlicense
32 stars 5 forks source link

feature request :combine Multi-sub to single file #16

Closed hunterHungry closed 3 months ago

hunterHungry commented 5 months ago

combine Multi-sub to single file

bindestriche commented 5 months ago

Can you please elaborate?

hunterHungry @.***> schrieb am Mi., 1. Mai 2024, 13:13:

combine Multi-sub to single file

— Reply to this email directly, view it on GitHub https://github.com/bindestriche/srt_fix/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATZWN6RRVLTVAODFJ6QLMPDZADE47AVCNFSM6AAAAABHB2FQ6WVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3TGMZUGEZDKMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

hunterHungry commented 5 months ago

Can you please elaborate? hunterHungry @.> schrieb am Mi., 1. Mai 2024, 13:13: combine Multi-sub to single file — Reply to this email directly, view it on GitHub <#16>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATZWN6RRVLTVAODFJ6QLMPDZADE47AVCNFSM6AAAAABHB2FQ6WVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3TGMZUGEZDKMQ . You are receiving this because you are subscribed to this thread.Message ID: @.>

Pic

I often need to read bilingual subtitles because I am not familiar with foreign languages and cannot read them fluently. However, if I only read the automatic translation of my mother tongue, some words may lost real meaning.

I don’t know if the following two points can be achieved.

  1. Convert multi-line files to single lines.
  2. According to the subtitle title suffix, merge the text of the same title and different languages and convert it into a bilingual subtitle.

I am currently using the YouTube™ Dual Caption plugin to download subtitles, but it can only be downloaded one by one manually.

bindestriche commented 3 months ago

that's out of scope for this extension. I also don't quite understand how exactly those rows should be merged. Line break are not treated consistently across video players

hunterHungry commented 3 months ago

that's out of scope for this extension. I also don't quite understand how exactly those rows should be merged. Line break are not treated consistently across video players

Thanks

mrfragger commented 2 weeks ago

Here's part of what I use...in a bash script ..using pysubs. merge either 2, 3 or 4 subs into one. Still think it's better to keep them separate as almost all media players support dual subs.


     "Combine 2 languages into one vtt/srt")
      clear
      echo "combine / merge two vtt subtitles into one vtt subtitle"
      echo "this is NOT cd1.vtt + cd2.vtt joining subtitles"
      echo "rename your two subtitles to top.vtt and bottom.vtt"
      echo "example English.vtt --> bottom.vtt"
      echo "and Spanish.vtt --> top.vtt"
      read -p "Press ENTER to continue or m (Main Menu) " choice
      [[ "$choice" == [Mm]* ]] && exec "$0" || echo "combining"
      python3 << EOF
import pysubs2
from pysubs2 import SSAFile
subs_top = pysubs2.load("top.vtt")
subs_bottom = pysubs2.load("bottom.vtt")
subs = SSAFile()
for e in subs_bottom:
    subs.append(e)
for e in subs_top:
    subs.append(e)
subs.save("source/combinedsubs.vtt") 
EOF
    ffmpeg -hide_banner -i source/combinedsubs.vtt source/combinedsubs.srt 
    echo "combinedsubs.vtt and combinedsubs.srt"
    echo "have been created in source/"
    echo ""
    read -p "Press ENTER to continue"
      ;;
      "Combine 3 languages into one vtt/srt")
      clear
      echo "combine / merge three vtt subtitles into one vtt subtitle"
      echo "rename your three subtitles to"
      echo "top.vtt, middle.vtt and bottom.vtt"
      echo "example English.vtt --> bottom.vtt"
      echo "German.vtt --> middle.vtt"
      echo "Spanish.vtt --> top.vtt"
      read -p "Press ENTER to continue or m (Main Menu) " choice
      [[ "$choice" == [Mm]* ]] && exec "$0" || echo "combining"
      python3 << EOF
import pysubs2
from pysubs2 import SSAFile
subs_top = pysubs2.load("top.vtt")
subs_middle = pysubs2.load("middle.vtt")
subs_bottom = pysubs2.load("bottom.vtt")
subs = SSAFile()
for e in subs_bottom:
    subs.append(e)
for e in subs_middle:
    subs.append(e)
for e in subs_top:
    subs.append(e)
subs.save("source/combinedsubs.vtt") 
EOF
    ffmpeg -hide_banner -i source/combinedsubs.vtt source/combinedsubs.srt
    echo "combinedsubs.vtt and combinedsubs.srt"
    echo "have been created in source/"
    echo ""
    read -p "Press ENTER to continue"
      ;;
      "Combine 4 languages into one vtt/srt")
      clear
      echo "combine / merge four vtt subtitles into one vtt subtitle"
      echo "rename your four subtitles to"
      echo "tiptop.vtt, top.vtt, middle.vtt and bottom.vtt"
      echo "example English.vtt --> bottom.vtt"
      echo "German.vtt --> middle.vtt"
      echo "Spanish.vtt --> top.vtt"
      echo "Japanese.vtt --> peak.vtt"
      echo "peak.vtt is the highest, above top.vtt"
      read -p "Press ENTER to combine or m (Main Menu) " choice
      [[ "$choice" == [Mm]* ]] && exec "$0" || echo "combining"
      python3 << EOF
import pysubs2
from pysubs2 import SSAFile
subs_peak = pysubs2.load("peak.vtt")
subs_top = pysubs2.load("top.vtt")
subs_middle = pysubs2.load("middle.vtt")
subs_bottom = pysubs2.load("bottom.vtt")
subs = SSAFile()
for e in subs_bottom:
    subs.append(e)
for e in subs_middle:
    subs.append(e)
for e in subs_top:
    subs.append(e)
for e in subs_peak:
    subs.append(e)
subs.save("source/combinedsubs.vtt") 
EOF
    ffmpeg -hide_banner -i source/combinedsubs.vtt source/combinedsubs.srt
    echo "combinedsubs.vtt and combinedsubs.srt"
    echo "have been created in source/"
    echo ""
    read -p "Press ENTER to continue"
      ;;