FFMPEG options differences between two videos - ffmpeg

So I'm working with a video build out of pngs. Making a video hasn't been too hard thanks to ffmpeg however most of the videos I've made work great playing forward and are extremely choppy playing backwards.
Using a program named MPEG Streamclip plus Handbrake I managed to convert my video to one that plays great forward and backward. But now I can't figure out how to pass in the right options to ffmpeg to replicate this video.
Using ffprobe I have some outputs of the good and bad video. What options am I missing?
Bad Video:
$ ffprobe tea_ffmpeg.mov
ffprobe version 3.0 Copyright (c) 2007-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tea_ffmpeg.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf57.25.100
Duration: 00:00:08.04, start: 0.000000, bitrate: 1140 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 676x450 [SAR 675:676 DAR 3:2], 1138 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : DataHandler
encoder : Lavc57.24.102 libx264
Good Video:
$ ffprobe test.mov
ffprobe version 3.0 Copyright (c) 2007-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2016-03-09 15:16:37
Duration: 00:00:08.04, start: 0.000000, bitrate: 2650 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 674x450, 2646 kb/s, 25 fps, 25 tbr, 25k tbn, 50k tbc (default)
Metadata:
creation_time : 2016-03-09 15:16:47
handler_name : Apple Alias Data Handler
encoder : H.264
FFMPEG Command so far:
ffmpeg -y -i 'pngs/tea-%03d.png' -vf scale=674:-2 -vcodec libx264 -pix_fmt yuv420p -r 25 tea_ffmpeg.mov
I understand mov vs mp4 should just be a container spec, but mov was the first I got working. I'm more than happy to use mp4.

The main thing that stands out is the profile. So,
ffmpeg -y -i 'pngs/tea-%03d.png' -vf scale=674:-2 -vcodec libx264 -profile:v main -pix_fmt yuv420p -r 25 tea_ffmpeg.mov
To be safer, you can use baseline profile and small GOP sizes (at some cost to file size)
ffmpeg -y -i 'pngs/tea-%03d.png' -vf scale=674:-2 -vcodec libx264 -profile:v baseline -g 12 -pix_fmt yuv420p -r 25 tea_ffmpeg.mov

Related

FFMPEG Concat filter - Output video skips second file

I am using the ffmpeg concat filter to join video files. I am aware the files must be exactly the same format for concat to work without encoding. However, the output of these two files are not seemless. The video will stop when it switches to second video file.
Here is the output of the two video files.
SKYbum:~ Aspvik$ ffmpeg -i /Users/Aspvik/Desktop/newIntro.mp4 -i /Users/Aspvik/Downloads/wetransfer-008789/Middle.mp4
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/Aspvik/Desktop/newIntro.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:00:08.87, start: 0.000000, bitrate: 7160 kb/s
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 7159 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/Aspvik/Downloads/wetransfer-008789/Middle.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Netcam Studio 1.6.1.0
encoder : Lavf57.71.100
Duration: 00:00:19.47, start: 0.033008, bitrate: 676 kb/s
Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 674 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
The command I'm using for the concat is:
ffmpeg -f concat -safe 0 -i /Users/Aspvik/Desktop/files.txt -codec copy -y /Users/Aspvik/Desktop/video.mp4
Can anyone see what could be wrong?

Getting error while converting on FFMPEG? what's the meaning & how it should be fixed?

I am using this code to apply watermark on linux server;
-i input.mp4 logo.png -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' output.mp4
so ended-up with this error;
Please use -b:a or -b:v, -b is ambiguous
Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_overlay_0
Full error;
ffmpeg version N-71954-gbc6f84f Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
configuration: --prefix=/usr --enable-version3 --enable-gpl --enable-shared --
enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libvpx --
enable-libx264 --enable-libxvid --enable-libopencore-amrwb --enable-libopencore-
amrnb --enable-postproc --enable-nonfree --enable-pthreads --enable-x11grab --
enable-libfaac --enable-libopenjpeg --enable-zlib --disable-doc
libavutil 54. 23.101 / 54. 23.101
libavcodec 56. 37.101 / 56. 37.101
libavformat 56. 31.102 / 56. 31.102
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'uploaded/1502539665_21.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.31.102
enter code here
Duration: 00:02:27.32, start: 0.023220, bitrate: 635 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x320
[SAR 1:1 DAR 3:2], 476 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
enter code here
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 151 kb/s (default)
Metadata:
handler_name : SoundHandler
enter code here
Please use -b:a or -b:v, -b is ambiguous
Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_overlay_0
Your image isn't presented as an input so ffmpeg treats it as the first output, and output.mp4 as the 2nd output. The filter_complex only sees the video as an input.
Start your command like this
ffmpeg -i input.mp4 -i logo.png

