text:
FFmpeg filter_complex says filter not connected to source
I am trying to understand the how FFmpeg's filtergraph works with the help of the graph2dot utility (FFmpeg graph2dot tool).
I am using an example from one of the questions previously posted here (How to concatenate clips from the same video with ffmpeg). Upon trying to parse the following filtergraph which is adapted from the accepted answer,
echo "nullsrc[vid];anullsrc[aud];[vid]trim=60:65,setpts=PTS-STARTPTS[v0];[aud]atrim=60:65,asetpts=PTS-STARTPTS[a0];[vid]trim=120:125,setpts=PTS-STARTPTS[v1];[aud]atrim=120:125,asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[out];[out]nullsink" | graph2dot
I get the following error with FFmpeg (ver 3.4):
[Parsed_nullsrc_0 @ 0x55cd2c952240] size:320x240 rate:25/1 duration:-1.000000 sar:1/1
[Parsed_trim_2 @ 0x55cd2c953500] Setting 'start' to value '60'
[Parsed_trim_2 @ 0x55cd2c953500] Setting 'end' to value '65'
[Parsed_setpts_3 @ 0x55cd2c953fc0] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_atrim_4 @ 0x55cd2c954f20] Setting 'start' to value '60'
[Parsed_atrim_4 @ 0x55cd2c954f20] Setting 'end' to value '65'
[Parsed_asetpts_5 @ 0x55cd2c955960] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_trim_6 @ 0x55cd2c9568c0] Setting 'start' to value '120'
[Parsed_trim_6 @ 0x55cd2c9568c0] Setting 'end' to value '125'
[Parsed_setpts_7 @ 0x55cd2c957120] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_atrim_8 @ 0x55cd2c957fa0] Setting 'start' to value '120'
[Parsed_atrim_8 @ 0x55cd2c957fa0] Setting 'end' to value '125'
[Parsed_asetpts_9 @ 0x55cd2c9587a0] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_concat_10 @ 0x55cd2c9596c0] Setting 'n' to value '2'
[Parsed_concat_10 @ 0x55cd2c9596c0] Setting 'v' to value '1'
[Parsed_concat_10 @ 0x55cd2c9596c0] Setting 'a' to value '1'
Input pad "default" with type video of the filter instance "Parsed_trim_6" of trim not connected to any source

As far as I understand, the "Parsed_trim_6" filter is connected to the source nullsrc[vid].
Can anyone help me understand what's wrong here and how I can fix it?
EDIT: Following Mulvya's hints, the correct solution is given below:
echo "nullsrc,split=2[vid1][vid2];anullsrc,asplit=2[aud1][aud2];[vid1]trim=60:65,setpts=PTS-STARTPTS[v0];[aud1]atrim=60:65,asetpts=PTS-STARTPTS[a0];[vid2]trim=120:125,setpts=PTS-STARTPTS[v1];[aud2]atrim=120:125,asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[outv][outa];[outv]nullsink,[outa]anullsink" | graph2dot
Other lessons I learnt from this

Video and audio streams require separate sinks. Even with the concat filter, I wasn't able to merge them into the [out] destination as I had originally done

You can consume a filter generated stream only once, unlike streams from -i inputs. Since [vid] is already supplied to the first trim 60:65, it can't be reused. You can add a split and supply a copy to each:
nullsrc,split=2[vid1][vid2]; ... [vid1]trim=60:65, ... [vid2]trim=120:125, ...

Thanks. It wasn't clear from the documentation that nullsink could be used only once. I have added the complete solution to the question.

I wrote a shell script that uses fzf to create repls from linux commands: https://github.com/vapniks/fzfrepl
There's an example in the Readme.org that shows how you can use it with ffmpeg, graph2dot & graph-easy to get a live preview diagram of the ffmpeg filtergraph thats entered at the prompt.
This could be useful for debugging filtergraphs.


text:
Are JPEG compression and H.264 intraframe compression the same process?
I was looking at how JPEG compression works, and to me it seems to be really similar to what H.264 (and other video codecs) does with its intraframe prediction step.
In both algorithms the image frame is "chroma-downsampled", divided into small blocks, and then DCT and quantization are applied. Finally the frame/picture is encoded into a bitstream using Huffman coding.
Is this correct? Are there important differences between JPEG and H.264 intraframe compressions that I'm missing?

This is a complex topic, so best to link and excerpt
From https://sonnati.wordpress.com/2010/10/19/h-264-for-image-compression/

H.264 contains a number of new features that allow it to compress
  images much more efficiently than JPG.
New transform design
Differently from JPG, an exact-match integer 4×4 spatial block
  transform is used instead of the well known 8×8 DCT. It is
  conceptually similar to DCT but with less ringing artifacts.  There is
  also a 8×8 spatial block transform for less detailed areas and chroma.
A secondary Hadamard Transform (2×2 on chroma and 4×4 on luma) can be
  usually performed on “DC” coefficients to obtain even more compression
  in smooth regions.
There is also an optimized quantization and two possible zig-zag
  pattern for Run Length Encoding of transformed coefficients.
Intra-frame compression
H.264 introduces complex spatial prediction for intra-frame
  compression. Rather than the “DC”-only prediction found in MPEG2 and
  the transform coefficient prediction found in H.263+, H.264 defines 6
  prediction directions (modes) to predict spatial information from
  neighbouring blocks when encoded using 4×4 transform. The encoder
  tries to predict the block interpolating the color value of adiacent
  blocks. Only the delta signal is therefore transmitted.
There are also 4 prediction modes for smooth color zones (16×16
  blocks). Residual data are coded with 4×4 trasforms and a further 4×4
  Hadamard trasform is used for DC coefficients.
Improved quantization
A new logarithmic quantization step is used (compound rate 12%). It’s
  also possible to use Frequency-customized quantization scaling
  matrices selected by the encoder for perceptual-based quantization
  optimization.
Inloop deblocking filter
An adaptive deblocking filter is applied to reduce eventual blocking
  artifacts at high compression ratio.
Advanced Entropy Coding
H.264 can use the state of the art in entropy coding: Context Adaptive
  Binary Arithmetic Coding (CABAC) which is much more efficient than the
  standard Huffman coding used in JPG.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
MPEG-TS imprecise cut position on exact PTS, if cutting audio as well
Good morning, after 1 month of research and attempts, still wondering the correct solution.
I have frequently tv mpeg-ts (h264+aac) file to cut part from. I have a script to cut at exact times inserted in a text file; the timestamp of the cut point is identified overlaying the pts on every frame with drawtext filter, and/or exporting exact frame number as a pic and checking frame's timestamp with ffprobe, and/or with ffmpeg -i xxxx -ss [...] (accurate seek).
if I cut only the video, with the trim filter, according those timestamp, the result is perfect. the problem arises when I cut audio as well (with the same timestamps, obviously, from the same input ([0:v]trim.....; [0:a]trim.....): audio/video is synced BUT not at the exact position.
after troubleshooting I checked that start_pts of the video and audio track are different; after checking many files I found that audio always starts earlier, between around 0.4 - 1.5 sec.
video start pts:
ffprobe -show_entries stream=codec_type,start_time  00001.ts 2>/dev/null  | grep -m 1 -A1 codec_type=video | grep -v video | sed  -e 's/^.*=//'

audio start pts:
ffprobe -show_entries stream=codec_type,start_time  00001.ts 2>/dev/null  | grep -m 1 -A1 codec_type=audio | grep -v audio | sed  -e 's/^.*=//'

in this case, for instance, I get:
35918.124589 (video)
35917.700589 (audio)

difference is 35918.124589 - 35917.700589 = 0.424 s.
this is the exact offset of the cut as compared from my input timestamps.
my understanding is that if I use the trim filter only on a video track, ffmpeg position on the requested time starting from intial video track timestamp, but if I trim both video and audio, BOTH are cut at requested time starting from intial AUDIO track timestamp (thus shifting the video cutting point).
if I decide to use separate inputs (ffmpeg -i 00001.ts -i 00001.is -filter_complex "[0:v]trim xxx yyy[v1];[1:a]atrim xxx yyy[a1]") then video is cut at original desired position, but audio and video are out of sync.
presently my two options are to use separate inputs and INCREASE audio cut time by the calculated offset, OR use, as normal, one input for each part to be cut, and increase both video and audio cut time by the offset (since is going to be counted from audio initial pts for both the audio and the video).
I would like to understand how ffmpeg use pts from different tracks: how it decides if looking to audio track pts, or video track pts, etc?
which should be the correct approach to have audio vidfeo in sync, and cutting exactly at the timestamp identified from the video track?
best regards

Curious... none interested? or none knows?

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
capture RTSP stream from IP camera ffmpeg
I used the following command to get the frames from RTSP h264 codec. I could not able to get the frames from the ip camera.
$ ffmpeg -i rtsp://xxxx:yyy@192.168.1.yy:xx/tcp/av0_0 -f image2 -vf fps=fps=1/120 img%03d.jpg

My output
ffmpeg version 3.1.1 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.1)

  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --disable-yasm

  libavutil      55. 28.100 / 55. 28.100

  libavcodec     57. 48.101 / 57. 48.101

  libavformat    57. 41.100 / 57. 41.100

  libavdevice    57.  0.101 / 57.  0.101

  libavfilter     6. 47.100 /  6. 47.100

  libswscale      4.  1.100 /  4.  1.100

  libswresample   2.  1.100 /  2.  1.100

  libpostproc    54.  0.100 / 54.  0.100

[rtsp @ 0x2dba3a0] CSeq 6 expected, 0 received.
    Last message repeated 5 times

[rtsp @ 0x2dba3a0] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size

Consider increasing the value for the 'analyzeduration' and 'probesize' options

Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from
'rtsp://xx:yy@192.168.1.xx:yy/tcp/av0_0':

  Metadata:

    title           : streamed by the RTSP server

  Duration: N/A, start: 0.000000, bitrate: 64 kb/s

    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc

    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s

Output #0, image2, to 'img%03d.jpg':

Output file #0 does not contain any stream

Exiting normally, received signal 2.

Try ffmpeg -analyzeduration 1G -probesize 50M -i rtsp://xxxx:yyy@192.168.1.yy:xx/tcp/av0_0 -f image2 -vf fps=fps=1/120 img%03d.jpg My output

It didn't work. Got the same output. I can see two streams both audio and video. I need only video stream to get frames. Is there any conflict between those streams?

Do you know the resolution and frame rate of the video?

Thanks Mulvya. I actually got it now with this. ffmpeg -rtsp_transport tcp -i rtsp://xx:yy@192.168.1.ee:fd/tcp/av0_0 -f image2 -vf fps=fps=1 hello/img%03d.png

