0

I have a list of mp4 files which are of kb's or of at max 4 MB (they were actually gifs but downloaded as mp4).So when I concatenate them using a list of them the video don't work as all of them are of different sizes (resolution wise ) and all of not are in vertical order.So any help with that matter and also I f someone would be kind enough to tell me the FFmpeg command to convert this mp4 list to gif 's without losing quality.Thanks in advance

1 Answers1

3

You can use the fps, scale, setsar, setpts, concat, palettegen, and paletteuse filters.

1. Make all inputs uniform, concatenate, then generate the palette

    ffmpeg -i input0 -i input1 -i input2 -filter_complex \
    "[0:v]fps=10,scale=320:240,setsar=1/1,setpts=PTS-STARTPTS[v0]; \
     [1:v]fps=10,scale=320:240,setsar=1/1,setpts=PTS-STARTPTS[v1]; \
     [2:v]fps=10,scale=320:240,setsar=1/1,setpts=PTS-STARTPTS[v2]; \
     [v0][v1][v2]concat=n=3:v=1:a=0,palettegen[out]" \
    -map "[out]" palette.png
  • You may not need fps but you did not show any info about your inputs so I had to make assumptions.

2. Encode to GIF

    ffmpeg -i input0 -i input1 -i input2 -i palette.png -filter_complex \
    "[0:v]fps=10,scale=320:240,setsar=1/1,setpts=PTS-STARTPTS[v0]; \
     [1:v]fps=10,scale=320:240,setsar=1/1,setpts=PTS-STARTPTS[v1]; \
     [2:v]fps=10,scale=320:240,setsar=1/1,setpts=PTS-STARTPTS[v2]; \
     [v0][v1][v2]concat=n=3:v=1:a=0[vv]; \
     [vv][3:v]paletteuse[out]" \
    -map "[out]" output.gif
  • You can't "convert MP4 to GIF without losing quality", but there is a small chance you may not notice much of a difference since you said the MP4 were created from GIF. It all depends on what your inputs look like and how many colors there are.

Also see

llogan
  • 63,280