Slideshow video created by ffmpeg with scale+pad+vstack filters only contains one image

$ ls -1 *.jpg
1.jpg # could be any size, here is 210×315
2.jpg # could be any size, here is 480x480
3.jpg # could be any size, here is 480x480
$ ls -1 *.png
bg.png # 480x160
$ ffmpeg -y -r 0.5 -pattern_type glob -i '*.jpg' -i bg.png -filter_complex 'scale=iw*min(480/iw\,480/ih):ih*min(480/iw\,480/ih),pad=480:480:(480-iw*min(480/iw\,480/ih))/2:(480-ih*min(480/iw\,480/ih))/2,vstack' -vsync vfr -c:v libx264 -pix_fmt yuv420p out.mp4
...
$ ffprobe out.mp4
ffprobe version 3.3.2 Copyright (c) 2007-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Duration: 00:00:02.00, start: 0.000000, bitrate: 152 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x640 [SAR 1:1 DAR 3:4], 149 kb/s, 0.50 fps, 0.50 tbr, 16384 tbn, 1 tbc (default)
Metadata:
handler_name : VideoHandler
The video size 480x640 is correct, but it only lasts 2 seconds, only contains the first image 1.jpg, please tell me how I can solve this problem?
-------

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.
I need to use rtsp_transport tcp. The following command works.
ffmpeg -rtsp_transport tcp -i rtsp://bb:cc#192.168.1.xx:yy/tcp/av0_0 -f image2 -vf fps=fps=1 hello/img%03d.png

FFMPEG parameter 'pixel_aspect' out of range

I am trying to extract thumbnail from video using ffmpeg but I am getting following error. Video taken from Ipad and and flipped horizontally.
/var/www/html/ffmpeg -i "/var/www/html/media/4/event-4-video-setting-17.mp4" -r 1 -ss 00:00:03 -vframes 1 "/var/www/html/media/4/new_file.jpg"
ffmpeg version N-63893-gc69defd Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 16 2014 05:38:01 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 89.100 / 52. 89.100
libavcodec 55. 66.101 / 55. 66.101
libavformat 55. 43.100 / 55. 43.100
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 8.100 / 4. 8.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/media/4/event-4-video-setting-17.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2015-09-08 07:03:47
Duration: 00:00:05.45, start: 0.000000, bitrate: 5048 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x640, 5042 kb/s, SAR -1:1 DAR -3:4, 28.42 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 180
creation_time : 2015-09-08 07:03:47
handler_name : Core Media Data Handler
encoder : H.264
[buffer # 0x3183060] Value -1.000000 for parameter 'pixel_aspect' out of range [0 - 1.79769e+308]
Last message repeated 3 times
[buffer # 0x3183060] Error setting option pixel_aspect to value -1/1.
[graph 0 input from stream 0:0 # 0x318b620] Error applying options to the filter.
Error opening filters!
You somehow have negative values for the Sample Aspect Ratio (SAR) and Display Aspect Ratio (DAR):
SAR -1:1 DAR -3:4
Try to use a filter to set them correctly:
-filter:v "setsar=1/1,setdar=3/4"
Here, I have created a function that accepts 2 parameters video path & thumbnail path respectively.
function videoThumbnail($video,$thumbImage){
$ffmpeg = FFMPEGPATH; // Path to the ffmpeg library linux file
exec("$ffmpeg -y -i '$video' -r 1 -ss 00:00:00 -vframes 1 '$thumbImage'".' 2>&1', $result);
// Here $result is used for debugging purpose.
}

Resources