<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>

CC BY-SA 4.0
2019-03-25T04:47:31.663Z
Add `-fflags +shortest` for a closer result.
Gyan
CC BY-SA 4.0
2019-03-25T05:53:18.073Z
Unable to find a suitable output format for '+shortest'
+shortest: Invalid argument
mydeve
CC BY-SA 4.0
2019-03-25T07:20:50.960Z
Share full command and log.
Gyan
<ffmpeg><mp4>
ffmpeg mp4 video created from mp3 with image has longer duration
mydeve
# 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

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


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

