File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -160,8 +160,14 @@ def pre_encode_if_necessary
160160
161161 def determine_audio_for_pre_encode ( path )
162162 local_movie = Movie . new ( path )
163- # If there's a local audio stream, use that
164- return '-map "0:a"' if local_movie . audio_streams . any?
163+ # If there's a local audio stream, use that. Map only decodable streams explicitly -
164+ # using -map "0:a" would include APAC (Apple Positional Audio Codec) from iPhone
165+ # spatial audio, which FFmpeg cannot decode. audio_streams already excludes these.
166+ if local_movie . audio_streams . any?
167+ puts "|| local_movie.audio_streams: #{ local_movie . audio_streams } "
168+ puts "|| local_movie.audio_streams inspect: #{ local_movie . audio_streams . inspect } "
169+ return local_movie . audio_streams . map { |s | "-map \" 0:#{ s [ :index ] } \" " } . join ( ' ' )
170+ end
165171 # Otherwise, use a silent audio source
166172 # | aevalsrc=0 will generate a silent audio source
167173 # | -shortest will make sure that the output is the duration of the shortest input (meaning the real source input)
Original file line number Diff line number Diff line change @@ -348,7 +348,8 @@ module FFMPEG
348348 transcoder = Transcoder . new ( movie_with_multiple_dimension_inputs , output_path , EncodingOptions . new )
349349
350350 expect ( Open3 ) . to receive ( :popen3 ) . exactly ( 2 ) . times # prevent ffprobe calls from being evaluated (check_frame_resolutions)
351- expect ( Open3 ) . to receive ( :popen3 ) . twice . with match ( /.*\[ 0\: v\] scale\= 854\: 480.*pad\= 854\: 480\: \( ow\- iw\) \/ 2\: \( oh\- ih\) \/ 2\: color\= black.*\- map \" 0\: a\" .*/ )
351+ # Maps decodable audio streams by index (excludes APAC); awesome_widescreen has 1 audio stream
352+ expect ( Open3 ) . to receive ( :popen3 ) . twice . with match ( /.*\[ 0\: v\] scale\= 854\: 480.*pad\= 854\: 480\: \( ow\- iw\) \/ 2\: \( oh\- ih\) \/ 2\: color\= black.*\- map \" 0\: \d +\" .*/ )
352353
353354 transcoder . send ( :pre_encode_if_necessary )
354355 end
@@ -360,7 +361,8 @@ module FFMPEG
360361 # Match silent audio fill
361362 expect ( Open3 ) . to receive ( :popen3 ) . once . with match ( /.*\[ 0\: v\] scale\= 960\: 540.*pad\= 960\: 540\: \( ow\- iw\) \/ 2\: \( oh\- ih\) \/ 2\: color\= black.*\- map \" \[ a\] \" .*/ )
362363 # Retain "real" audio
363- expect ( Open3 ) . to receive ( :popen3 ) . once . with match ( /.*\[ 0\: v\] scale\= 960\: 540.*pad\= 960\: 540\: \( ow\- iw\) \/ 2\: \( oh\- ih\) \/ 2\: color\= black.*\- map \" 0\: a\" .*/ )
364+ # Retain "real" audio - maps decodable audio streams by index
365+ expect ( Open3 ) . to receive ( :popen3 ) . once . with match ( /.*\[ 0\: v\] scale\= 960\: 540.*pad\= 960\: 540\: \( ow\- iw\) \/ 2\: \( oh\- ih\) \/ 2\: color\= black.*\- map \" 0\: \d +\" .*/ )
364366
365367 transcoder . send ( :pre_encode_if_necessary )
366368 end
You can’t perform that action at this time.
0 commit comments