Body: <p>I am trying to convert an mp3 to mp4 with images. Below are two <code>ffmpeg</code> commands I tried.</p>
  
  <p>Length of mp3: 23 sec</p>
  
  <ol>
  <li>Here, the length of the video is same as the mp3, but video's sound does not work when trying to play on an iPhone:</li>
  </ol>
  
  <pre><code>ffmpeg -loop 1 -i vidimage.jpg -i my.mp3 -shortest -acodec copy -vcodec libx264 -pix_fmt yuv420p my-video.mp4
  </code></pre>
  
  <ol start="2">
  <li>Here, the mp4 plays with audio on an iPhone, but it is only 25 seconds long: </li>
  </ol>
  
  <pre><code>ffmpeg -loop 1 -i vidimage.jpg -i my.mp3 -shortest -acodec aac my-video.mp4
  </code></pre>
  
  <p>Between the two commands, how can I get an MP4 with the same length as the source audio <em>and</em> plays properly on an iPhone?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-25T04:47:31.663Z
Comments.Text: Add `-fflags +shortest` for a closer result.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-25T05:53:18.073Z
Comments.Text: Unable to find a suitable output format for '+shortest'
  +shortest: Invalid argument
Comments.UserDisplayName: mydeve
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-25T07:20:50.960Z
Comments.Text: Share full command and log.
Comments.UserDisplayName: Gyan
Tags: <ffmpeg><mp4>
Title: ffmpeg mp4 video created from mp3 with image has longer duration
UserDisplayName: mydeve
ThreadText: # ffmpeg mp4 video created from mp3 with image has longer duration
  
  (Asked by: username_0 on 2019-03-25)
  
  I am trying to convert an mp3 to mp4 with images. Below are two `ffmpeg` commands I tried.
  
  Length of mp3: 23 sec
  
  1. Here, the length of the video is same as the mp3, but video's sound does not work when trying to play on an iPhone:
  
  ```
  ffmpeg -loop 1 -i vidimage.jpg -i my.mp3 -shortest -acodec copy -vcodec libx264 -pix_fmt yuv420p my-video.mp4
  
  ```
  
  2. Here, the mp4 plays with audio on an iPhone, but it is only 25 seconds long:
  
  ```
  ffmpeg -loop 1 -i vidimage.jpg -i my.mp3 -shortest -acodec aac my-video.mp4
  
  ```
  
  Between the two commands, how can I get an MP4 with the same length as the source audio *and* plays properly on an iPhone?
  
  **Tags:** ffmpeg, mp4
  
  > **Comments:**
  > **username_1**: Add `-fflags +shortest` for a closer result.  
  > **username_0**: Unable to find a suitable output format for '+shortest' +shortest: Invalid argument  
  > **username_1**: Share full command and log.  
  
  ---
  
  ## 0 answers
  
  