I am trying to add watermark with transparent background on OSX with ffmpeg.
I am using this command:
ffmpeg -i test.mpg -vf "movie=stuff.png, scale=100:100 [watermark]; [in][watermark] overlay=main_w-overlay_w:main_h-overlay_h-10 [out]" out.mpg
And I am getting this:
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 12 2012 21:37:10 with clang 3.1 (tags/Apple/clang-318.0.54)
configuration: --prefix=/usr/local/Cellar/ffmpeg/0.11.1 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-libfreetype --cc=/usr/bin/clang --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-libvo-aacenc --disable-ffplay
libavutil 51. 54.100 / 51. 54.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.100 / 54. 6.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mpeg, from 'test.mpg':
Duration: 00:00:01.04, start: 1.000000, bitrate: 9106 kb/s
Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p, 640x480 [SAR 1:1 DAR 4:3], 104857 kb/s, 24 fps, 24 tbr, 90k tbn, 24 tbc
Stream #0:1[0x1c0]: Audio: mp2, 44100 Hz, stereo, s16, 128 kb/s
File 'out.mpg' already exists. Overwrite ? [y/N] y
w:640 h:480 pixfmt:yuv420p tb:1/90000 sar:1/1 sws_param:flags=2
[buffersink # 0x7ff50bc1c3e0] No opaque field provided
[png # 0x7ff50c038400] unsupported bit depth 16 and color type 4
[image2 # 0x7ff50c044800] decoding for stream 0 failed
[image2 # 0x7ff50c044800] Could not find codec parameters (Video: png, 640x480)
[movie # 0x7ff50bc17200] Failed to find stream info
[movie # 0x7ff50bc17200] seek_point:0 format_name:(null) file_name:stuff.png stream_index:0
[scale # 0x7ff50bc178c0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_movie_0' and the filter 'Parsed_scale_1'
Impossible to convert between the formats supported by the filter 'Parsed_movie_0' and the filter 'auto-inserted scaler 0'
Error opening filters!
I thought I am missing png support and I checked homebrew for libpng install, but it turn out png support is already included by Apple with OSX.
Also I did
ffmpeg -codecs list | grep -i png
and I do have PNG support in ffmpeg:
DEV D png PNG (Portable Network Graphics) image
Is yor file 16bit grayscale with alpha? It looks like ffmpeg doesn't support this combination. Try converting it to 8bits and/or RGBA.
Related
I'm using MakeMKVcon to automate episodes extraction. It do the job, expect the metadata. I have to rename files manually. But the problem here is that I want to extract some bonus pictures slideshow from the ISO but no software can detect it. I can only display those images using VLC (using the ISO file).
Do you have any idea how to do that ?
Here's the ffmpeg -i output:
$ ffmpeg -i /path/to/iso/file.ISO
ffmpeg version git-2020-03-24-7239254 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.16)
configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-7239254_1 --enable-shared --cc=clang --host-cflags=-fno-stack-check --host-ldflags= --enable-gpl --enable-libaom --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages --enable-libfdk-aac --enable-nonfree
libavutil 56. 42.101 / 56. 42.101
libavcodec 58. 76.100 / 58. 76.100
libavformat 58. 42.100 / 58. 42.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.100 / 7. 77.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[mpeg # 0x7f8111808200] Packet corrupt (stream = 4, dts = 2097152).
[mpeg # 0x7f8111808200] stream 4 : no TS found at start of file, duration not set
[mpeg # 0x7f8111808200] Could not find codec parameters for stream 4 (Audio: mp2, 0 channels): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpeg, from '/path/to/iso/file.ISO':
Duration: 00:24:21.47, start: 0.280000, bitrate: 40817 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, progressive), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
Side data:
cpb: bitrate max/min/avg: 8000000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:2[0x20]: Subtitle: dvd_subtitle
Stream #0:3[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:4[0x1d7]: Audio: mp2, 0 channels
At least one output file must be specified
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
i m trying to use kinect to capture video for video/image processing purposes
i found there is an script in libfreenect/build/bin folder named fakenect-record can do this for me
when i use it,it start capturing rgb and depth data in ppm and pgm format(both are images) and also it has an option (-ffmpeg) witch make an avi file of video but the problem is when I that it it fails and says this error :
Depth Mode: {256, 1, {0}, 614400, 640, 480, 11, 5, 30, 1}
Video Mode: {256, 1, {0}, 921600, 640, 480, 24, 0, 30, 1}
[Stream 70] Expected 1748 data bytes, but got 948
ffmpeg -pix_fmt rgb24 -s 640x480 -f rawvideo -i /dev/stdin -aspect 4:3 -r 20 -vcodec msmpeg4 -b 30000k sadra-depth.avi
ffmpeg -pix_fmt rgb24 -s 640x480 -f rawvideo -i /dev/stdin -aspect 4:3 -r 20 -vcodec msmpeg4 -b 30000k sadra-rgb.avi
ffmpeg version N-76045-g97be5d4ffmpeg version N-76045-g97be5d4 Copyright (c) 2000-2015 the FFmpeg developers Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
libavutil 55. 4.100 / 55. 4.100
libavutil 55. 4.100 / 55. 4.100
libavcodec 57. 6.100 / 57. 6.100
libavcodec 57. 6.100 / 57. 6.100
libavformat 57. 4.100 / 57. 4.100
libavformat 57. 4.100 / 57. 4.100
libavdevice 57. 0.100 / 57. 0.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 11.100 / 6. 11.100
libavfilter 6. 11.100 / 6. 11.100
libavresample 3. 0. 0 / 3. 0. 0
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libswscale 4. 0.100 / 4. 0.100
libpostproc 54. 0.100 / 54. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Segmentation fault (core dumped)
root#thispc-sns:~/Documents/libfreenect/build/bin/Untitled Folder# Input #0, rawvideo, from '/dev/stdin':
Duration: N/A, bitrate: 184320 kb/s
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 640x480, 184320 kb/s, 25 tbr, 25 tbn, 25 tbc
Please use -b:a or -b:v, -b is ambiguous
Input #0, rawvideo, from '/dev/stdin':
Duration: N/A, start: 0.000000, bitrate: 184320 kb/s
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 640x480, 184320 kb/s, 25 tbr, 25 tbn, 25 tbc
Please use -b:a or -b:v, -b is ambiguous
Output #0, avi, to 'sadra-depth.avi':
Output #0, avi, to 'sadra-rgb.avi':
Metadata:
ISFT : Metadata:
ISFT : Lavf57.4.100Lavf57.4.100
Stream #0:0 Stream #0:0: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 30000 kb/s: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 30000 kb/s, , 20 fps, 20 fps, 20 tbn, 20 tbn, 20 tbc20 tbc
Metadata:
Metadata:
encoder : Lavc57.6.100 msmpeg4 encoder : Lavc57.6.100 msmpeg4
Stream mapping:
Stream #0:0 -> #0:0Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> msmpeg4v3 (msmpeg4))
(rawvideo (native) -> msmpeg4v3 (msmpeg4))
***[rawvideo # 0x2a31ce0] Invalid buffer size, packet size 483328 < expected frame_size 921600
Error while decoding stream #0:0: Invalid argument
frame= 0 fps=0.0 q=0.0 Lsize= 6kB time=00:00:00.00*** bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
frame= 0 fps=0.0 q=0.0 Lsize= 6kB time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Conversion failed!
Run the following script on your machine, if you've installed opencv as well:
import freenect
import cv2
import numpy as np
from functions import *
def nothing(x):
pass
kernel = np.ones((5, 5), np.uint8)
def pretty_depth(depth):
np.clip(depth, 0, 2**10 - 1, depth)
depth >>= 2
depth = depth.astype(np.uint8)
return depth
while 1:
dst = pretty_depth(freenect.sync_get_depth()[0])#input from kinect
cv2.imshow('Video', dst)
if cv2.waitKey(1) & 0xFF == ord('b'):
break
Do you see a disparity map from your kinect ?
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.
}
I am interested in scaling a video to a larger size without applying any filter or anything. The output video should look very pixelated. How do I do this in FFMPEG?
On the suggestion of Ronald S. Bultje, I am using the neighbor flag. I have also decided to use the rawvideo codec to avoid compression.
The current command I am running is
ffmpeg -i vid.avi -s 800x800 -sws_flags neighbor -sws_dither none -vcodec rawvideo vid2.avi
The command line output of that command is
ffmpeg version 2.7 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, avi, from 'vid.avi':
Duration: 00:00:25.00, start: 0.000000, bitrate: 226 kb/s
Stream #0:0: Video: rawvideo, pal8, 80x80, 206 kb/s, 4 fps, 4 tbr, 4 tbn, 4 tbc
File 'vid2.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'vid2.avi':
Metadata:
ISFT : Lavf56.36.100
Stream #0:0: Video: rawvideo, pal8, 800x800, q=2-31, 200 kb/s, 4 fps, 4 tbn, 4 tbc
Metadata:
encoder : Lavc56.41.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame= 100 fps=0.0 q=0.0 Lsize= 62608kB time=00:00:25.00 bitrate=20515.4kbits/s
video:62600kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.012614%
ffmpeg -i infile -vf scale=WIDTH:HEIGHT:flags=neighbor outfile
or
ffmpeg -i infile -s WIDTHxHEIGHT -sws_flags neighbor outfile
The critical part here is flags or -sws_flags, which selects the filter (and other scaling-related flags). The default filter value is bicublin (IIRC), which means a bicubic luma and bilinear chroma filter. Nearest-neighbour will do what you're asking for.
See scaler options for a list other scaling algorithms.
You can rich your goal maybe with scale-down and then scale-up like:
ffmpeg -i in.mp4 -vf scale=iw/4:ih/4,scale=4*iw:4*ih:flags=neighbor out.mp4
The 4 you can modify to your needs.