I got it working with the following command, finally. I missed out using rtsp_transport.
ffmpeg -rtsp_transport tcp -i rtsp://xx:yy@192.168.1.ee:fd/tcp/av0_0 -f image2 -vf fps=fps=1 hello/img%03d.png

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
H.264 adding dark anti-aliasing even on high444 yuv444p
I have a PNG file with white on red and no antialiasing at all - each pixel is either white or red, but when I encode it to MP4 using ffmpeg -i test.png  -profile:v high444 -pix_fmt yuv444p  -loop 1 -crf 0 -framerate 30 -c:v libx264 -t 15  test444.mp4 the output gets dark pixels added and the white color gets changed.  See zoomed in screenshot below for before and after.  I played the mp4 file with ffplay btw.

Original PNG below:

Can you share the original PNG?

@Mulvya added original PNG - thx

This appears to be a scaler issue, not the encoder. I'll look into it.

@Mulvya is there a way to disable or change the scaler to see if that resolves it? I tried using bitexact in light of your comment but it didn't solve it. Thanks

How did you view and take the screenshot of the output?

@Mulvya Viewed using ffplay test444.mp4 and screenshot taken using Greenshot (note that a screenshot of the PNG file has no issues - only of the resulting MP4 file). Thanks

It's a rendering artifact, not an actual error.
See
ffplay test444.mp4 -vf scale=iw*16:-1:flags=neighbor

and
ffmpeg -i test444.mp4 roundtrip.png

You should see no black pixels.
Update: ffplay downsamples YUV inputs to 420 before final conversion to RGB.
[swscaler @ 0000000005a82800] bicubic scaler, from yuv444p to yuv420p using MMXEXT

You can avoid artifacts by directly calling pixel format filter.
ffplay test444.mp4 -vf format=bgra

How weird - I wonder why the player would possibly decide to add those dark pixels.

I think decoder/display uses yuv420

That's right. See workaround.


text:
After Effects - middle point line animation
I have line with 3 points and I want to animate middle point to top. Please help me!

I found my answer. See this GIF:


text:
What frame rate is the iOS camera aiming for when it shoots 24fps VFR?
Almost every time we deal with footage that was shot on an iOS device in a post production workflow, we find it's Variable Frame Rate (aka VFR) rather than Constant Frame Rate (CFR). The hardware seems to be doing timing based on a 600 Hz internal clock, so within the mov the timebase is based on 600 ticks per second. But what I'm seeing on multiple mp4/mov AVC clips shot on an iPad Pro running iOS 15.2.1 is that almost every frame is 25 ticks, but with every 30 seconds one frame will be 26 ticks. This results in an effective frame rate between 23.99865 fps and 23.99880 fps. I would understand a system where most frames are one number of ticks but occasionally one is longer if it resulted in a more common framerate, but that number seems very strange to me.
Does anyone know why this would be a goal? Did someone at Apple just mess up their math, or is there some application where that frame rate would be desirable (instead of, say, 24.00 fps or something closer to the ntsc-film standard of ~23.976 fps)?
UPDATE: This continues to be the case at least through the iPhone 14 Max, running iOS 16.3

I tested BlackmagicCam and the iPad Air iPadOS 18.0.1 stock Apple Camera with 4K HEVC 25fps. MediaInfo reports constant frame rate for the former and variable for the latter.

Hopeful! I'm not currently in a position to do much testing directly anymore but in my previous testing of apps that claimed to (but didn't) fix the framerate I found it helpful to record for at least 60 seconds. If the clip is short enough that the phone hasn't inserted one of the 26-tick-length frames, MediaInfo will report CFR. Just something to watch out for!

Thanks for the note. I took 5 minute HD HEVC 25fps with BlackmagicCam and there Invisor reports variable frame rate 23.810-26.316 fps.

When shooting at 24 frames per second you are better off using a professional camera which can shoot at 24 frames per second. NTSC based field rate equipment has a compromise and it will be 23.976 frames per second. NTSC field rates were know as 30 frames or 60 fields per second but they were actually 29.97 or 59.94. NTSC was the result of adding color to an existing monochrome standard. There's a thorough explanation of how the math for this worked here. The 625 line systems which adopted a lower field rate due to the higher line rate and the need to ensure channel usage was maximized and they just sped up the film shot at 24 fps so it sounds higher pitched and for people like me with Migraine, working with 625i50 editing screen you need external light to cut the flicker effect which ordinary viewers do not notice. So it is a mess and if you want 24 fps then you need a pro camera which can capture it.

But Rich to your point, interestingly because the iPhone's internal timing crystal seems to be exactly 600 Hz to a relatively high degree of precision, on a pure hardware level as far as I can tell it can shoot 24.00fps, it just is set in the software not to do so. This seems to be a simple mistake on Apple's part, confusing clock ticks with frames, but I guess I'm looking for more info from that perspective. Just telling productions not to shoot on phones isn't super practical, sadly


text:
Android Streaming and Recording at Once
PROBLEM: Video should be streamed (Youtube) with low resolution for live view, but recorded in HD resolution for later review.
RESEARCH: I can stream and record separately. But using Android camera by two apps simultaneously is prohibited. Android 7 is used.
QUESTION: How to stream with low resolution and finally get video with high resolution?

The simple answer is that you need one piece of software that can handle both recording and streaming.  Product recommendations for a specific piece of software that can do this are likely to change frequently and probably aren't a great fit for the site.  You might have better luck on Software Recommendations.

I found an easy and suitable solution:
launch Youtube streaming app and Android screen capture app at once. Only first app has monopolian access to camera in this case.
As of 2018, highest rated are AZ Screen Recorder and DU Recorder.
Thus I can stream outside low quality live and save to tablet with HD.

Some background: when you want to use Camera in Android (as an application), you must setup it by specifying some constants. You must specify resolution, framerate, encoder options. This data usually used by internal CPU (DSP) for producing encoded stream in your hardware, you can't programm it. So, you must setup some options and get encoded stream for this options.
So, sorry, you can't use multiple applications at same time. At least, with different options (framerate).
But you can do workaround: you can decode HD stream, scaledown, encode again and stream to any service you want. This is very heavy task for CPU (in which apps works), so even if your phone can do it, it will very fast drain battery. Better way if to stream HD to some PC or server, recode it and re-stream to any other service.


text:
Video corrupted because of force restart when capturing

I was capturing my video using Vmix Live Video Streaming & Video Mixer Software when suddenly my computer restart itself. The file was saved with size of 3GB in my local drive. I used AVI format.
But when I try to open the video file, it looks like the file is corrupted and couldn't be opened. What can I do to fix this??
Any help would be very appreciated, thanks.
UPDATE:
This is the screenshot when I open the file in VirtualDub Hex editor

UPDATE:
This is the screenshot again where the zeros end.

UPDATE:
This is the screenshot of a working file.

Don't panic
Download virtualdub and try to open in it. Try select "direct stream copy" and save new file. AVI container very easy to fix.
If you using h264 codec inside, you can try to use my tool https://github.com/bookkojot/mp4fixer

It doesn't work, it says "the file is of an unknown or unsupported file type" when I tried to open it.

VirtualDub -> tools -> hex editor -> open file -> post screenshot here

Ok, I've posted it in my question. I can't screenshot all of them though, I think it have million lines of hexadecimals.

Ok, things goes worse than expected. Try to scroll down, you see anything other, than zeros?

Yes, the zeros stop at line 1F6E0

Very good. You posted piece of uncompressed sound. Now, can you record few seconds /using Vmix Live Video Streaming & Video Mixer Software/ and save it in proper way? May be you have some old files? I need only small piece of working file with exactly same parameters.

Where a you? You don't need help anymore?

I'm very sorry for my very slow response, it has been a very busy week. However I still really need your help and very glad to have it, I've added new screenshot of a working file. Thanks.

Excellent! Copy your damaged file (all experiments done only on copy!) and paste header of healtly file in it (0...0x150, before zeros starts). Try to open in VirtualDub.

Also, you can try this: https://expirebox.com/download/4338e9acafa820fc55a521c280afca21.html (pass: 123), just drop broken file over avi.exe and wait some time. This is bad method, as it uses reencoding in process. But you will see content of your file, what can be restored.

How to copy and paste the header?? In hex editor I can only view them but not edit them.

Try winhex. Or app on my link.

I've replaced the header but it didn't work, but now in virtualdub it says "The main movi block is missing"

Okay, but copy a little more. Find on good file a small string "movi", skip 16 bytes and copy all header, including "movi" and 16 bytes to copy of the broken file.  Also, you tried tool on my link, may be it will be easier?

How your progress?

I've copied the movi block, and opened it in Virtual Dub, now I can play it :)
.
Although there's some warning:
_[!] AVI: Index not found or damaged -- reconstructing via file scan.
[!] AVI: Invalid chunk detected at 96740. Enabling aggressive recovery mode.
[!] AVI: Keyframe flag reconstruction was not specified in open options and
the video stream is not a known keyframe-only type.  Seeking in the video
stream may be extremely slow._
But still, the video can be played now, I will click save as AVI now. Thanks for your help, really appreciate it :)

It's very good. Thanks!! Of course, you could just use a ready tool, which I uploaded for you.

Yes, i want to try that but when i want to download the app, the link has been expired. I would be glad if you could re-upload it, thanks.

Actually, you don't need it anymore, as you can open your file

You can also use an ffmpeg copy command. Usually fixes this kind of thing, and no quality loss.


text:
How to set pts time format when using ffmpeg filter to add timestamp
I want to add timestamp of current played time to a video, so I use this:
ffmpeg -i video.mkv -filter_complex "drawtext=fontfile=/Library/Fonts/Arial.ttf:
       text='timestamp: %{pts \: hms}': x=5: y=5: fontsize=16:
       fontcolor=yellow@0.9: box=1: boxcolor=blue@0.6" -c:a copy -c:v libx264 -map 0 output.mkv

This comes out that the timestamp was in hh:mm:ss:mm format, but I want it in hh:mm:ss format. So how can I achieve this goal?

Use
text='timestamp \: %{pts\:gmtime\:0\:%H\\\:%M\\\:%S}'

It went wrong: [Parsed_drawtext_0 @ 0x7fe6e840fd40] Could not load font "%M\": cannot open resource and [AVFilterGraph @ 0x7fe6e8708020] Error initializing filter 'drawtext' with args 'fontfile ***'

I'm on Windows. You probably are using the bash shell. You can try skipping the slashes between H M and S.

Yeah, you are right! On macOS use this: text='timestamp \: %{pts\:gmtime\:0\:%H %M %S}', It seems that \: between H M and S is not allowed. So the ":" has not escaped. I'm wondering how to escape ":". Thanks a lot!

