FORUMS: list search recent posts

Concatenate image video to another video

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Mary Rosa
Concatenate image video to another video
on May 13, 2015 at 4:33:39 am

I am currently trying to achieve with ffmepg a `freeze frame effect`. This is something easy to do with adobe after effects shown



. However I would like to achieve a freeze frame effect(of 5 seconds duration) followed by the 15 second video for the final output video. This should amount to a final duration of 20 seconds. However with the settings below, I am not getting a "freeze frame effect". The video keeps its original size of 15 seconds due to some trimming which I am not sure why. How can I achieve a "freeze frame effect" in ffmpeg?

//create image

ffmpeg -i "/media/test/test.mp4" -ss 00:00:00.023222 -vframes 1 "/media/test/test.png"

//create freeze image effect

ffmpeg -i "/media/test/test.mp4" -loop 1 -i "/media/test/test.jpg" -an &#092;
-filter_complex "[1:v]trim=start=0:end=5[ol];[0:v]setpts=[nv];[nv][ol]overlay=eof_action=pass[final]" &#092;
-map '[final]' -c:a aac -strict experimental -c:v libx264 -q 1 "/media/test/test_effect.mp4"


//Output

ffmpeg version git-2014-12-27-d4fd3f2 Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 27 2014 12:23:47 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 19.100 / 56. 19.100
libavformat 56. 16.102 / 56. 16.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 6.100 / 5. 6.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/media/test/test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Duration: 00:00:15.09, start: 0.023222, bitrate: 1258 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 1107 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 97 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Data: none (rtp / 0x20707472), 40 kb/s
Metadata:
handler_name : HintHandler
Stream #0:3(eng): Data: none (rtp / 0x20707472), 8 kb/s
Metadata:
handler_name : HintHandler
Input #1, image2, from '/media/test/test.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 5930 kb/s
Stream #1:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 640x640 [SAR 1:1 DAR 1:1], 25 fps, 25 tbr, 25 tbn, 25 tbc
File '/media/test/outputwitheffect.mp' already exists. Overwrite ? [y/N] y
[swscaler @ 0x3b20340] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x3b52240] using SAR=1/1
[libx264 @ 0x3b52240] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x3b52240] profile High, level 3.1
[libx264 @ 0x3b52240] 264 - core 144 r2 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/media/test/outputwitheffect.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.16.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x640 [SAR 1:1 DAR 1:1], q=-1--1, 29.97 fps, 11988 tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc56.19.100 libx264
Stream mapping:
Stream #0:0 (h264) -> setpts
Stream #1:0 (mjpeg) -> trim
overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
frame= 450 fps= 42 q=-1.0 Lsize= 1897kB time=00:00:14.94 bitrate=1039.6kbits/s
video:1892kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.261115%
[libx264 @ 0x3b52240] frame I:3 Avg QP:21.42 size: 32916
[libx264 @ 0x3b52240] frame P:258 Avg QP:24.90 size: 6512
[libx264 @ 0x3b52240] frame B:189 Avg QP:30.33 size: 835
[libx264 @ 0x3b52240] consecutive B-frames: 36.2% 19.1% 12.7% 32.0%
[libx264 @ 0x3b52240] mb I I16..4: 5.6% 79.1% 15.2%
[libx264 @ 0x3b52240] mb P I16..4: 2.4% 5.9% 0.9% P16..4: 40.8% 14.3% 4.7% 0.0% 0.0% skip:30.8%
[libx264 @ 0x3b52240] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 22.1% 2.2% 0.3% direct: 0.3% skip:75.0% L0:56.7% L1:39.4% BI: 3.9%
[libx264 @ 0x3b52240] 8x8 transform intra:65.3% inter:56.8%
[libx264 @ 0x3b52240] coded y,uvDC,uvAC intra: 53.8% 60.0% 12.4% inter: 12.2% 11.4% 0.1%
[libx264 @ 0x3b52240] i16 v,h,dc,p: 34% 24% 9% 33%
[libx264 @ 0x3b52240] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 19% 5% 5% 6% 5% 6% 6%
[libx264 @ 0x3b52240] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 22% 17% 5% 6% 7% 7% 5% 5%
[libx264 @ 0x3b52240] i8c dc,h,v,p: 54% 19% 21% 6%
[libx264 @ 0x3b52240] Weighted P-Frames: Y:3.5% UV:1.2%
[libx264 @ 0x3b52240] ref P L0: 80.1% 14.6% 4.7% 0.6% 0.0%
[libx264 @ 0x3b52240] ref B L0: 97.6% 2.4% 0.1%
[libx264 @ 0x3b52240] ref B L1: 98.3% 1.7%
[libx264 @ 0x3b52240] kb/s:1031.91


Return to posts index

Jim Sustacek
Re: Concatenate image video to another video
on May 13, 2015 at 6:01:09 pm
Last Edited By Jim Sustacek on May 13, 2015 at 6:02:00 pm

I notice your first command outputs a PNG file, and your second command inputs a JPG. Presumably that's just a typo.

The "overlay" filter will lay one video on top of the other, and the duration will be the longest video (15 seconds). What you want is to concatenate two videos together (play one after the other), for a total duration of 20 seconds, so you want the "concat" filter.

You will probably want to make the frame image into its own 5 second video with a blank audio track, then concatenate it with the full video:

ffmpeg -f lavfi -i aevalsrc=0 -loop 1 -i test.png -t 5 -c:v libx264 -q 1 -c:a aac -strict experimental test_freeze.mp4

ffmpeg -i test_freeze.mp4 -i test.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -c:v libx264 -q 1 -c:a aac -strict experimental test_effect.mp4


See here for audio:
http://stackoverflow.com/questions/12368151/adding-silent-audio-to-mov-in-f...

And here for concatenate:
https://trac.ffmpeg.org/wiki/Concatenate


Return to posts index

Mary Rosa
Re: Concatenate image video to another video
on May 13, 2015 at 10:10:35 pm

Many thanks Jim! I am now trying to add white text with a black bar background

-vf drawtext="fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf:text='TitleofVideo' :x=(w-tw)/2:y=(h-th)/2"

Error

Filtergraph 'drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf:text='TitleofVideo' :x=(w-tw)/2:y=(h-th)/2' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.


Example


Return to posts index


Jim Sustacek
Re: Concatenate image video to another video
on May 14, 2015 at 3:49:02 pm

Sounds like you can't do the "-filter_complex" (for the concatenate) and the "-vf" (for the drawtext) in the same command.

Fortunately you can combine them in the same "-filter_complex" statement:

ffmpeg -i test_freeze.mp4 -i test.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]; [v] drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf:text='TitleofVideo' :x=(w-tw)/2:y=(h-th)/2 [v-titled]" -map "[v-titled]" -map "[a]" -c:v libx264 -q 1 -c:a aac -strict experimental test_effect_titled.mp4


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]