1

I am totally nob to FFMPEG. I am trying to generate mp4 video file by merging mp3 and png image.

When i try converting png image into mp4 it works

ffmpeg -r 1/5.544000 -i 1.png -qscale 2 1.mp4

But when i add mp3 audio file then it fails

ffmpeg -r 1/5.544000 -i 1.png -i 1.mp3 -qscale 2 1.mp4

Following is the error that i get:

No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.

[libx264 @ 0x1475be0] using SAR=1/1

[libx264 @ 0x1475be0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2

`[libx264 @ 0x1475be0] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-`bit

[libx264 @ 0x1475be0] 264 - core 142 r2431 a5831aa - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

[aac @ 0x1476660] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

I tried using -strict -2 but still it fails.

What wrong in the command? How to create mp4 using mp3 and png?

Emii Khaos
  • 9,983
  • 3
  • 34
  • 57
Bhaskar Dabhi
  • 841
  • 1
  • 11
  • 28

2 Answers2

4

Loop the image, use AAC audio, and use yuv420p pixel format:

ffmpeg -loop 1 -framerate 25 -i image.png -i audio.mp3 -c:a aac \
-vf format=yuv420p -movflags +faststart -shortest output.mp4

Other suggestions:

  • If your device doesn't like H.264 High profile add the -profile:v main output option.
  • If you want a really low frame rate (under 5 fps) then adjust the -framerate option to your desired value, and then add the -r output option with a normal value, such as -r 25.
  • Some players don't like MP3 audio in MP4, so that is why AAC is used instead.
  • Width and height must be divisible by 2, so if you get not divisible by 2 error see FFMPEG (libx264) “height/width not divisible by 2”.
  • See FFmpeg Wiki: H.264 for more options.
llogan
  • 121,796
  • 28
  • 232
  • 243
  • Its giving error that `Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height` – Bhaskar Dabhi Oct 25 '15 at 08:59
  • Another error displayed is `track 1: muxing mp3 at 8000hz is not supported` – Bhaskar Dabhi Oct 25 '15 at 09:52
  • @BhaskarDabhi I can't provide an answer without the actual `ffmpeg` command you used and the **complete** console output. Please update your question with this info. – llogan Oct 25 '15 at 16:33
  • Thnx buddy it worked. I had to change `192k` to `32k`. I dont know what was wrong but video is not sync with Audio. I will provide you command and output. – Bhaskar Dabhi Oct 25 '15 at 20:26
  • Here is my command `ffmpeg -loop 1 -i 1.png -i 1.mp3 -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -movflags +faststart -shortest output.mp4` and here you can find snapshot of the error http://imgur.com/ayckKVR – Bhaskar Dabhi Oct 25 '15 at 20:35
  • @BhaskarDabhi Sorry, but I don't understand how video can be out-of-sync with audio when the video is just a single image. Also, why did you make a screenshot instead of simply copying and pasting the text? It is already text. Some important info is missing and is cut off in your screenshot, so I can't yet provide an answer. – llogan Oct 25 '15 at 23:12
0

FFmpeg does by default reencode your audio to acc. But as noted this is experimental and may or may not work. Force ffmpeg to use mp3 with -c:a copy

ffmpeg -r 1/5.544000 -i 1.png -i 1.mp3 -qscale 2 -c:a copy 1.mp4
Equanox
  • 2,220
  • 1
  • 12
  • 11