TheWidlarzGroup/react-native-video

[iOS]Video(mp4) with two audio tracks both disposition default set can play only first track

Open

#2,927 opened on 2022年11月22日

GitHub で見る
 (8 comments) (0 reactions) (1 assignee)Kotlin (7,677 stars) (3,027 forks)batch import
6.x.xAcceptedPlatform: iOSbughelp wanted

説明

Bug

In iOS, when a video with multiple audio tracks is played and if both audio tracks are set as disposition default, then only one audio track is being considered by react-native-video for playing.

Platform

Which player are you experiencing the problem on:

  • iOS

In safari, the video plays fine with both audio tracks shown as options. So the issue is likely to be in this codebase.

Environment info

React native info output: FWIW we noticed the issue on older react-native(0.68) also

System:
    OS: macOS 13.0.1
    CPU: (8) arm64 Apple M1
    Memory: 70.06 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.2 - /private/var/folders/_j/19d37zp90s57mwb7m72352l40000gn/T/xfs-ea49d6c4/node
    Yarn: 3.2.0 - /private/var/folders/_j/19d37zp90s57mwb7m72352l40000gn/T/xfs-ea49d6c4/yarn
    npm: 8.5.0 - ~/Library/Caches/fnm_multishells/2244_1668186879933/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.11.3 - /var/folders/_j/19d37zp90s57mwb7m72352l40000gn/T/frum_2257_1668186879970/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.14.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.5 => 0.70.5 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 5.2.1

Steps To Reproduce

  1. Create an mp4 video with two audio tracks, both set default disposition.
  2. Play it in react-native-video in ios. Only one track will be visible/playable in the app. ...

Expected behaviour

  1. Player should show both audio tracks.

Reproducible sample code

  const handleOnLoad = (data: any) => {
    console.log({ data });
    console.log(data.audioTracks[0]);
    console.log(data.audioTracks[1]);
  };


<Video
  onLoad={handleOnLoad}
  source={{ uri: url }}
  style={{ width: '100%', height: '100%' }}
/>

The log showed only one audio track.

 LOG  {"data": {"audioTracks": [[Object]], "canPlayFastForward": true, "canPlayReverse": true, "canPlaySlowForward": true, "canPlaySlowReverse": true, "canStepBackward": true, "canStepForward": true, "currentTime": 0, "duration": 3.878000020980835, "naturalSize": {"height": 1080, "orientation": "landscape", "width": 1920}, "target": 3889, "textTracks": []}}
 LOG  {"index": 0, "language": "en", "title": "A"}
 LOG  undefined

Video sample

https://d3bm2z03a5d1kp.cloudfront.net/narrations/0d4197b0-7fc3-45b2-858b-05fd8977eb38/test.mp4

ffprobe of the sample:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : M4V 
    minor_version   : 1
    compatible_brands: isomavc1mp42
    creation_time   : 2022-11-22T17:32:24.000000Z
  Duration: 00:00:21.40, start: 0.000000, bitrate: 3376 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 3174 kb/s, 25 fps, 25 tbr, 25k tbn (default)
    Metadata:
      creation_time   : 2022-11-22T17:32:24.000000Z
      handler_name    : ETI ISO Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : Elemental H.264
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2022-11-22T17:32:24.000000Z
      handler_name    : ETI ISO Audio Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2022-11-22T17:32:24.000000Z
      handler_name    : ETI ISO Audio Media Handler
      vendor_id       : [0][0][0][0]

Notice that both the audio tracks have default set at the end.

After I did

ffmpeg -i test.mp4 -map 0:v:0 -map 0:a:0 -map 0:a:1 -c copy -disposition:a:0 default \
       -disposition:a:1 0 reordered.mp4

The reordered.mp4 plays fine in iOS.

PS: This issue is not happening in Android.

コントリビューターガイド