@WayneChen
Fedora Linux fish I used "...:text=%{pts\\\:hms}" as an example for escaping parameters.  I already had to escape single quote character using this: set fileE (echo "$file" | sed 's|\'|\\\\\\\\\\\\\\\'|'), so I would say keep adding slashes carefully until it works interpreted as a literal and not a filter or function parameter/argument separator.

Do
In order to draw Timestamp: 01:25., you should specify this one to (feed) ffmpeg:
drawtext = text = 'Timestamp\: %{pts\:gmtime\:0\:%M\\\:%S}.'

Don't
If you specify this one to (feed) ffmpeg:
drawtext = text = '%{pts\:gmtime\:0\:%M\\:%S}'

, it gives Unterminated %{} near '{pts:gmtime:0:%M\' error.
But in bash
But if you're using bash-like shell and a weak quote, "......", to feed it,

\\ is escaped to \, and
\: is not escaped but remains without any changes because \: is not an escape sequence.

So it should be:
-filter_complex "drawtext = text = '%{pts\:gmtime\:0\:%M\\\\\:%S}'"

i.e. bash's "\\\\\:" for ffmpeg's \\\: for getting a single character : displayed.
Note that
If you only want to apply one or more filters to one video stream (e.g, drawtext), you can use -vf instead of using --filter_complex. The latter is reserved for applying filters on multiple streams.


text:
ffmpeg - video with timer
I am currently working with the drawtext and drawbox filters to recreate a similar video appearance to what is shown below in the image. I am trying to see of a possible ways to add a count down timer to display video duration. The timer could either be placed in the upper left or right hand corners.
I am able to generate a test video showing a timer this way: ffplay -f lavfi -i testsrc OR  ffmpeg -f lavfi -i testsrc -vf crop=29:52:256:94 -t 10 timer1.mp4. However, how can I display a timer?
drawbox/drawtext filter settings
ffmpeg -i "/media/test/test.mp4" -vf drawtext="fontfile=/usr/share/fonts/truetype/open-sans/OpenSans-Regular.ttf:text='Title of this Video':x=(w-tw)/2:y=(h-th)/2"  /media/test_edited.mp4"

desired output

Why did you remove the image showing the desired output? Without it, the question is totally unclear.

This is possible but will require scripting. ffprobe will be used to determine the duration of the input, then the countdown and background box will be created by the drawtext filter.

A 30 second input will start from 30 and count down to 0.
Example:
input=input.mp4
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nw=1:nk=1 "$input")
ffmpeg -i "$input" -vf "drawtext=fontfile=OpenSans-Regular.ttf:text='%{eif\:$duration-t\:d}':fontcolor=white:fontsize=24:x=w-tw-20:y=th:box=1:boxcolor=black@0.5:boxborderw=10,format=yuv420p" -c:v libx264 -c:a copy -movflags +faststart output.mp4

If you prefer rounded corners you may be able to make a PNG file with alpha, and then place it in your desired location using the overlay filter. Doesn't seem worth it to me though.
If you find the duration from ffprobe to be inaccurate then you will have to completely decode the file to get the actual duration and then parse the console output. One method would be: ffmpeg -i input -f null -.
This may be possible to do without ffprobe but I don't have an alternative method at the moment.
You can combine this filterchain with the one from ffmpeg drawtext filter - create transparent background with text to get exactly what you want. An oversimplified command could then look like:
-vf "format,drawbox,drawtext,drawtext,format"

@Code_Ed_Student It will vary in width according to the number of digits. If that's annoying then dump all of the box related stuff from drawtext and make another box with drawbox instead. If you want to keep using the current method with drawtext then boxborderw will control the "padding", but you can't independently control top, right, bottom, and left like you can in CSS.

Let us continue this discussion in chat.

You are absolutely right, I am sticking with just having it in drawtext. I just increased the boxborderw to ultimately get what I needed it. Thanks for all the help! what are the coordinates to place timer in the left corner?

@Code_Ed_Student Top left? That's the easy one because that's the default. You can probably use boxborderw + whatever margin you want, so if boxborderw is 10, and you want a 10 pixel margin separating the box from the left and top edges, then x=20:y=20 or x=20:y=x. You will have to experiment.

I have another ffmpeg question in relation to crossfading: http://video.stackexchange.com/questions/15740/crossfading-audio-at-beginning-and-ending-of-video

@llogan probably need your help over here: https://video.stackexchange.com/questions/26036/translate-ffmpeg-drawtext-bash-code-to-batch

@Arete Unfortunately I know nothing of Windows batch file scripting.


text:
Is the Flycam Galaxy Arm and Vest compatible with a Steadicam Solo?
I am planning on getting myself a Steadicam Solo Stabilizer and Monopod from B&H Photo Video. However, for my purposes I would really need an arm and vest kit that I could mount it onto. While I saw that from B&H I could get the stabilizer with the Merlin arm and vest, but judging by reviews I think that the Flycam Galaxy Arm and Vest is higher in quality and more value for money. I definitely need an arm and vest, and I don't want to change my stabilizer, but I would simply like a yes or no answer: Is the Flycam Galaxy Arm and Vest compatible/can it fit onto and work with a Steadicam Solo, and if so, does it reduce performance as it is third party?
Thanks in advance.


text:
ffmpeg: color loss when encoding to .webm
When encoding to webm (specifically VP8, i.e. libvpx), the color range gets reduced from 0-255 to 15-235. This causes a washed-out look; blacks become faded and not as sharp.
I have found solutions to this problem for mp4, but can't find one for webm. (With an mp4, you can add -pix_fmt yuvj420p. I have tested that and it works for mp4. However, libvpx does not recognize this option.)
The command I'm using is ffmpeg -i in.avi -c:v libvpx -crf 8 -b:v 5M -an out.webm

Update: while the below comment fixed the problem for me, I've noticed that browsers seem to do some of their own color conversion when displaying video. It looks like they do a TV->PC conversion, eliminating a lot of the washed-out look of video. Possibly they do this to account for the fact that most video is in the clipped range. When playing my improved version, the blacks look overly dark, and I prefer the original version.
But when played in VLC, the improved version shows the full color range I wanted. So I think whether you use this technique depends on where the intend the video to be played. In VLC I would; in a browser, I wouldn't.

How are you converting to limited range?

@Gyan You mean what command am I using that's producing the limited range in the final output? ffmpeg -i in.avi -c:v libvpx -crf 8 -b:v 5M -an out.webm. Although from searching it seems that either most codecs do that by default, or ffmpeg does (I'm a new to manipulating color spaces, although I understand what they are).

Use ffmpeg -i in.avi -vf "scale=in_range=pc:out_range=tv" -c:v libvpx -crf 8 -b:v 5M -an out.webm

@Gyan That didn't do it, but out_range=pc did! (I figure that was a typo, since output range=tv is what we were trying to avoid). Thank you! I had read about another hack using the scale filter, and tried it, but the command didn't work. If you'll make that an answer I'll accept it.


text:
A framerate of 30.30 has become common the past couple years. What is it about the number 30.30 that is significant? Why not an even 30, for example?
I typically resample the framerate to 30 when I'm encoding (much of my source video was streamed and has unreliable native framerate). But these 30.30 videos I tend to leave at 30.30 just because I don't know why it's like that and don't want to mess with it.

Never heard of it. I doubt that it’s common, but maybe in a certain niche? What source created the videos? Could your player software be misrepresenting the frame rate? Can you check with an alternate method?

30.30 isn't a standard frame rate. I think you see it a lot because mobile phones (especially iPhones) only "target" certain frame rates, they don't necessarily perfectly deliver them.
https://www.provideocoalition.com/understanding-iphone-framerates-for-shooting-editing-distribution/
Interpreting a 30.30 frame rate video as 30fps won't cause significant issues unless the clip is longer than a few minutes, in which case you may have lip-sync issues with the audio vs the video.

I don't mind keeping it at 30.30. I just like to know why I'm doing something. It tends to be streaming video, so my current assumption is that some popular software (maybe OBS) defaults to 30.30 or something.

See this issue I had with Premiere introducing glitches into iPhone footage: https://video.stackexchange.com/questions/30683/glitches-in-premiere-exports


text:
Why recording a still image using a mobile camera is taking up more space?
I know basic video compression technique .In that it reduces spatial redundancy and temporal redundancy.If it is so why recorsing still image using camera takes more space.Why compression technique cannot remove temporal redundancy in the still image video.

What codec are you using? Something you developed yourself?

I think it's a translation error : have --> know of

A still image doesn't have any temporal redundancy to exploit - it is a snapshot of a single point of time! Also, the quantization parameter will be low. Video compression uses higher quantization parameters since each individual frame is seen for a fraction of a second, so in a normal playback mode, the user doesn't get to focus on the details within each frame. Both of these contribute to the lower file sizes for the average image in a video.

Photographs only have one instance in time without other related instances in time, so they can't make use of temporal redundancy because there is none.  You might be able to make some use of this for bursts of photos, but then if you separate any of the photos in the burst, you won't be able to view any of the dependent images, so it isn't very useful.
That said, most photos are still larger than the size of a frame in All-I frame video, but this is because the average photo has far more information.  While we tend to think of HD as high quality and UHD or 4k as even higher quality, the fact is these are image resolutions that have been on the low end of digital photography for over a decade.  A 4K image is only around the same amount of detail as an 8MP photo and an HD frame captures around 2MP.  They seem higher quality because they make use of a lot of frames playing back over time which produces a natural anti-alias effect that makes it appear higher quality, but the actual resolution of each frame is fairly low.
So clearly, when you compare a spatially compressed image that is a fraction of the size of another image, the smaller image ends up being a smaller file size.  The photo simply has much more information to store, even if it ends up being similarly compressed.

When you write 4:2:2 I think you mean 4:2:0, which is the color space used by most of the consumer videos as far as I know

@MatteoContrini - could be.  At the higher end they use 4:2:2, but 4:2:0 is the same idea, just even less color detail.  I modified my answer to include both.  It's been quite a while since I shot on anything on the lower end of consumer.

@MatteoContrini - hmm, though in investigating further about 4:2:0 vs 4:2:2 I discovered something I didn't realize about jpeg.  It actually generally uses 4:2:0 as well, so I guess that part of the answer is just wrong because jpeg does make use of it, so I'll remove the whole section.


