6

I have the following command that I have used to create an MP4 video file from an image and an MP3 file, it plays fine in a Chrome browser on desktop and on an Android phone - but it doesn't work on an iPhone 10. Do I need some extra codec or setting to make this compatible for iPhone? Should I be converting this into a MPEG file instead for wider compatibility?

ffmpeg -loop 1 -i 6f4aa5dfefc4dd32186f41315ad9d1e2-0.png -i "music.mp3" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest aa-image0.mp4

Here are the ffprobe details for the input MP3 file used to create the MP4 video and also the ffprobe for that output file:

Input #0, wav, from 'download0.mp3':
  Duration: 00:00:35.94, bitrate: 384 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 24000 Hz, 1 channels, s16, 384 kb/s
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'aa-image0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.22.100
  Duration: 00:00:38.76, start: 0.000000, bitrate: 505 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2664x1498 [SAR 1:1 DAR 1332:749], 367 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 138 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

The video seems to play on the iPhone, but the audio seems to start/stop constantly. Like it is a streaming issue (even though it is not). Maybe an MP3 encoding issue when I created the video?

Here are the test files I have used and created (any iPhone users will likely find the MP4 will not play the audio in the video properly):

https://ffmpeg-iphone-issue.netlify.com/tesla.jpg

https://ffmpeg-iphone-issue.netlify.com/tesla.mp3

https://ffmpeg-iphone-issue.netlify.com/tesla.mp4 (OUTPUT - Created from the 2 files above)


In summary, two FFmpeg commands are required:

1) Used to create iPhone/iOS compatible videos in FFmpeg from an image and MP3 (A slight modification to the command at the top of the page)

and

2) An FFmpeg command that could be used to fix or re-encode the video above so that it works on iPhone (A new command incorporating the parts so it works with iPhone and then to rebuild and fix the "broken" video. In a similar fashion to this video where he fixes a broken video https://www.youtube.com/watch?v=2FhmbKKh6mc [command in Youtube description])

Gracie
  • 896
  • 5
  • 14
  • 34
  • `newyork.mp4` plays fine for me in Safari on an iPhone. – llogan Feb 19 '20 at 19:33
  • Thanks @llogan - stangely the ffprobe for the newyork.mp3 file seems to have different attributes. So I have used the MP3 sample (Tesla) from the problem video batch. Perhaps this highlights that the MP3 file could be the issue, but as we have over 100 videos to fix this is the Tesla sample we will work with. But for ref, this was the newyork.mp3 output ```Input #0, mp3, from 'newyork.mp3': Duration: 00:00:24.26, start: 0.000000, bitrate: 32 kb/s Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s``` – Gracie Feb 19 '20 at 21:32
  • `tesla.mp4` also played normally on iPhone 6, iOS 12.4.5. How can I duplicate the issue you are experiencing? – llogan Feb 19 '20 at 22:48

1 Answers1

0

Maybe try to use the ipod mp4 muxer using -f ipod:

ffmpeg -loop 1 -i 6f4aa5dfefc4dd32186f41315ad9d1e2-0.png -i "music.mp3" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest -f ipod aa-image0.mp4

Mattias Wadman
  • 11,172
  • 2
  • 42
  • 57