VideoHelp Forum

+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Hello,

    This is my first attempt at 1) creating a fake video with a still picture and no audio, and 2) append a full video to it.

    The full video looks like this, after further compressing the big input file:
    Code:
    ffmpeg -i big.mp4 -b:v 300k -vf scale=720:-1 -c:v libx264 -pix_fmt yuv420p -c:a aac -q:a 1 -ac 2 -ar 44100 -threads 2 -f mp4 02.full.video.mp4
    
    ffprobe -i 02.full.video.mp4
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x540 [SAR 4:3 DAR 16:9], 300 kb/s, 50 fps, 50 tbr, 12800 tbn, 100 tbc (default)
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    To create the "still picture video", I tried this:
    Code:
    ffmpeg -loop 1 -i still.png -vf scale=720:540,setdar=16:9 -b:v 300k -r 50 -c:v libx264 -t 10 -pix_fmt yuv420p -c:a aac -q:a 1 -ac 2 -ar 44100 -threads 2 -f mp4 01.still.mp4
    FWIW, the still picture as input is 720 x 540 pixels, 24 BPP, 96 x 96 DPI.

    To join the two files, I used:
    Code:
    (for %i in (*.mp4) do @echo file '%i') > input.txt
    ffmpeg -safe 0 -f concat -i input.txt -c copy merged.aud.vid.mp4
    In the output, there's no audio, and the video is horizontally stretched.

    Would someone have a working example I could try?

    Thank you.
    Quote Quote  
  2. Don't know if this can be done as intended with ffmpeg alone, but if the original video is going to be re-compressed anyway, it might be more reliable to do this with Avisynth, although I'm not sure exactly how to do this. In particular, I'm not sure how to import a still picture as a clip with silent audio. I would try something like this :
    Code:
    big = FFmpegSource2("big.mp4").LanczosResize(720,540) # other source filters may be more suitable, this one has the advantage of loading the video and audio streams in a single line which simplifies the script
    still = ImageSource("still.png", pixel_type=YV12, fps=50, end=500) # should load the still picture as a 10 seconds / 50FPS video clip
    blank = BlankClip(fps=50, length=500, channels=2) # should create a blank clip with silent stereo audio, 10 seconds at 50FPS (with the default 44100Hz sample rate)
    stillaudio = AudioDub(still, blank) # should merge the still picture clip with silent audio / you could add a fade-in effect here, with for instance “.FadeIn(25)”
    big ++ stillaudio # should append the still picture clip to the “big” video clip / for this to work the clips must have matching parameters, there will be a warning otherwise
    Then ffmpeg could be used to encode the new video, using the AVS script as input.
    Code:
    ffmpeg -i "big plus still.avs" -vf scale=720:540,setdar=16:9 -c:v libx264 -b:v 300k -c:a aac -q:a 1 -threads 2 "big plus still.mp4"
    Disclaimer : it's mostly a shot in the dark, don't have enough experience to guarantee that this will work or that I didn't make a severe mistake that might destroy the entire fabric of the universe.
    Quote Quote  
  3. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Thanks. I've never used AviSyth, so I'll read more to see if ffmpeg is up to the task before.
    Quote Quote