Moving an overlay smoothly - ffmpeg

I have a sliding video overlay on top of a background screen and move it from point a to point b.
The resulting video produces choppy movement. The overlay moves a step at a time instead of in one continous motion.
Here's an example of the code:
ffmpeg -y -stream_loop -1 -i b.mpg -i bg.jpg -filter_complex "
[0:v]scale=320:240[vid];[1][vid]overlay=x='(180+(30-180)*(t-
0)/60)*between(t,0,60)+(30+(290-30)*(t-60)/60)*between(t,60,120)':y='(120+
(120-120)*(t-0)/60)*between(t,0,60)+(120+(30-120)*(t-
60)/60)*between(t,60,120)'[out]" -map "[out]" -r 29.97 -aspect 4:3 -b:v
4000k -minrate 4000k -maxrate 4000k -bufsize 2000k -t 64 t.mpg
Input #0, mpegvideo, from 'b.mpg':
Duration: 00:00:32.34, bitrate: 4000 kb/s
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480
[SAR 32:27 DAR 16:9], 4000 kb/s, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
Input #1, image2, from 'bg.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 19637 kb/s
Stream #1:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 640x480,
25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 (mpeg2video) -> scale
Stream #1:0 (mjpeg) -> overlay:main
overlay -> Stream #0:0 (mpeg1video)
Press [q] to stop, [?] for help
[swscaler # 0000000002adc740] deprecated pixel format used, make sure you
did set range correctly
Output #0, mpeg, to 't.mpg':
Metadata:
encoder : Lavf57.73.100
Stream #0:0: Video: mpeg1video, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31,
4000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc57.99.100 mpeg1video
Side data:
cpb: bitrate max/min/avg: 4000000/4000000/4000000 buffer size: 2000000
vbv_delay: -1
warning, clipping 1 dct coefficients to -255..255repeated 2 timesnter
Link to video here: https://youtu.be/EE_hrjy4ilg

Related

With FFmpeg yuv encoded into H264 and encapsulated into ts, ts video found the length of time shorter?

With FFmpeg the mov directly into yuv, then yuv encoded into H264 and encapsulated into ts, ts video found less than the length of time the length of the mov video time. I want to know how to modify the FFmpeg command to solve the video time length shorter problem
The ffmpeg command is as follows:
ffmpeg-i 00.mov 01.yuv
ffmpeg-s 1920x800-pix_fmt yuv420p-i 01.yuv-vcodec libx264-x264-params fps=24 02.h264.
ffmpeg-i 02.h264 03.ts
Use ffprobe to view the 00.mov details are as follows:
Duration: 00: 12: 14.17, start: 0.000000, bitrate: 6361 kb/s
Stream #0:0 (eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x800 [SAR 1: 1 DAR 12: 5], 6162 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc (default)
Metadata:
handler_name: VideoHandler
encoder: libx264
Stream # 0:1 (eng): Audio: mp3 (. mp3 / 0x33706D2E), 44100 Hz, stereo, fltp, 191 kb/s (default)
Metadata:
handler_name: SoundHandler
Use ffprobe to view the 03.ts details are as follows:
Duration: 00:11:44.80, start: 1.440000, bitrate: 2242 kb/s
Program 1
Metadata:
service_name: Service01
service_provider: FFmpeg
Stream #0:0 [0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p (tv, progressive), 1920x800 [SAR 1:1 DAR 12: 5], 25 fps, 25 tbr, 90k tbn, 50 tbc
How to modify the ffmpeg command to make the ts video duration equal to the duration of the mov video
In the 2nd command, add -framerate 24 for the input. The x264 fps signaling only affects ratecontrol and not any framerate metadata in the raw .264 output.
Also, add -c copy in the 3rd comand to avoid re-encoding.

ffmpeg. Concatenate two webm files with transparency

Could you help me to find my mistake. I am trying to concatenate two files (webm) which have transparent background. I do the following:
ffmpeg -i 1.webm -i 2.webm -filter_complex "[0:v:0] 1:v:0]concat=n=2:v=1[outv]" -map "[outv]" 3.webm
I get the concatenate video as i I expect. However the transparent background disappears. Instead the background is black. How to keep the transparency when i concatenate two videos?
The output of the above command is:
ffmpeg version 3.3.4-2 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7 (Ubuntu 7.2.0-8ubuntu2)
Input #0, matroska,webm, from '1.webm':
Metadata:
encoder : Lavf57.71.100
Duration: 00:00:04.35, start: 0.000000, bitrate: 293 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, progressive), 799x770, SAR 1:1 DAR 799:770, 23 fps, 23 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
Input #1, matroska,webm, from '2.webm':
Metadata:
encoder : Lavf57.71.100
Duration: 00:00:04.35, start: 0.000000, bitrate: 303 kb/s
Stream #1:0(eng): Video: vp9 (Profile 0), yuv420p(tv, progressive), 799x770, SAR 1:1 DAR 799:770, 23 fps, 23 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
File '3.webm' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 (vp9) -> concat:in0:v0
Stream #1:0 (vp9) -> concat:in1:v0
concat -> Stream #0:0 (libvpx-vp9)
Press [q] to stop, [?] for help
[libvpx-vp9 # 0x55f58406a540] v1.6.1
Output #0, webm, to '3.webm':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p, 799x770 [SAR 1:1 DAR 799:770], q=-1--1, 200 kb/s, 23 fps, 1k tbn, 23 tbc (default)
Metadata:
encoder : Lavc57.89.100 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 200 fps=8.4 q=0.0 Lsize= 187kB time=00:00:08.65 bitrate= 176.8kbits/s speed=0.365x
video:185kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.011632%
`
I thought this had been fixed, but apparently the native VPx decoders still don't decode alpha, so you have to use the libvpx decoders.
ffmpeg -c:v libvpx-vp9 -i 1.webm -c:v libvpx-vp9 -i 2.webm -filter_complex "[0:v:0] 1:v:0]concat=n=2:v=1[outv]" -map "[outv]" 3.webm

Changing container from mkv to m2v - audio doesn't transfer

Am converting a DVD extraction from an MKV container to an MPEG2 file. This is the command I am using:
ffmpeg -i title04.mkv -c:v copy -c:a copy title04.m2v
It creates the file but with no audio. Am not sure what I am missing as it isn't throwing any error (and usually if a stream isn't compatible with a container it complains).
Here is the output. Any ideas?
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, matroska,webm, from 'title04.mkv':
Metadata:
encoder : libmakemkv v1.8.12 (1.3.0/1.4.1) darwin(x86-release)
creation_time : 2014-08-28 19:36:24
Duration: 00:00:11.34, start: 0.000000, bitrate: 4979 kb/s
Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv), 720x480 [SAR 8:9 DAR 4:3], max. 7500 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s (default)
Metadata:
title : Stereo
Stream #0:2(eng): Subtitle: dvd_subtitle, 720x480 (default)
Output #0, mpeg2video, to 'title04.m2v':
Metadata:
encoder : Lavf55.48.100
Stream #0:0(eng): Video: mpeg2video, yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, max. 7500 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 340 fps=0.0 q=-1.0 Lsize= 4738kB time=00:00:11.31 bitrate=3431.4kbits/s
video:4738kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
m2v (mpeg 2 video) is a video only container. The audio stream is not included.
You should use .mpg or .mpeg as container format.

FFMPEG Dropping all frames

I have a raw H264 video which i am trying to convert into MP4 by the command:
ffmpeg -i 'Camera 4(172.16.2.12_554)_1_2014_07_16_15_20_08.h264' 'Camera
4(172.16.2.12_554)_1_2014_07_16_15_20_08.mp4'
FFMPEG keeps dropping all frames. Not even 1 frame is encoded.
Please see the output below:
Seems stream 0 codec frame rate differs from container frame rate:
2400000.00 (2400000/1) -> 24.00 (24/1)
Input #0, h264, from 'Camera 4(172.16.2.12_554)_1_2014_07_16_15_20_08.h264':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: h264 (Baseline), yuv420p, 1280x960 [PAR 1:1 DAR
4:3], 24 fps, 24 tbr, 1200k tbn, 2400k tbc
[buffer # 0x820c140] w:1280 h:960 pixfmt:yuv420p
Output #0, mp4, to 'Camera 4(172.16.2.12_554)_1_2014_07_16_15_20_08.mp4':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], q=2-31,
200 kb/s, 24 tbn, 24 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
^Zame= 2 fps= 1 q=2.0 size= 225kB time=0.08 bitrate=22147.4kbits/s
dup=0 drop=842
You can try tell to ffmpeg the fps that you desire on output file:
just type the following:
ffmpeg -r "24" -i 'Camera 4(172.16.2.12_554)_1_2014_07_16_15_20_08.h264' 'Camera
4(172.16.2.12_554)_1_2014_07_16_15_20_08.mp4'

FFmpeg streaming to Akamai like FMLE does

I am trying to stream video from my webcam to AkamaiHD service using ffmpeg (like it is implemented in Flash Media Live Encoder)
ffmpeg -f dshow -i video="Webcam C110" -s 640x360 -aspect 16:9 -profile:v baseline - pix_fmt yuv420p -vcodec libx264 -f flv "rtmp://..."
...
Input #0, dshow, from 'video=Webcam C110':
Duration: N/A, start: 31296.194000, bitrate: N/A
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 30 tbr, 10000k tbn, 30 tbc
Output #0
Metadata:
encoder : Lavf55.8.102
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 1k tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
....
The video is sreamed, but when I try to view it at http://mediapm.edgesuite.net/edgeflash/public/zeri/debug/Main.html?url=myplayback_url/manifest.f4m
it is not displayed.
I've found out that if the video is recorded using FMLE and restreamed to akamai, then HLS stream is played.
ffmpeg -re -i sample.f4v -c copy -f flv "rtmp://..."
....
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.f4v':
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
creation_time : 2018-10-06 09:23:33
Duration: 00:01:01.77, start: 0.460000, bitrate: 718 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 624 kb/s, 30 tbr, 1k tbn, 48 tbc
Metadata:
creation_time : 2018-10-06 09:23:33
handler_name : MainConcept
Output #0
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
encoder : Lavf55.8.102
Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=2-31, 624 kb/s, 1k tbn, 1k tbc
Metadata:
creation_time : 2018-10-06 09:23:33
handler_name : MainConcept
Stream mapping:
Stream #0:0 -> #0:0 (copy)
....
It seems that the problem is with h.264 codec configuration, but I have found no solution yet.
Could you please advice, how can I implement streaming like FMLE using ffmpeg?
I think for Akamai you need authentication for the RTMP entrypoint which I don't believe is supported in the librtmp used by ffmpeg.
Have a look at this thread over at Wowza for more information.
If you think it is a codec issue then instead of copy the codec you could try encoding it using -c:v libx264 as the video codec and -c:a libfaac for audio

Resources