damus-io / damus

iOS nostr client
GNU General Public License v3.0
2k stars 288 forks source link

Support MKV video files with multiple audio tracks (e.g. multiple languages) #2461

Open alltheseas opened 1 month ago

alltheseas commented 1 month ago

User Story I

As a Damus user who is a content creator with a multi-lingual audience, I would like to be able to upload media with audio in multiple languages, so that I achieve localization of media in one upload.

acceptance criteria

Tbc

User Story II

As a Damus user who is a content creator with a multi-lingual audience, I would like damus users to be able to play media with audio in their preferred language, so that they can better understand the content I

acceptance criteria

Tbc

Describe alternatives you've considered Upload multiple videos, and maintain separate npubs and/or follow lists for each respective language of my aucience.

Additional context Via Ser sleepy. I asked for an example dual language dubbed video. @semisol advised iOS player should natively support Unsure if nostr.build supports this functionality

alltheseas commented 1 month ago

File type requested is MKV.

See https://matroska.org/index.html

alltheseas commented 1 month ago

Example event via sleepy

https://damus.io/nevent1qqs0glft582n06hrdczpjrn3n6jz0gs4de5c66r7re3gd68ulct2xlqprdmhxue69uhhyetvv9ujucnfw33k76twwpshy6ewvdhk6qgewaehxw309ac8junpd45kgtnxd9shg6npvchxxmmdqyg8wumn8ghj7vf5xqhxvdm69e5k7qgkwaehxw309an8yetwwvhxummnw3erztnrdaksda7456

https://archive.org/download/paprika-bd-2006-1080p-dual-audio_202112/Paprika%20BD%20%282006%29%20%5B1080p%5D%20%5BDUAL-AUDIO%5D.zip/Paprika%20BD%20%282006%29%20%5B1080p%5D%20%5BDUAL-AUDIO%5D.mkv

alltheseas commented 1 month ago

@fishcakeday ser 👀

Have yall considered MKV support? Is it a premium feature maybe for NB?

alltheseas commented 1 month ago

Current behavior view in damus

image

On interaction

image

@jb55 advises MKV is a wrapper, and not necessarily a widely adopted solution among multiple nostr or non-nostr apps.

Need research on figuring out what is the best standard?

alltheseas commented 1 month ago

According to gpt4 it might be possible to audio multi audio tracks to mp4, although player support is another question altogether

Creating an MP4 video file with multiple dubbed audio tracks can be done using various video editing and encoding software. Here’s a general step-by-step guide using a popular tool called FFmpeg, which is a powerful command-line utility for handling multimedia files:

Using FFmpeg

  1. Install FFmpeg:

    • Download and install FFmpeg from the official website or use a package manager if you're on Linux or macOS.
  2. Prepare Your Files:

    • Ensure you have your video file (e.g., video.mp4) and the audio files for each dubbed track (e.g., audio_en.mp3, audio_es.mp3, etc.).
  3. Use FFmpeg Command:

    • Open your command line interface (Terminal on macOS/Linux or Command Prompt on Windows).
    • Use the following command to combine the video with multiple audio tracks:
    ffmpeg -i video.mp4 -i audio_en.mp3 -i audio_es.mp3 -map 0:v -map 1:a -map 2:a -c:v copy -c:a aac -b:a 192k output.mp4
    • In this command:
      • -i video.mp4 specifies the input video file.
      • -i audio_en.mp3 and -i audio_es.mp3 specify the input audio files.
      • -map 0:v maps the video stream from the first input (the video).
      • -map 1:a and -map 2:a map the audio streams from the second and third inputs (the audio tracks).
      • -c:v copy copies the video codec without re-encoding.
      • -c:a aac specifies the audio codec for the output.
      • -b:a 192k sets the audio bitrate.
      • output.mp4 is the name of the resulting file.
  4. Check the Output:

    • After running the command, you should have an output.mp4 file that contains the video and multiple audio tracks.

Using Video Editing Software

If you prefer a graphical user interface, you can use video editing software like:

Steps in Video Editing Software:

  1. Import Video and Audio: Open your video editing software and import the video file and audio tracks.
  2. Add to Timeline: Place the video on the timeline and add each audio track to separate audio channels.
  3. Export Settings: When exporting, ensure you select the option to include multiple audio tracks.
  4. Export: Choose MP4 as the output format and export the file.

Conclusion

Using either FFmpeg or video editing software, you can create an MP4 file with multiple dubbed audio tracks. Make sure to test the output file in a compatible media player to ensure that all audio tracks are accessible.

fishcakeday commented 1 month ago

@alltheseas MKV is just a container, and not the best one for the streaming purposes due to the lack of wide adoption and support. MP4 does support multiple tracks for sound and even subtitles. We do not have plans to support MKV, it also serves as deterrent from violation of our TOS, where we do not allow upload and sharing of media that you do not have copyrights to.