text:
How to fully optimize RAM Disks in Adobe Premiere CC 2017
I have an older server workstation with 12 cores (2x AMD Opteron hex-core 2.6GHz), 32 GB RAM, and a Sapphire HD6950 video card with 6x 2TB hard drives on SATA/SAS (motherboard has room for 12 drives). Despite not being a modern set-up, this computer has been fine with my previous projects of 4 camera angles at 1080/4K for live concerts 2+ hours long. As long as I don't edit with full effects on, I have never had to resort to proxies or any other tweaks.
My current project is using 8 cameras at 1080 (with one at 4K) for a 2.5 hour concert. I have had to create proxies (480, H.264) and yet editing is still unbearably slow. First I split the proxies up between 4 drives (2 per drive), but that actually seemed to make editing almost impossible. Then I consolidated all the proxies on to one drive, and I was able to edit, but had ridiculously long wait periods as the media cached. Load time can be five or more minutes when moving across the timeline, though I can actually multi-cam in real-time with this set up. I noticed Premiere never got above 11GB of RAM usage, so I thought I could move my 16GB of proxy files on to a RAM Disk, and leave 16 GB of system RAM for Premiere. This has had mixed results.
On the one hand, editing section by section is fluid and real time with zero effects on right now. On the other hand, once I get through about five minutes of timeline, the video goes blank or shows the "Media Processing" screen and I have a wait time of several minutes before the next "cache" is loaded, or whatever it is doing to process the film. My question is, is there a way to convince Premiere that my proxy files are already in RAM, or is there another way to load the hard drive versions of the proxies in to RAM so that Premiere accesses them instantly and fluidly? I don't know the process going on behind the scenes, but it seems exponentially counter-intuitive that I can handle 4 files at full resolution natively but can not handle 8 considerably reduced file versions located completely in memory.
(To clarify, this lag occurs both when viewing the multi-cam editor with 8 cameras playing back simultaneously, and with multi-cam editor turned off, showing only the single selected camera in the editor.)

[SOLVED - PROXY ISSUE IN CC2017] It took several days, multiple re-renders, and seeing multiple threads relating to proxies not connecting properly before I figured out the issue. Apparently, there are a number of individuals having difficulty with proxies in CC 2017. I first ensured the proxies were attached to the clips in the project window, which they were, then I had to replace every clip in the timeline with that same clip in the project window. Premiere then registered the proxies correctly. I followed a lot of other answers, but these were the steps I took that worked for me.

I would think that the codec of your proxies could be the issue.
H264 is very cpu intensive and this could be your bottle neck.
Switching to QT ProRes Proxy would be my first try.
A couple of links to help you out.
https://forums.adobe.com/thread/2287035
https://forums.creativecow.net/thread/3/994398


text:
How to concatenate multiple videos with fades (from- and to-black) in-between?
I recently had the following problem:
I wanted, using ffmpeg, to concatenate several videos (with audio), adding black clips (with null audio) between them , and lastly fade the videos from those black clips (fade-in) and to those black clips (fade-out).
Schematically, with 2 videos for instance:
black (1s) --> part_1 (60s) --> black (3s) --> part_2 (120s) --> black (1s)
            ^                ^              ^                 ^
       (2s-fade-in)     (2s-fade-out)  (2s-fade-in)      (2s-fade-out)

I was looking for a one-liner solution (to avoid re-encoding original videos more than once), but only found documentation or help for each part of the problem.
Having figured it out, I wanted to document my solution for those after me who will stumble on a similar problem :)

So here is what I came up with.
A not fully one-liner solution
1) Generate black clips
ffmpeg -f lavfi -i "color=black:s=1920x1080:r=30" \
 -f lavfi -i "anullsrc=r=48000:cl=stereo" \
 -c:v libx264 -c:a aac -t 3 empty_3s.mp4

Use lavfi filters to generate your empty clip. Of course, change the parameters according to your videos and what you want to achieve. Especially:

in first (video) source filter:

s (size) should match that of the videos you want to concatenate.
r (frame rate) should also match your videos (especially if your want a constant frame rate output)

in second (audio) source filter:

r (sample rate) should match that of the audio tracks from the videos you want to concatenate.
cl (channel layout) should also match the audio from your videos

Output parameters (codecs for instance) should match those of your videos. Use -t to set the length (in seconds) of the empty clip.
2) Concatenate and fade your videos using a complex filtergraph
ffmpeg -i empty_1s.mp4 -i part_1.mp4 -i empty_3s.mp4 -i part_2.mp4 -i empty_1s.mp4 \
 -filter_complex \
  "[1:v] fade=t=in:st=0:d=2, fade=t=out:st=58:d=2 [1v]; \
   [1:a] afade=t=in:st=0:d=2, afade=t=out:st=58:d=2 [1a]; \
   [3:v] fade=t=in:st=0:d=2, fade=t=out:st=118:d=2 [3v]; \
   [3:a] afade=t=in:st=0:d=1, afade=t=out:st=118:d=2 [3a]; \
   [0:v] [0:a] [1v] [1a] [2:v] [2:a] [3v] [3a] [4:v] [4:a] concat=n=5:v=1:a=1 [v] [a]" \
 -map "[v]" -map "[a]" -c:v libx264 -c:a aac output.mp4

Explanation:

we first specify the inputs (-i) that we will concatenate
we then set a complex filter (-filter_complex), that we use to:

first, fade in and out our videos. To that end we use the fade (for video) and afade (for audio) filters. We specify the start (st) and duration (d) for each fade. We output the results with outpad names ([1v], [1a]...).
then, concatenate the black clips and the previously faded videos, using the concat filter. We specify the number of input segments n (i.e. the number of video+audio sets, in our case 5) we want to concat, and the number of video (v=1) and audio (a=1) streams for the output.

we map the final output to the output streams from the concat filter
specify the encoding parameters to whatever you want :)

Important notes:

your videos (inputs) must have the same characteristics (pixel and sample format for video, sample rate and channel layout for audio). See concat documentation for more info.
in the fade filter, we specify start time and duration in seconds, but you can use frames or samples as well with s and n (video) or ss and ns (audio) options. See afade and fade filters documentation.
you must know the duration of your videos for the fade filter, especially for fade-outs. See this question for hints on how two fade-out clips without having to manually specify start time.

True one-liner
If you really want a one-liner (and not having to encode empty black clips), you can use:
ffmpeg \
 -f lavfi -t 1 -i "color=black:s=1920x1080:r=30" -f lavfi -t 1 -i "anullsrc=r=48000:cl=2" \
 -i part_1.mp4 \
 -f lavfi -t 3 -i "color=black:s=1920x1080:r=30" -f lavfi -t 3 -i "anullsrc=r=48000:cl=2" \
 -i part_2.mp4 \
 -f lavfi -t 1 -i "color=black:s=1920x1080:r=30" -f lavfi -t 1 -i "anullsrc=r=48000:cl=2" \
 -filter_complex \
  "[0:v] null [0v]; [1:a] anull [0a]; [3:v] null [2v]; [4:a] anull [2a]; \
   [6:v] null [4v]; [7:a] anull [4a]; \
   [2:v] fade=t=in:st=0:d=2, fade=t=out:st=58:d=2 [1v]; \
   [2:a] afade=t=in:st=0:d=2, afade=t=out:st=58:d=2 [1a]; \
   [5:v] fade=t=in:st=0:d=1, fade=t=out:st=118:d=2 [3v]; \
   [5:a] afade=t=in:st=0:d=1, afade=t=out:st=118:d=2 [3a]; \
   [0v] [0a] [1v] [1a] [2v] [2a] [3v] [3a] [4v] [4a] concat=n=5:v=1:a=1 [v] [a]" \
 -map "[v]" -map "[a]" -c:v libx264 -c:a aac output.mp4

In that case we must beware of the input indices, as black video clips and null audio clips are separated inputs (I didn't figure out how to put them as two streams in a single input, if you have an idea feel free to share it).
Here I applied null and anull filters to those inputs to give them outpad tags, in order to use consistent identifiers in the concat filter. But this is purely optional.
Hope this helps, feel free to improve my solution with your insights :)

You don't need to generate distinct source filter inputs for the null video and audio segments. They can be used multiple times in the filter_complex.


text:
How to trim, crop, and concatenate a reverse into video at the same time
I am using ffmpeg to first trim and crop the video, then take the output and concatenate a reverse of that onto the video. The way I'm doing it now requires me to run two commands. Is there a way to simplify it into a single command?
Currently, I'm running
        ffmpeg -i MVI_0289.mov -ss 00:00:10.50 -t 3 -vf "crop=720:720:600:80" -movflags +faststart -an OUTPUT.mp4
and then
        ffmpeg -i OUTPUT.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]" -map "[v]" OUTPUT2.mp4
Update#1: Running ffmpeg -ss 00:00:10.50 -t 3 -i MVI_0289.mov
-filter_complex "reverse,fifo[r];[0:v][r] concat=n=2:v=1,crop=720:720:600:80[v]" -map "[v]" OUTPUT2.mp4
 gives the following error:
ffmpeg -ss 00:00:10.50 -t 3 -i MVI_0289.mov
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.38)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MVI_0289.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537331968
    compatible_brands: qt  CAEP
    com.apple.quicktime.make: Canon
    com.apple.quicktime.model: Canon EOS 70D
    com.apple.quicktime.rating.user: 0.000000
    creation_time   : 2017-12-09T23:42:21.000000Z
  Duration: 00:00:19.19, start: 0.000000, bitrate: 25320 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25277 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 48k tbc (default)
    Metadata:
      creation_time   : 2017-12-09T23:42:21.000000Z
      timecode        : 00:16:56:04
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2017-12-09T23:42:21.000000Z
      timecode        : 00:16:56:04
At least one output file must be specified
-filter_complex "reverse,fifo[r];[0:v][r] concat=n=2:v=1,crop=720:720:600:80[v]" -map "[v]" OUTPUT2.mp4
-bash: -filter_complex: command not found

Run
ffmpeg -ss 00:00:10.50 -t 3 -i MVI_0289.mov -filter_complex "reverse,fifo[r];[0:v][r] concat=n=2:v=1,crop=720:720:600:80[v]" -map "[v]" OUTPUT2.mp4

I get an error At least one output file must be specified and then -bash: -vf: command not found.

@smartbean Change -vf to -filter_complex. If that doesn't work show your full command and the complete console output.

@LordNeckbeard That did not work either. Please see update to the question.

@smartbean You were actually splitting the command in half and trying to run each half independently. The linebreak was for readability and should be removed before executing the command. Try the updated command.

Oops, forgot to change the -vf in the original.

@LordNeckbeard It worked after running ffmpeg -ss 00:00:10.50 -t 3 -i MVI_0289.mov -filter_complex "reverse,fifo[r];[0:v][r]concat=n=2:v=1,crop=720:720:600:80[v]" -map "[v]" OUTPUT2.mp4  Thanks a lot to you both!


