2

I am working on videos with alpha channel to be merged with a background video at a given position (for instance, [100,100]) . You can accomplish this by using:

ffmpeg -i BACK -i OVER -filter_complex [0][1]overlay=100:100 OUTPUT

But I would like to test the result without having to generate the whole video and then playing it.

I've tried VLC but its only overlay option is to put a picture (not even animated) over the video. I don't know if there is a shader in MPC-HC that would suit me, but I haven't found it (and shaders, even simplest, are usually CPU demanding). The same happens with avisynth: the playing is jerky and seeking even worse (I believe it's because avisynth works with and outputs uncompressed video).

Is there a way to watch the resulting video on-the-fly, being able to jump to any point of it and using a reasonable amount of CPU?

1

If you generate a fragmented MP4, you can view the video as it is being encoded. You can only seek upto the points which have already been encoded at the time of loading the file. So, if you want to seek further, reload it later.

Basic syntax is

ffmpeg -i input -<encoding parameters> -movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov out.mp4
  • I appreciate the effort but not what I was looking for. I would like to check maybe 4 or 5 random points (one of them at the end, for instance) with a smooth playing and what I was trying to avoid is the encoding and the creation of the file until I was fairly sure of the result. But +1 for the idea, which I find interesting for another purposes (I will look into those mysterious flags more deeply). – cdlvcdlv Jul 13 '16 at 9:13
  • Then you can simply encode small segments: ``ffmpeg -ss 34 -t 10 -i back -i over... test-output` and check. If you want to be able to do random spot-checks, a video editor is your best option. Openshot is a free one. – Gyan Jul 13 '16 at 10:06
1

I answer myself:

I found a question related and I thought I could pipe ffmpeg to ffplay. It works partially (you can watch the merged video), but you can't seek (and it chokes the CPU).

ffmpeg -i BACKGROUND -i OVERLAY -filter_complex [0][1]overlay=100:100 -f matroska - | ffplay -

But I didn't even think that ffplay could be used and, though ffplay only accepts one -i option, revising the ffmpeg filters, I came across the movie filter (almost unused with ffmpeg because you can add multiple -i options), which provides a way to add more inputs. After some tests, I could do what I wanted:

ffplay -i BACKGROUND -vf "movie=OVERLAY[ov]; [in][ov]overlay=100:100"

(If you are using Windows and OVERLAYis a name with spaces, you can surround it with ''.)

With this command line, you can seek the resulting video using no noticeable additional CPU (just right-click on the image - you will go to the percentage in file corresponding to fraction of width).

A plus is that, if you need some additional options in the final encoding with ffmpeg, they can be undestood by ffplay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.