Avidemux Forum

Avidemux => Windows => Topic started by: Cormy1 on January 16, 2018, 09:59:11 PM

Title: Export video from still image
Post by: Cormy1 on January 16, 2018, 09:59:11 PM
I want to take an image, take an audio track, and export a video whose length contains the entire audio track and have the still image shown at 1fps or something, fit to a 1920X1080 size with letterboxing if need be, how would I go about doing this?
Using 2.6.21, vanilla windows install.
As a sidenote, can I use AviDemux to record video from any sources such as a full screen application or an external video source provided by USB?
Title: Re: Export video from still image
Post by: Jan Gruuthuse on January 17, 2018, 07:01:14 AM
Somewhere along this: add png then append video to it  (https://www.youtube.com/watch?v=bfKFYeNacrQ&list=PLLGMi2RSm8sbiUG2tfv8mcCzJoEsK3JVN&index=14) just don't add video to it.
- Once your video is created you can change the fps.
- Copy / paste the video  to the wanted duration
- Add Audio track

Avidemux is not (desktop) recording program. Search internet for "desktop recording" + "Your OS"
Title: Re: Export video from still image
Post by: Cormy1 on January 17, 2018, 10:26:40 PM
There must be a better way than copy-pasting images until you have the desired video length. Where do you change the fps exactly so that fewer pastes are required?
Is there no way to force the video length to contain whatever length of audio is in the project audio tracks?
Title: Re: Export video from still image
Post by: eumagga0x2a on January 17, 2018, 10:55:02 PM
I think ffmpeg is a better tool to accomplish at least the video part of the task: https://stackoverflow.com/questions/25891342/creating-a-video-from-a-single-image-for-a-specific-duration-in-ffmpeg
Title: Re: Export video from still image
Post by: Cormy1 on January 18, 2018, 11:17:19 PM
I'm not familiar with ffmpeg behaviour, would setting the scale to something that is different from the image's specifications yield distortion of the image to fit or would it add letterboxing?
In that particular thread you linked, the duration is manually set and is not based on the length of audio being input.
If I wanted to add audio, how would I do so? Why is loop set to 1 rather than 0?
I really have no idea what to do with ffmpeg, which is why I have been trying to go through something with a GUI like AviDemux.
It has the capability, it's just a matter of figuring out the best way of doing it without having to paste hundreds of times.
Title: Re: Export video from still image
Post by: eumagga0x2a on January 19, 2018, 07:18:41 AM
Prepare the image using a proper image editing tool like GIMP, set the duration you need with -t (-loop 1 says ffmpeg to loop input, 0 would disable looping), don't use scaling. Mux the result again using ffmpeg and -c copy or use Avidemux for this purpose.
Title: Re: Export video from still image
Post by: Cormy1 on January 21, 2018, 12:02:38 AM
ffmpeg documentation says 0 parameter sets it to loop indefinitely, if you want to disable looping... You don't use the loop command at all. I would assume that I want to use the 0 parameter to loop throughout the video, which should be based on the length of the audio but you still say I need to set the duration manually and output a looping image video which I would then have to mux with the audio thereafter.
How should the image be prepared in GIMP?
Title: Re: Export video from still image
Post by: eumagga0x2a on January 25, 2018, 08:40:57 AM
Quote from: Cormy1 on January 21, 2018, 12:02:38 AM
ffmpeg documentation says 0 parameter sets it to loop indefinitely, if you want to disable looping... You don't use the loop command at all. I would assume that I want to use the 0 parameter to loop throughout the video

No. From the ffmpeg manpage:

-loop_input
           Loop over the input stream. Currently it works only for image streams. This option is used for
           automatic FFserver testing.  This option is deprecated, use -loop 1.


This is exactly what is written in the command. You are going to loop the input for a given duration.

QuoteHow should the image be prepared in GIMP?

You wanted to fit it into 1920x1080 with letterboxing if needed. Create a black image 1920x1080 in size and paste your image into it, scale and center the image layer if necessary, export the result as a PNG without transparency.
Title: Re: Export video from still image
Post by: Cormy1 on January 25, 2018, 08:40:40 PM
???
Quote-loop_output number_of_times
    Repeatedly loop output for formats that support looping such as animated GIF (0 will loop the output infinitely). This option is deprecated, use -loop.
from https://www.ffmpeg.org/ffmpeg.html
There is also
Quote-stream_loop number (input)
    Set number of times input stream shall be looped. Loop 0 means no loop, loop -1 means infinite loop.
Seems I should be using either the first option with 0, or second option with -1 to loop indefinitely, for the duration of the video. If I set it to loop once, won't I end up with a bunch of empty frames that the picture wasn't looped for? Don't see any framerate adjustments either so if it isn't set to loop, will it show 1 frame for the entire duration or will it just be followed by many empty frames?


As I understand it, there is currently no way to do this within AviDemux without pasting dozens of the same picture is that right?
Title: Re: Export video from still image
Post by: eumagga0x2a on January 25, 2018, 09:40:27 PM
I refer to the manpage of ffmpeg 3.4.1 which is installed on my system and to my own testing. The command works as expected, generates a video of given duration at 25 fps.

QuoteAs I understand it, there is currently no way to do this within AviDemux without pasting dozens of the same picture is that right?

While pressing Ctrl+C and then keeping Ctrl+V pressed for a while feels awkward, it works.
Title: Re: Export video from still image
Post by: Cormy1 on August 24, 2020, 04:53:17 PM
Since introducing the StillImage Filter I've been able to perform this task with ease, however I tried doing it today with a PNG and that seemed to cause an error when encoding, filtered playback works fine.
Why would there be an issue encoding the PNG...? I'm filtering, so it isn't copying, it should encode the png to jpeg as video frames.

I get the error:
"Cannot set up encoder. The configuration supplied to the encoder may be incompatible or the encoder may depend on features unavailable on this system."

Using Avidemux 2.7.7 200813, admlog says it couldn't initiliaze x264, changing codecs did not help.
Title: Re: Export video from still image
Post by: eumagga0x2a on August 24, 2020, 05:26:22 PM
Are both width and height of the image even?
Title: Re: Export video from still image
Post by: Cormy1 on August 24, 2020, 10:16:14 PM
No, is that the issue? It worked when I converted it to JPG first, which had the same dimensions.
Title: Re: Export video from still image
Post by: eumagga0x2a on August 24, 2020, 11:14:51 PM
Quote from: Cormy1 on August 24, 2020, 10:16:14 PMNo, is that the issue?

Sure.

Quote from: undefinedIt worked when I converted it to JPG first, which had the same dimensions.

If it worked, some intermediate stage like a video filter cropped or padded the size to an even value. x264 doesn't support odd dimensions.

By the way, width or height which is not a multiple of 16 strongly worsens compressibility and should be avoided (don't be fooled by the height of the full HD resolution 1920x1080 not being a multiple of 16: it is actually encoded as 1920x1088 with the bottom 8 pixels cropped away at the output stage).
Title: Re: Export video from still image
Post by: Cormy1 on August 25, 2020, 10:54:33 AM
As I said, the only difference was that it was a JPG rather than a PNG, the filters I employed did not change.
To create the JPG, I merely opened the PNG in Irfanview and then saved it has a 100Q JPG instead, no chroma subsampling.
How can I tell if the resolution was changed? Nothing seems to indicate that it has.

If 1080p is encoded as 1088 for the sake of compressibility, should not all resolutions that are not multiples of 8 be padded first automatically?
What kind of padding is applied? I assume it SHOULD duplicate the last line of pixels to achieve that multiple.
Title: Re: Export video from still image
Post by: eumagga0x2a on August 25, 2020, 11:58:04 AM
Quote from: Cormy1 on August 25, 2020, 10:54:33 AMAs I said, the only difference was that it was a JPG rather than a PNG, the filters I employed did not change.

Indeed, Avidemux automatically fakes size of loaded JPEG images to make the values even (https://github.com/mean00/avidemux2/blob/dc59711b2cae2c0df98d453cfb59dfa7b1e8f186/avidemux_core/ADM_coreImageLoader/src/ADM_imageLoader.cpp#L223). It doesn't do that for PNG and BMP.

Quote from: undefinedTo create the JPG, I merely opened the PNG in Irfanview and then saved it has a 100Q JPG instead, no chroma subsampling.

...which is always converted in Avidemux to 4:2:0.

Quote from: undefinedHow can I tell if the resolution was changed? Nothing seems to indicate that it has.

Avidemux prints the complete (or almost complete) x264 configuration, which includes width and height of the input, to the log. Anyway, it is clear now how the things work and why odd dimensions were not a problem with JPEG.

Quote from: undefinedIf 1080p is encoded as 1088 for the sake of compressibility, should not all resolutions that are not multiples of 8 be padded first automatically?

Multiples of 16. Yes, indeed, it looks like x264 is doing exactly that, encoding 1280x712 as 1280x720 with the bottom 8 pixels cropped away, so the my claim of adverse effects of a size being not a multiple of 16 is moot.

Quote from: undefinedWhat kind of padding is applied? I assume it SHOULD duplicate the last line of pixels to achieve that multiple.

Which one? The padding applied by x264? Can't tell without studying the source. Probably zeroed-out memory. The extra line or row resulting from Avidemux making width and height of a loaded JPEG image even contains probably just random noise.
Title: Re: Export video from still image
Post by: Cormy1 on August 26, 2020, 07:59:48 PM
In this case, would it be possible for Avidemux to fake PNG dimensions in the future aswell...?
If I have a PNG that isn't a multiple of 16 and want to import it into Avidemux, how should I pad it?
Title: Re: Export video from still image
Post by: eumagga0x2a on August 26, 2020, 08:52:55 PM
Don't pad, add the crop filter (and "add border" if necessary) to the chain instead. Technically it is not mandatory for width and height to be a multiple of 16, they just need to be even, else no joy with x264.