text:
What does the Multi-Camera Record On/Off Toggle do in Premiere Pro?
My experience
I'm currently creating a multi-camera sequence in Premiere Pro CC 2020 14.1.0 (build 116). I created my multicam sequence and everything is working fine.

When I press play, my sequence start playing and I can than switch between the multiple angles by clicking on a different angle or by pressing 1, 2 or 3 on my keyboard. After I've done that once I notice that the rectangle around the active angle becomes red and that the record button, the Multi-Camera Record On/Off Toggle, has a blue circle around it.

If I than pause playback, a cut has appeared in my sequence on the position where I switched angles, as expected. The rectangle is yellow again and the circle around the record button is gone. Everything works. But than what happens if I press this record button?

If I press it before I start playback, a blue circle appears around the button. If I than move my playhead the circle disappears. If after clicking the button I start playback or choose a different angle, the circle stays, but it doesn't appear to change the recording behaviour of the angles I can switch to at all.

If I press the record button during playback, but before I switched to a different angle, it makes a blue circle around the button appear. The rectangle around the active angle stays yellow though. I can than still switch to different angles and the switches I make are being recorded as usual.

If I press the button during playback after I switched to a different angle, the circle around the button disappears, but more noteworthy, the red rectangle around the active angle becomes yellow. If I than pause the playback, the angle switch is still recorded however. Once again this button doesn't seem to have any impact at all apart from UI appearance.

Research
I searched the web, checked multiple tutorial video's, searched Reddit, but no one mentions this button.
I searched this site and I found someone in 2015 mention this button in an answer. This user describes the button as a way to Toggle Multi-Cam recording. I believe he sees the pressing of this button as a required step before the angle-switches are recorded, however, as I described above, this doesn't seem to be in line with the behaviour I'm experiencing.
Over at Adobe's help website, there also is a tutorial that mentions pressing the button as a step in the Multi-camera editing workflow (step 6). It doesn't state though what the exact function of the button is.
My question
Could someone shine some light on what the purpose of this button is? Or to word it differently, what difference is there between state A and B?

The record button has three states:

Record is disabled
You're not selected on a multi-camera sequence, or you haven't enabled the Multi-camera View button, so you can't record camera cuts. (You can still change camera on a selected clip).

Record standby
If you have a clip selected, and select a different camera, the whole clip will be changed to the new camera. If you are playing a multi-camera clip, in multi-camera view and change cameras, the changes will be recorded as cuts, nothing will happen.

Record enabled
Does exactly the same as record standby, as far as I can tell.
At this point, I think the blue circle must only be there because they though it looks nice. It's like the close button on an elevator door....
The rectangles around the multi-view cameras show:
yellow - which cut is active
red - a new cut that you have just written
As soon as you stop playback, the red rectangle highlights become yellow highlights.

The button is used to show, in the main window, the original top video in the source, and the selected video. It ignores your current camera selection if off, or shows your current camera selection when on.
The problem is that when you select a new camera, it automatically goes on. Thats the confusion :)


text:
Sony FS5 border artifacts
I've got a problem with trying to key the green color with some footage I shot with a Sony FS5. The main object in the frame has some kind of white/light grey border around it which makes it very hard to separate it from the green screen background. Here are some examples:
Original footage...
Trying to key with Keylight in After effects...
I shot in 1920x1080, 50 fps 4.2.2 with the internal AVC codec.
I think it could be caused by the in-camera sharpening settings, I tried to change the settings but I didn't notice any change.
Each channel isolated (RGB) not keyed:

You mention that you changed the sharpening settings.  What exactly did you do, and how did you asses the change?  The sort of halo that is extremely visible in the R channel looks a lot like some sort of a sharpening filter, not like a 4:2:2 subsampling issue.  They may be additional settings you need to fiddle with in the camera to tone this down.

The other answer is correct that 4:4:4 gives better green screen results. But given that you need to fix your footage, can I recommend both of these tutorials

The most important takeaways from these in my opionion are:
Use the Status setting of the Keylight plugin with a secondary monitor of your footage, so that you can ink-drop precisely the best colour of green to key.
Adjust the black and white points of your matte whilst looking at the Status output.
Use Keylight's Intermediate mode with the Key Cleaner and Advanced Spill suppressor.  It gives great results but takes longer to render.

Have you tried tweaking the settings in Keylight? It looks like the screen replace colour you are using is too light for the black background.
Keylight is a great plugin, and in a perfect world give you one-click keying. But in the real world you usually need to tweak it a bit. The first stop is to check the screen gain and screen balance settings. These look ok for your example, but what you might need to look at is the Screen Replace Color setting.
This setting allows you to pick which colour will be used to replace the screen colour in any pixels that are partially transparent. So on the edges, there are pixels that are partially green and partially foreground colour. To prevent green fringes, once the green has been extracted another colour is put in. By default I think it is  mid grey, which presumes that your new background averages out to mid grey. On a black background it shows up clearly. Change the Screen Replace Color to black and that should fix the fringes.
A guide to what the settings do is available at the keylight page.

Thank you for the answer. I tried but it didn't fix the problem. I think it's some flaw in the footage itself, maybe because of chroma subsampling. I'll post a reference for each color channel in the original post.

Chroma subsampling usually leads to blockiness in keys, because the chroma is at a lower resolution than the Luma. That's not really what I'm seeing in the examples. The fringe looks pretty smooth. It could be from ringing in the camera. You could try turning the screen gain up maybe. The green channel looks like it should give you a solid key.

In regards to the green and black mixing, 4:2:2 means pixels are merged and this will always happen, this is why movies shoot in 4:4:4 because then there is no merging of colors.  But I have no idea why you are getting a white halo around a black object with a black background.


text:
FFmpeg - how to adjust video (clip) duration to sound duration if sound is longer, possible without re-encoding it with mp3 file?
I have a problem. I have recorded my videos separately, and then added sound to it. Sometimes, sound is longer or less in duration compared to video duration. Usually sound is longer, sometimes around 20 seconds. To me, when running on my PC through flv or some Windows Media player, that is not problem, since after video is over, last capture of video stays displayed (like an image), and sounds is still executing, and video ends after sound is over. So everything is ok at my PC when running it like .flv or .mp4 file. But, when I upload that on Google drive or some other place on web (that is, when I run it in my browser for viewing after upload), I see my video is cutted to the lenght of the video duration (so my sound is cutted). I understand that this is because of different duration sizes of sound and video.
Now I need a command with ffmpeg that can make my video to be extened to my sound duration. I would like not to reencode my videos with sound again (in sense that I would need to put my mp3 file in ffmpeg command) if I don't need (since I have many videos and sound is already inserted in them), but just to re-encode video with some ffmpeg command to extend video lenght to sound lenght.
I have watched this (not sure at the momen if this would even help me): https://superuser.com/questions/801547/ffmpeg-add-audio-but-keep-video-length-the-same-not-shortest
But with this approach, you have to reencode video with sound (mp3 or similar) file first.
Can it be done, and what would be command, or commands for it? (And if only way is to re-encode it with mp3 file, what would be command for it?)
Edit: I don't want to cut my sound, I need to hold last frame till my sound is over. Currently last frame is holded only when viewing on my PC, when I upload that, clip is cutted immediately when video stops.

You could make a still image of the last frame then concatenate it with the video and loop it until you get to the end of the audio.

stib, I understand, but making still image and concatenation is too much job (specially if there are many videos). That is why I am asking if there is a way to more elegantly adjust it with ffmpeg.

You can do it all with ffmpeg, so if there are many videos you could automate it.

I can't reproduce this behaviour at Youtube. Media plays till the audio stream concludes.

stib, any example? I really researched a lot, and find nothing that helps me. Mulvya, I never mentioned youtube, and my sound is recorded separaretly in these videos. Sound is added directly copying (without re-encoding). If you upload that kind of video with different sound lenght on Google drive for example, it will cut it. I think youtube will do the same, you just haven't had video with my example.

