0

I am trying to convert an mkv with video and audio into an m4v with the same audio, but with the video replaced with a still jpg for the duration. I'm following the examples from https://trac.ffmpeg.org/wiki/Slideshow and not having any success. Every time I attempt any of these, it doesn't insert the jpg, and instead uses the original video from the mkv. I am testing the files in VLC. Any ideas what could be going wrong? I'm inclined to think the documentation itself may be outdated or wrong.

Attempts following the linked examples:

-i input.mkv -loop 1 -i image.jpg -c:a ac3 -b:a 640K -c:v libx264 -shortest output.m4v

-i input.mkv -framerate 1 -i image.jpg -c:a ac3 -b:a 640K -c:v libx264 -r 30 -pix_fmt yuv420p output.m4v

-i input.mkv -framerate 1 -i image.jpg -c:a ac3 -b:a 640K -c:v libx264 -r 30 -vf format=yuv420p output.m4v

The one thing I got semi-working (based on code from another source) was -i input.mkv -i image.jpg -filter_complex "[1][0]scale2ref[i][v];[v][i]overlay" -c:a ac3 -b:a 640K -c:v libx264 output.m4v but this stretches the image out (which I don't want, I want the resultant video to have the same aspect ratio as the image without black padding on the sides).

I'm kicking myself because I eventually got something along the lines of the first examples working a few days ago, but somehow didn't save my work and am back to square one. Any help is appreciated, thanks in advance.

ben158
  • 11
  • 1
    Straight from the [tag:ffmpeg] tag description: *"Only questions about programmatic use of the FFmpeg libraries, API, or tools are on topic. **Questions about interactive use of the command line tool should be asked on Super User or Video Production**."* – IInspectable Sep 14 '20 at 06:00

1 Answers1

0

FFmpeg has the -map option that allows the users to select streams for output. In the absence of mapping, ffmpeg with auto-select streams based on factors like resolution or input order. For your case, set mapping.

-i input.mkv -loop 1 -i image.jpg -map 1:v -map 0:a -c:a ac3 -b:a 640K -pix_fmt yuv420p -c:v libx264 -shortest -fflags +shortest -max_interleave_delta 100M output.m4v

Due to an issue with -shortest, some parameters are added. See My ffmpeg output always add extra 30s of silence at the end

Gyan
  • 85,394
  • 9
  • 169
  • 201