You are not logged in.

#1 2018-04-30 07:03:32

makh
Member
Registered: 2011-10-10
Posts: 305

[SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

Hi

I used:

ffmpeg -loop 1 -r 1 -i IMG_file.jpg -i audio_p1.mp3 -c:a copy -c:v libx264 -tune stillimage -shortest output.mp4

I have:

203kB  IMG_file.jpg 
2.1MB  audio_p1.mp3
37MB  output.mp4

Please inform, is it possible that I can get video around 3MB only, but still in mp4 format.

I am actually trying to upload to FB, but they dont allow the audio upload. But this large volume is not suiting me.

Thankyou

Last edited by makh (2018-05-12 18:18:23)


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#2 2018-04-30 09:59:02

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,849

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

Did you try simply

ffmpeg -i IMG_file.jpg -i audio_p1.mp3 output.mp4

You'll end up w/ an aac, but that should be fine.

Offline

#3 2018-04-30 10:23:13

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,962
Website

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

seth wrote:

Did you try simply

ffmpeg -i IMG_file.jpg -i audio_p1.mp3 output.mp4

You'll end up w/ an aac, but that should be fine.

does that produce a video with just one frame? In that case most online services will derp out, atleast it did when I uploaded such video to youtube

Offline

#4 2018-04-30 10:39:35

xerxes_
Member
Registered: 2018-04-29
Posts: 1,077

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

You may try solution in this link:
https://video.stackexchange.com/questio … ith-ffmpeg

or maybe this is what you need:
https://trac.ffmpeg.org/wiki/Encode/YouTube

Last edited by xerxes_ (2018-04-30 10:42:19)

Offline

#5 2018-04-30 11:09:28

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,849

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

It says 25fps but if it has more than one key frame, the encoder would do wrong.
idk whether FB is ok with that, because apparently I don't have any friends.

Offline

#6 2018-05-01 19:53:25

makh
Member
Registered: 2011-10-10
Posts: 305

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

seth wrote:

Did you try simply

ffmpeg -i IMG_file.jpg -i audio_p1.mp3 output.mp4

You'll end up w/ an aac, but that should be fine.

Hi this gives me a video file, but the file has no video, it only ends up in audio. Plus FB complains that it is not a valid video format.

@xeres:
Using:

ffmpeg -loop 1 -framerate 2 -i input.png -i audio.m4a -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p output.mkv

gives me:
18MB      output.mkv
Its a little better then mp4, but still I dont understand: (203kB + 2.1MB) ... its still too big, for me...!!!

Trying:

ffmpeg -i input.mp3 -c copy output.mkv

... FB complains that it is not a valid video format.

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#7 2018-05-01 21:44:05

teckk
Member
Registered: 2013-02-21
Posts: 590

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

How long is that audio file? The size is less important. The longer it is
the more frames of video that have to be made. Longer the audio the larger the
video will be. Also the larger the image the larger the video will be in size.

I did a test.

I made a file.png with scrot, it is 768x432, 326Kb in size
I then made a .mp3 that is 3:00 long and 128K, it is 2.8Mb in size.
I then made a 30fps x264 .mp4 out of them

ffmpeg -i file.mp3 -loop 1 -i file.png -t 00:03:00 -c:a copy -c:v libx264 -crf 18 -preset slow -r 30 -pix_fmt yuv420p OutFile.mp4

OutFile.mp4 is 4.6Mb in size

Offline

#8 2018-05-01 23:13:14

makh
Member
Registered: 2011-10-10
Posts: 305

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

teckk wrote:

How long is that audio file?

Hi
Your method gave me one error; I couldnt use -t as my file was 0:8:56 time, and it caused ffmpeg to run endlessly.

But it gave me a possible hint to reduce the image size; so I did as:

STEP 1:
Compress image to 50% using convert.
STEP 2:
Reduce image to around 800x600, using smooth scale option in Kolourpaint. 
STEP 3:
ffmpeg -loop 1 -framerate 2 -i image_file_3.jpeg -i audio_p1.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -preset slow -c:a copy -shortest -pix_fmt yuv420p output.mkv

RESULT:
3.4MB  output.mkv

Well I am not sure, it could have been fine tuned more, or not...!

Thankyou All smile


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#9 2018-05-03 19:48:23

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

Your command is almost there, but you are using two "-preset" options–you only need one. Use a slow preset. Since you're not encoding many frames it won't take long.
No need to use convert or Kolourpaint: just do it all in ffmpeg.

ffmpeg -loop 1 -framerate 2 -i image.jpg -i audio.mp3 -c:v libx264 -preset veryslow -crf 18 -vf "scale='min(1280,iw)':-2,format=yuv420p" -c:a copy -shortest output_x265.mkv

In this example the image is downscaled to 1280 pixels wide only if the input is larger; otherwise use original image size to prevent a needless upscale.
If the video is not accepted increase the `-framerate` value.
You may also try libx265 instead of libx264 to encode HEVC/H.265 video, but it will probably not make much of a size difference in this case (assuming Facebook accepts HEVC).

Offline

#10 2018-05-05 13:17:02

makh
Member
Registered: 2011-10-10
Posts: 305

Re: [SOLVED] ffmpeg: Combining on jpeg to mp3, but how to get smaller size

DrZaius wrote:

...

Thankyou Sir! Let me test and see if it helps me. It will definitely be nicer to do it in one shot.


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

Board footer

Powered by FluxBB