You can hack this using mp4fpsmod (direct link to Win binary; C++ source at https://github.com/nu774/mp4fpsmod).
First step is to extract the timestamps of the existing video
mp4fpsmod -p vid_tc.txt vid.mp4

This will produce a text file like this
# timecode format v2
0
40
80
120
...
4880
4920
4960

Each line contains the timestamp of frame #N in milliseconds.
In this example, each frame is 40 milliseconds long and the last frame is shown at 4960 ms and hence the video stream is 5 seconds long.
Now suppose your audio is 11.34 seconds == 11340 ms long. Edit the last timecode to something just under 11340, like 11320.
# timecode format v2
0
40
80
120
...
4880
4920
11320

and then run
mp4fpsmod -x -T keep -t vid_tc.txt -o vid_new.mp4 vid.mp4

This will create a new file vid_new.mp4, which you can upload. The duration shown in desktop players or tools can be wrong, but playback should be as desired, except that the last frame is shown along with the end of the audio. This skips re-encoding and is quick. You can add -i and skip -o vid_new.mp4 if you want to edit the timecode in-place in existing file i.e.
mp4fpsmod -x -T keep -t vid_tc.txt -i vid.mp4

but I don't recommend it.

Thank you, I will try it. Will this maybe ruin quality of video my video since this isn't ffmpeg? Everything should stay as it was for me - resolution, quality, etc. And second, if I want to remove problem with how duration is shown in desktop players you mentioned, what would be the way? Re-encode it with mp3 file? P.s. I've found this, but I haven't tried it yet, maybe this would be (correct answer on this link) what I am searching for If I don't want to involve mp3 file directly?: https://superuser.com/questions/871084/ffmpeg-extract-audio-with-exact-frame-length-of-video?rq=1

There's no re-encoding so there's no quality change. The answer at SU won't help if the audio is longer.

Thank you Mulvya. I will try it. Just one more question - you've mentioned it has to be set under 11340 in example. You've set it to 11320. Could it work properly if it is set only to 11339? And what would happened if is set for example, to 9000? I guess that setting number to low could ruin ending?

Any number just lower than the audio length is fine. So 11339 is fine. The idea is to increase length so 9000 won't work for an audio stream of 11.34 seconds.

All right. And just wondering, can mp4fpmod get mp3 file length or it is just working with video files? If that is the case, I'll have to or either read it manually (really not problem) or get precise info through ffmpeg
https://stackoverflow.com/questions/10437750/how-to-get-the-real-actual-duration-of-an-mp3-file-vbr-or-cbr-server-side

mp4fpsmod only looks at video streams.

I have tried it. It doesent work at all. Absolutely nothing from it. Everything is the same after the upload.

Share the file, if you can.

Thank you for this answer. The resulting video doesn't play properly in mkv. I doubled the video length, but mkv thinks the video is 3 times as long. But after uploading to Youtube, it works perfectly!


text:
Nuke studio GPU
I'm working on my first project on nuke studio 10.
The sequence is 10 mins long.
I set the default blink device to my NVidia titan x. My machine is a Mac pro 5,1
12 cores.
I tried to export the sequence quicktime prores 4444 and I set it to use 6 cores as the threats number.
I wanna know if it's possible to render or export using my gpu becayse it gave me estimated time like 1 hour and a half.
And when I try to export the same sequence from premier pro cc, it takes 4 mins because media encoder is using cuda processing to encode the sequence.
Thanks


text:
Can't make a clip in FinalCutPro X longer
I am pretty new to FinalCutPro X and want to make my timelapse video with it. So far so good... I am almost finished...
But in the end, I'd like to make it a bit longer.
What I have are a couple of compound clips for each part of my video and then in the end I made one more compound clip with all of the parts to be able to easily adjust the length of the whole video to the music I am using.
Now I wanted to add some more images to my last segment but then I can't drag the clip longer. It will show a red border at the end and wont make it longer. Also, the part on the right is kind of grayed out.
Hard for me to explain the problem, so I made some screenshots.
First one shows the one big compound clip

Second shows the inner ones (each represents one week)

And inside those are individual images. Even when I add a couple of more images to the last compound clip, I am not able to make it longer...

Any idea of what I am doing wrong would help me a lot!!!
And... just a very quick question (don't want to create a whole question for it)... When I slowmo a clip it will show this drag-handle-bar on top to adjust the speed. When I close the project and reopen it again, they are gone... Is there a quick way on how to get them back?
Cheers,
Georg

The red line is shown when there is no more source media left. You've dragged the end of the clip all the way to the end of the source file, so there's no more media to be added. Imagine a video 5 seconds long, of which you've added the first 4 seconds to the timeline, then you try to drag the end of the clip in the timeline beyond 5 seconds — you can't, because there's no more source media in the clip.
The end of the timeline when viewing your compound clip is greyed out because this section is beyond the end of the compound clip range in the containing timeline. The main timeline which contains the compound clip is only showing a portion of the compound clip, and the video in the compound clip beyond the greyed out area will not be played. To play this section, drag the end of the compound clip in the main timeline until the red line is shown.
To quickly show/hide the retime editor for any selected clips, press cmd-R.

Thank you very much for your help!!! I updated my question to also show the inside of the second compound clip. You can see in there, that I have images inside that compound clip that are more than the grayed out area shows. So I'd expect that I should be able to make the compound clip longer. And once that is longer, I'd expect to make the outer one also longer?!? But it's not working...


text:
RTSP to RTMP converting fails after specific time only when IP camera enters night mode
I have bought a cheap IP camera Escam QF002 producing output in RTSP.
I'd like to secure it with RTMP or HLS stream served by nginx with nginx-rtmp-module.
For this I'd copy the video stream (h264) and transcode audio(pcm_alaw -> aac), using:
/usr/bin/ffmpeg -loglevel debug \
  -i 'rtsp://192.168.1.2:554/user=admin&password=******&channel=0&stream=0.sdp?real_stream--rtp-caching=100' \
  -vcodec copy -acodec aac -f flv "rtmp://localhost/escam/stream"

After ~260 seconds (same value each time) of successfull stream, no valid output is produced any longer and the message is being spammed:
Delay between the first packet and last packet in the muxing queue is 10020000 > 10000000: forcing output

This seems to happen only when camera is in "night/infrared" mode. Some differences may be logged:
Night mode: reported framerate converges to 13 fps and inital frames are passed with 488 DTS
...
[flv @ 0x1d53710] Non-monotonous DTS in output stream 0:0; previous: 488, current: 385; changing to 488. This may result in incorrect timestamps in the output file.
....
frame= 1451 fps= 13 q=-1.0 size=    5357kB time=00:02:11.84 bitrate= 332.8kbits/s speed=1.16x

Day mode: reported fps converges to 20 fps, and and inital frames are passed with 300 DTS.
But each time the input stream is defined as:
Stream #0:0, 0, 1/1000: Video: h264 (Main), 1 reference frame ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive, left), 1280x720 (0x0), 0/1, q=2-31, 20 fps, 13 tbr, 1k tbn, 90k tbc
Stream #0:1, 0, 1/1000: Audio: pcm_alaw ([7][0][0][0] / 0x0007), 8000 Hz, mono, 64 kb/s

So far only disabling the audio stream with -an allows for continuous streaming. Copying the stream without reencoding audio (-acodec copy) or writing to file results in same error.
What could be the issue? Why this is specific to night-mode only?

EDIT:
I think I need to post it as another thread, since this turns out to be an XY problem.
I guess the issue is connected with improper PTS/DTS for the video frames returned by RTP.
FFmpeg reports, that video input has 20fps, while actually it returns ~ 13fps (tbr):
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720, 20 fps, 13 tbr, 90k tbn, 40 tbc

Probing the input frames with ffprobe -show_frames -read_intervals %+100 'rtsp://host/stream' gives the following info for video frames:

pkt_duration_time = 0.05s, pkt_duration = 4500
increment of pkt_pts is 6923, increment of pkt_pts_time is ~ 0.077s, same apllies to pkt_dts, pkt_dts_time, as well as best_effort_timestamp, best_effort_timestamp_time

The PTS/DTS must be somehow recalculated from the default 0.05 (I'm not sure whether done by ffmpeg or source itself). However this interval is to small compared to audio stream - as seen on the graph below. This results in video being remuxed faster than audio.
Questions:

Are RTP h264 DTS/PTS given by stream itself, or calculated by ffmpeg?
What's the proper way to modify these to match audio DTS/PTS?

I've solved the issue by rebuilding the timestamps from scratch with -use_wallclock_as_timestamps 1 and -fflags +genpts.
/usr/bin/ffmpeg -use_wallclock_as_timestamps 1 -i "rtsp://${source}" -fflags +genpts -vcodec copy -acodec aac -f flv "rtmp://${dest}"
This is only a partial solution, or rather workaround, as it's still unclear to me what causes this behavior.

Your input stream config as set in the input video bitstream is different than actual frame throughput. Happens during night or low-power mode.

Is then the posted method the proper solution, or should I consider another approach? Setting variable fps on input with -re option does not work as it causes multiple packets to drop.


text:
Create a splitscreen video from two videos of different lengths with delay
I want to create a splitscreen video from two video clips.
Left one is of duration 70seconds.
Right one is of duration 80seconds.
In the splitscreen video, the right video should start first. Left video shouldn't start for first 15 seconds. After 80s, i.e. after right video ends, left video should continue. So, the final splitscreen video should be of 85 seconds. For the first 80 seconds, the audio should be from right video and for the next 5 seconds, it should be from left video. Or vice-versa is also fine (i.e. first 15 seconds, audio from right video, next 70 seconds, audio from left video). How to do this?
Another optional requirement: For first 15 seconds, when right video is playing, in the left part, instead of black screen, it would be preferable to have the first frame (image) of the left video. So, after 15s, when left video starts, it takes off from there. Similarly, after 80s when right video stops, instead of black screen, it would be preferable to have the last frame of right video there.
Thanks
Edit: Opensource software is preferred.

A bit busy; will answer in a day or two.

Get some basic knowledge of premiere Pro first.

Import both videos and set the settings for your output.
Move the right video in the timeline to where it should start.
Use effects to slow down or speedup your video
Create a still of the first frame and add it to the layer. You can do this as easily as a screenshot and cut it out with photoshop. Ah hell even import the video to Photoshop.


text:
Why does text or graphics in premiere pro have two boxes?
First the red box is selected

now if you click outside and click near red box the main box is selected

moving this box also moves entire graphic

what is this box called, how do you center it etc.
GIF

UPDATE: it is NOT the black video...

Do you have anything else in your sequence? Can you add a screenshot of your whole premiere screen?

no there is nothing just create a new file and add text or a square you fill find it, let me make a gif

added a gif that shows the problems

How odd.. Deleted my answer because it's not correct.  I can't replicate what you're seeing.  Maybe it's a bug?  Update to latest version, reboot, etc?

I can't replicate it either.

ok ill update so it must be a bug, ill report if update fixes it


text:
Video recording framerate limitation causes? (e.g. 1080p at only 60fps despite same camera records in 2160p?)
I know, smartphone cameras are maybe not the primary interest of professional videographers, but I am interested into the technical aspects.
They can also be relevant for real cameras.
There are irrational video recording specifications in some smartphones compared to others:

2160p@30fps = 1080p@120fps = 248832000 pixels per second. Keep this magic number in mind.
The Galaxy Note 3 from 2013 records at 2160p@30fps (248832000 pixels per second), yet only 1080p@60fps (124416000 pixels per second) instead of 1080p@120fps (248832000 pixels per second). The same is still valid for Galaxy Note 8 (late 2017).
The Galaxy S4 has around 80% as much processing power as the Note 3. Yet th S4 is limited to 1080p@30fps (62208000 pixels per second), while the Note 3 hit 24832000 pixels per second?
The front camera of the most phones is still limited to 1080p at 30fps, despite the image sensor has a much higher resolution and should also cope with 60fps.
Galaxy S7 doubles framerate at 720p (120fps→240fps or 110592000→221184000 pixels per second), yet the framerate at 1080p@60fps and 2160p@30fps compared to predecessor stayed the same?
The new iPhones (8,8+,X) are able to capture 2160p@60fps(497664000 pixels per second) and 1080p@240fps(497664000), which is even beyond the Lumix GH5's 1080p@180fps (373248000) How is that technically possible?
The OnePlus 5 from 2017 still had 720p@120fps, which the Note 3 had in 2013 already (let's disregard framerate distortion, because this is about the recording capabilities), and the OnePlus 6 suddenly jumped to 720p@480fps (I wonder what causes the 1 minute limitation)? The iPhone 6 from 2014 reached 240fps despite the OnePlus 5 (720p@only120fps) has more powerful hardware.
The Galaxy S7 (2016) allowed 2160p video recording without any fixed time limitation on Android Marshmallow. On Android Nougat, it got limited to 10 minutes. Earlier Samsung phones: 5 minutes, Galaxy Alpha: 4 minutes.
The Galaxy Note 3 plays back 1080p@120fps and 720p@240fps without any lagging. Frameskipping?
The Huawei Mate 8 still did not offer 2160p video capture, despite being a flagship in 2016, and equipped with similar hardware as other flagships that offer 2160p.
Some phones phones such as UleFone Armor 2 and Galaxy A series are limited to 1080p@30fps and have no high framerate mode at all, despite it has 65000 points in AnTuTu, while Galaxy Note 3 with 1080p@60fps and 2160p@30fps and 720p@120fps has just 44000 points, and even the Galaxy Note 2 has 480p@120fps with only ~30000 points?
iPhone 5s (2013) records 720p at 120fps, and Apple has always proven to be a framerate king in the years after. Yet 5s only has 1080p at 30fps despite 60fps should have technically been possible. The Note 3 (2013) was the peak of Samsung's superiority.

I need help understanding the background behind these limitations.I would appreciate a technical explaination.


text:
FFmpeg, record screen region on Mac
I am trying to record a screen region on Mac using FFmpeg. I have a solution using avfoundation device to grab the screen and using a filter to crop down to the screen region. This works fine for certain situations but does not work when either the screen is scaled to different resolution or when the screen orientation is sideways.
My command looks something like
ffmpeg -y -f avfoundation -framerate 2 -pixel_format uyvy422 -video_device_index 0
 -i ':none' -c:v libopenh264 -b:v 500k -allow_skip_frames 1
-filter:v crop=1010:600:200:200 -vsync vfr output.mp4

I've tried using the -video_size parameter but it seems to just ignore it.
The performance is also not great since it its grabbing the whole screen instead of just a region.
The sideways screen not working properly I can deal with, it's not that big of a problem but the screen scaling and performance are the issues I would really like to deal with but can't seem to find any good solutions.


text:
Understanding containers and codecs
To my understanding, there is the container format (MP4, MOV, 3GP, AVI) and the codecs (Theora, VP8, H264, XVid, DivX).
For what I understand, the container format and the codecs are independent and it seems that it would theoretically be possible to have a MP4 which contains some video encoded with DivX.
Would it work? I mean, would standard video players be able to play it?
Also, I don't understand why H.264 (a codec) is defined in the MPEG-4 (a container) specification.
As H.265/HVEC is to replace H.264, will there be a new container format? Or will there be some MP4 files containing some videos encoded in H.265?

MPEG-4 is not a container specification. It's a suite of specifications. Parts 12 and 14 define containers (MP4). Part 2 defines a video codec, whose encoder implementations are DivX and Xvid. Part 10 defines another video codec AVC a.k.a. H.264.
You can get a list of codecs, which can theoretically be present in a MP4 at http://mp4ra.org/codecs.html
Whether a given muxer/software offers the feature to include a codec in MP4, or whether a given player accepts a codec in a MP4, depends on the software developer. Generally, MPEG-4 Part 2 should be accepted but players can be finicky about the codec tag and may only play the video if they recognize the tag.
HEVC can be muxed in a MP4 and there's no dedicated or new container for it.

For anyone wondering, HEVC stands for H.265


text:
Print to file: Details of every NAL unit in raw H.264 file
I have a raw H.264 file. I would like to retrive both length and frame number of every NAL unit in this file. The result must be printed to file.
Is there any tool to do this?
I have tried using H.264 Stream Analysis on Windows and it works well, but I cannot find an option for printing to file.

You can use the trace_headers bitstream filter in ffmpeg
ffmpeg -i in.264 -c copy -bsf:v trace_headers -f null - 2> NALUS.txt

The text file will have data like this,
[AVBSFContext @ 00000000027d3580] Packet: 102 bytes, no pts, dts -31999, duration 40000.
[AVBSFContext @ 00000000027d3580] Slice Header
[AVBSFContext @ 00000000027d3580] 0           forbidden_zero_bit                                          0 = 0
[AVBSFContext @ 00000000027d3580] 1           nal_ref_idc                                                10 = 2
[AVBSFContext @ 00000000027d3580] 3           nal_unit_type                                           00001 = 1
[AVBSFContext @ 00000000027d3580] 8           first_mb_in_slice                                           1 = 0
[AVBSFContext @ 00000000027d3580] 9           slice_type                                              00110 = 5
[AVBSFContext @ 00000000027d3580] 14          pic_parameter_set_id                                        1 = 0
[AVBSFContext @ 00000000027d3580] 15          frame_num                                                0001 = 1
[AVBSFContext @ 00000000027d3580] 19          pic_order_cnt_lsb                                      000100 = 4
[AVBSFContext @ 00000000027d3580] 25          num_ref_idx_active_override_flag                            1 = 1
[AVBSFContext @ 00000000027d3580] 26          num_ref_idx_l0_active_minus1                                1 = 0
[AVBSFContext @ 00000000027d3580] 27          ref_pic_list_modification_flag_l0                           0 = 0
[AVBSFContext @ 00000000027d3580] 28          luma_log2_weight_denom                                      1 = 0
[AVBSFContext @ 00000000027d3580] 29          chroma_log2_weight_denom                                    1 = 0
[AVBSFContext @ 00000000027d3580] 30          luma_weight_l0_flag[i]                                      0 = 0
[AVBSFContext @ 00000000027d3580] 31          chroma_weight_l0_flag[i]                                    0 = 0
[AVBSFContext @ 00000000027d3580] 32          adaptive_ref_pic_marking_mode_flag                          0 = 0
[AVBSFContext @ 00000000027d3580] 33          cabac_init_idc                                              1 = 0
[AVBSFContext @ 00000000027d3580] 34          slice_qp_delta                                      000010011 = -9
[AVBSFContext @ 00000000027d3580] 43          disable_deblocking_filter_idc                               1 = 0
[AVBSFContext @ 00000000027d3580] 44          slice_alpha_c0_offset_div2                                  1 = 0
[AVBSFContext @ 00000000027d3580] 45          slice_beta_offset_div2                                      1 = 0
[AVBSFContext @ 00000000027d3580] 46          cabac_alignment_one_bit                                     1 = 1
[AVBSFContext @ 00000000027d3580] 47          cabac_alignment_one_bit                                     1 = 1

You'll have to parse the file to count frames.

Alternatively, H.264 Stream Analysis appears to be a frontend for h264_bitstream. Latest source available from https://sourceforge.net/projects/h264bitstream/files/h264bitstream/0.1.9/. It can be easily compiled on Windows under MinGW/MSYS2.

https://stackoverflow.com/questions/6014904/h264-frame-viewer has some good answers. For example, https://github.com/shi-yan/H264Naked worked well when I tried it.


text:
stream with ffserver without encode-decode
I have static file on my disk I want to stream it with ffserver .
The problem is that ffserver is decode and encode my file.
I know how to pass decode and encode when I save stream to file ffmpeg-i http://.... -c:v copy test.avi.
How can I do that when I stream with ffserver with command ffmpeg -i test.avi http://<ffserverUrl>
ffmpeg -i test.264 -c:v copy http://<ffserverUrl> still re-encode the video
I know that ffserver is not recommended but I need this option please

What have you tried so far? Have you tried doing a stream copy? Are you getting an error?

@MichaelLiebman ffmpeg -i test.264 -c:v copy http://  still re-encode the video

@resfds - if you have related follow-up questions, please ask them as new questions, not in comments.

FFmpeg, by default, uses ffserver's conf file to set encoding parameters.
Add -override_ffserver to the ffmpeg command to prevent that.


text:
Wrong frame-rate, corrupted playback of isom/mp4 files remuxed from H.264/AC3 MPEG-TS
NOTE: This question is superceded by this new one, please do not answer below this post.
What happened?

[Edit] DVB file ('file1') in TS format of H.264/AC3@50i cannot be properly remuxed into any of the following formats: isom/mp4; QuickTime MOV; Matroska
Another DVB file ('file2') in TS format of MPEG-2/MP2@59.94i can be properly remuxed into any of the following formats: MPEG; isom/mp4. QuickTime MOV and Matroska are not tried.
[Update] Still another one in TS format of H.264/AAC@29.97p can be properly remuxed into isom/mp4 without a hitch, not requiring any ffmpeg switches other than -i, -c copy.

Technical details

FFMpeg reports millions of the following error messages, with or without any possible combination of these switches: -fflags +genpts, -fflags +igndts, -fflags +discardcorrupt

Command line is ffmpeg.exe -fflags +igndts -fflags +genpts -fflags +discardcorrupt -i INPUT -c copy -format mp4 OUTPUT
Error Message 1:
    [mp4 @ address] pts has no value
    Last message repeated xxx times
Error Message 2:
   [mp4 @ address] Non-monotonous DTS in output stream 0:0. Previous ... Current ... Changing to ... , blah blah

AVIDemux completes operation with wrong metadata and faulty playback. File properties and playback behaviour resembles that created by FFMpeg

Frame-rate becomes variable, should be 50i
Average frame-rate is not the correct value, showing very strange numbers
Playback frame-rate is abnormal, oscillating btw. 59.94 and 39.xx

[Edit] MP4box reports the following warnings for 2 times, and produces jagged picture with wrong frame-rate as mentioned above. If you view the resultant video very carefully you will see the image with many blocks; this is not found in the original file.

Command line is  mp4box.exe -fps 50 -add "INPUT#video" OUTPUT
Error Message:
   [MPEG-2 TS] PID xx PCR discontinuity signaled but diff is small (diff xx us - PCR diff xx vs prev PCR diff 0) - ignore it

My questions, in detail
1   What on earth is "DTS" and "PTS"? They seem to be obsructing a successful remux.
2   Is this due to corrupted file or software bug (see https://trac.ffmpeg.org/ticket/4768 and https://trac.ffmpeg.org/ticket/502)?
3   If this is a software bug what are the work-arounds?
4   Any workable solution that remuxes MPEG Transport Streams to MP4 are welcome. MPEG-TS takes up too much overhead and are not well supported across platforms and systems.
Diagnostic Information
-   MediaInfo dump of file1,  file2, and  file1 remuxed into mp4 by FFMpeg
http://pastebin.ca/3966322

What does corrupted playback mean - decoding errors? Is the playback speed always wrong or it varies?

@Mulvya, playback speed is always wrong; frame image seems fine; the decoder can work but apparently the file isn't usable.

Does a TS to TS remux preserve playback rate? The store method of file1 is unusual. Try with ffmbc. If you can't compile, get an older binary from https://www.videohelp.com/software/ffmbc

@Mulvya , TS→TS remux works in FFMpeg with the following options specified: -mpegts_service_type advanced_codec_digital_hdtv -mpegts_m2ts_mode false -mpegts_flags system_b; works in FFMbc with -fflags +genpts specified. TS→mp4 succeeded in FFMbc (0.7.2) with -fflags +genpts -f mp4 specified. The ffmbc hack worked for this file and some others, the rest still failed. The issue appears to be centered around timestamping. A new question has been posted to supercede this one.

To answer part of your question (and add a couple of other abbreviations you will run into):

PTS = Presentation Time Stamp
DTS = Decode Time Stamp
PCR = Program Clock Reference
SCR = System Clock Reference

MPEG elementary streams reorder the frames for transmission. The PTS indicates the order that the frames should be re-assembled into. The DTS lets the decoder know if a frame needs to be decoded earlier than it is displayed (because a P or B frame references it). The PCR or SCR are the time scale that the PTS and DTS reference.
tstools and other transport stream analyzers can help you determine if the PCR/PTS/DTS issue is in the source file or not.

The links you've provided are just fabulous! However, I'm getting more confused after reading the PDF pp. 43-44. Although the PTS may not be monotonous as a result of bidirectional encoding, this should not cause frustrations for a proper (de)muxer because (i) the stream is transmitted and received according to the DTS which has to be (a) monotonous and (b) <= PTS-1, and (ii) every field has to have a meaningful PTS. If the million "pts has no value" and "non-monotonous DTS" in FFMpeg are real, how possible could it be to have a flawless playback of the original ts file (which I have)?

It definitely isn't likely for there to be a source problem that isn't picked up during playback and only happens during transcode. But when I want to be sure about something in a transport stream, I run it through an analyzer. Sometimes you pick up on something that is subtlety wrong that one decoder can correct that another chokes on.


text:
video or photo filter suggestion
How to edit a photo to look like this clip. link On the video  you can see a pic with a background moving left to right and at the same time the light changing(bright/dark). I am not sure if its filter or something else. Any suggestion accepted?

That was possibly achieved by taking a picture from several different angles simultaneously with multiple cameras. You can then flip through the images like a flip book.
You can simulate this by taking a single still image and separating out the foreground (the people in this case) from the background. For example, in Photoshop you could use any selection method you want - lasso, pen tool, quick mask, etc. - to select the people. Cut them out and put them on another layer. Next, turn them off and fill in the area where they used to be with something believable. This is a case where content-aware fill comes in handy. Turn the layer with the people back on. Import the photo into any motion graphics application, but be sure to import it as separate layers and not a composite. Once in the app, move the people towards the camera and/or move the background away from the camera. Once there's some separation you can orbit the 3D camera around the image a little bit. If you go too far, it will become obvious that the people are a 2D cut-out, so be careful with how far you take it.
You can also apply lights to the image in the motion graphics application. That should help you get a look similar to what you saw in the link.


text:
Adobe After Effects how can you create a distorted line moving along a video / picture? Example given in desc
Saw this on youtube and i would really appreciate if if anyone could explain to me how to do it- The youtube video is below and the distorted libne is in the intro:

Thanks,
I've tried looking around for help but cant seem to find any.

You can duplicate your footage and add a displacement map as your revealer with a black line with gradient


text:
How do I convert H.264 Rec709 ("SRGB") to H.265 HEVC 10-Bit Rec2020 ("Wide Gamut")?
I'm looking to convert a standard colour gamut video to a wide gamut video. For example, I have a 1080p, 2K or 4K H.264 8-bit mp4. This is normally (eg. from YouTube) in Rec709 or "SRGB" colour space.
I want to test my iPad Pro or other wide-gamut monitors to see what the video may look like with a wider colour gamut (eg. Rec2020) as well as save it as a H.265 10-bit mp4.

For questions you both ask and answer, please post the question and the answer separately, not both in the question

It's not so simple.  For one, iPad Pro's color space is significantly smaller than rec.2020.  If this is what you're using to "adjust to taste,"  then more capable displays (present or future) will expose discoloration.

@NoahL I thought something looked weird, will change it.

@JasonConrad Fair point.

Download the relevant build for Windows, eg: https://sourceforge.net/projects/ffmpegwindowsbi/files/july-01-2016/
Use the following command line: ffmpeg -i INPUT.mp4 -c:v libx265 -crf 20 -vf eq=gamma=1.15:saturation=0.925:brightness=0.05:contrast=1.15 -color_primaries bt2020 OUTPUT.mp4
Note that you will have to adjust the various values such as brightness, contrast, saturation, etc. to your taste since this is a "brute force" conversion to wide-gamut Rec2020. This has been tested on iPad Pro with H.264 movie trailers. On wide-gamut displays such as the iPad Pro you should notice richer, deeper colours.
Note that this is not an archival or permanent solution as Rec2020 is a very wide gamut vs Display P3 (latest Apple devices) or Adobe RGB (pro wide-gamut monitors). Newer Ultra HD TV monitors or reference monitors that can get close to Rec2020 may be more suitable.
In any case I think this is an interesting experiment and learning experience for any amateur or pro who has just started exploring wide-gamut and/or HDR video... it is a very, very different world to SRGB that had been with digital media for decades. All that is about to change radically in the next 10 years.

This is an odd thing to do. Converting footage from a smaller gamut to a larger one in the way you have is not something you should ever do for comparisons. You're changing the video from how it was intended to be viewed to something else. If you want to see the difference in gamuts, you should find footage that was shot with a wider gamut and convert to the smaller gamut and compare that way. That will get you something closer to a reasonable comparison of the 2 gamuts. The way you've done it, it's just cranking up the saturation.

I understand your point. I have evaluated things like Vimeo Vlog etc wide gamut videos on my iPad. While this method indeed ups the saturation I wanted to see if any other conversion takes place by ffmpeg itself. In general on iPad Pro Display P3 I notice an increase in saturation, but I do see colours not seen on SRGB. Interestingly from doing this process when I compare to iTunes Dolby Vision I can see similar results... Of course in the latter case it is accurately done, but as R&D I now have a glimpse into beyond-SRGB gamuts for videos. Plus they look stunning (movie trailers).

You could simply use the Colorspace Conversion LUT to convert between Rec.709 gamut and Rec.2020 gamut.

BT.709 and sRGB are completly different transfer functions. Sigh.
Anyway, download ffmpeg from here: https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip
ffmpeg -i INPUT.mp4 -c:v libx265 -crf 20 -vf zscale=r=limited:m=2020_ncl:t=2020_10:p=2020:c=topleft,format=yuv420p10 -color_primaries bt2020 -colorspace bt2020nc -color_trc bt2020_10bit -color_range tv OUTPUT.mp4
This will preserve the same colors and will preserve  SDR.


text:
Is wide-gamut video primarily an increase in saturation (for the layperson)?
Moving from SRGB to P3 and soon Rec2020 for most consumer devices... perceptually, is this just an increase in saturation?
I understand the chromaticity diagrams, and there is of course hue expansion from SRGB.
But in real-life consumer viewing, eg. Dolby Vision on iPad Pro, perceptually I notice primarily deep, rich, saturated colours.
Is this what wide-gamut for the masses will be? Or is there more I’m not getting? I know with 10-bit and HDR there is a better brightness and colour range. But to the layperson, will they mainly notice “wow colours!”?
I wanted to comment here FWIW. Recently when I'm at the theatre I look out for how cinemas use Display P3, and "regular" digital projection vs Imax 2D. It's a subtle thing, but very interesting. Black Panther is the best recent example I can think of. There are certain scenes, and particularly costumes, where they use the saturation and/or beyond-SRGB colours to "pop" colours for emotional effect. It can also draw the eye, set the atmosphere, etc. Sometimes though they go for a desaturated look, eg. the start of the movie (flashback).

Wide Gamut color space is primarily just an expanded color space that is capable of covering a larger range of values in the visible color spectrum. This, compared to sRGB and Adobe RGB.
The gamma and white / black points are roughly identical.
So yes this is primarily what Wide Gamut is designed for. Higher levels of vibrance.
The trade off is if the end user is viewing the material in an 8 bit environment, gradients can appear a bit posterized. Wide Gamut is designed to be used and viewed under 16 bit or higher colorspaces.

I'd add that there are some interactions with increased dynamic range that make WCG not just increase perception of saturation, but also alter perception of luminance.

@MichaelLiebman Yeah that's a good point, there's currently a lot of confusion between colour dynamic range and brightness dynamic range in the mainstream. Very interesting to see a paper discussing their inter-relatedness.


text:
Missing video codec
I have a Samsung TV which can play video files from an external USB source.
Generally this works fine, however recently I've come across some mp4 files which it says it can't play. I was a little confused at first as it can usually play mp4's without a problem but on further investigation it seems the problematic files have no video codec.
Can I 'install' this codec somehow in the file?

Edit: I've added the TV model and the file info from the video files. Unfortunately I don't own the actual footage so cannot post here.
TV model at the top, followed by the working file, then the non working file. The missing video codec is obvious.

When I try to play a non working file, I get this error message.

Put the exact model of TV, and if you can (and own the footage), upload an example of a file that will & won't play.

@tomh I've added the relevant details

Check whether the second video can play on a PC or Mac.
If it can, it means the video codec isn't recognised by the Samsung TV.
Transcode the second video using a free tool like Handbrake.
Make sure the audio and video codec settings match those of the first working video.

Thank Tom, I'll try this.
The TV can play other H.264/MP4 files without problem so I know it recognises the codec.


text:
ffmpeg - Drawtext Fade Out
Here is a new question on drawtext; actually, my drawtexts move from the left to right and from right to left, depending on the order ( 1,3,5... from left, 2,4,6 from right).
Each drawtext has a box; it would be nice to have each drawtext disappear with a fade out before other drawtext come in.
I see that there is the "fontcolor_exr", but I don't want to change the color of my text, I'd like to change the alpha, so I suppose I have to play with "alpha" props.
Unfortunatly, I cannot figure out how to set an expression to add the alpha trasparency after x seconds to my drawtext. Any Idea?
I'm trying to use something like this:
alpha='if(gt(t,4),--- some expresson --- ,1)'"

so that after 4 seconds, the drawtext will disappear.
Thanks
SOLVED
I found this graceful solution; let the drawtext be enabled between 0 and 6 seconds; this command will fade out the text after 5 seconds:
alpha='if(lt(t,5)\,1\,if(lt(t\,6)\,(1-(t-5))/1\,0))'
The entire drawbox disappear at second 6. Hope it helps.
See you next time!

You have to use fontcolor_expr. See 2nd last example.

I read that expression , fontcolor_expr=ff0000... but I really don't understand  what does it do, and cause I don't understand it, I cannot apply it  :( ... can you explain me quickly? tks!

and, sorry,  are you sure that ALL drawtext ( with box and border ) will disappear? I read that it is used to change the confcolor dinamically, while I need to fade the entire drawtext ( text, box, etc ... )  ..

No, the box, shadow.. won't disappear.