I'm trying to capture video from the camera using ffmpeg (macOS 10.12) and pipe it for preview into ffplay using rawvideo and -v copy options:
ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size 1280x720 -i "0" -map 0:v -c copy -f rawvideo - | ffplay -f rawvideo -video_size 1280x720 -pixel_format 0rgb -i -
Video captures just fine, however, it constantly moves sideways (see screenshot attached). What might the issue here?
UPDATE Full ffmpeg log output:
$ ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size 1280x720 -i "0" -map 0:v -c copy -f rawvideo - | ffplay -f rawvideo -video_size 1280x720 -pixel_format 0rgb -i -
ffmpeg version 4.0.2ffplay version 4.0.2 Copyright © 2003-2018 the FFmpeg developers Copyright © 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
built with Apple LLVM version 9.0.0 (clang-900.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-ffplay --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
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-ffplay --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavcodec 58. 18.100 / 58. 18.100
libavdevice 58. 3.100 / 58. 3.100
libavformat 58. 12.100 / 58. 12.100
libavfilter 7. 16.100 / 7. 16.100
libavdevice 58. 3.100 / 58. 3.100
libavresample 4. 0. 0 / 4. 0. 0
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libavresample 4. 0. 0 / 4. 0. 0
libpostproc 55. 1.100 / 55. 1.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
2018-09-20 09:33:28.013 ffmpeg[45781:16452887] Error loading /Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: dlopen(/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
2018-09-20 09:33:28.013 ffmpeg[45781:16452887] Cannot find function pointer New_SHP_PlugIn for factory 834FC054-C1CC-11D6-BD01-00039315CD46 in CFBundle/CFPlugIn 0x7fe63b506d00 </Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin> (bundle, not loaded)
2018-09-20 09:33:28.069 ffplay[45782:16452888] Error loading /Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: dlopen(/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
2018-09-20 09:33:28.069 ffplay[45782:16452888] Cannot find function pointer New_SHP_PlugIn for factory 834FC054-C1CC-11D6-BD01-00039315CD46 in CFBundle/CFPlugIn 0x7f93f3c13020 </Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin> (bundle, not loaded)
[avfoundation # 0x7fe63c000000] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, avfoundation, from '0':
Duration: N/A, start: 1054.178167, bitrate: N/A
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1280x720, 1000k tbr, 1000k tbn, 1000k tbc
Output #0, rawvideo, to 'pipe:': 0KB vq= 0KB sq= 0B f=0/0
Metadata:
encoder : Lavf58.12.100
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1280x720, q=2-31, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 ©
Press [q] to stop, [?] for help
Input #0, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 737280 kb/s
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1280x720, 737280 kb/s, 25 tbr, 25 tbn, 25 tbc
frame= 16 fps=0.0 q=-1.0 size= 57600kB time=00:00:00.60 bitrate=786437.5kbits/s speed=1.frame= 29 fps= 28 q=-1.0 size= 104401kB time=00:00:01.12 bitrate=763617.4kbits/s speed=1.frame= 42 fps= 27 q=-1.0 size= 151201kB time=00:00:01.64 bitrate=755268.5kbits/s speed=1.frame= 55 fps= 26 q=-1.0 size= 198002kB time=00:00:02.16 bitrate=750939.5kbits/s speed=1.frame= 68 fps= 26 q=-1.0 size= 244802kB time=00:00:02.68 bitrate=748290.4kbits/s speed=1.av_interleaved_write_frame(): Broken pipe= 0KB sq= 0B f=0/0
Error writing trailer of pipe:: Broken pipe
frame= 69 fps= 26 q=-1.0 Lsize= 247650kB time=00:00:02.72 bitrate=745863.6kbits/s speed=1.01x
video:248402kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.
Looks like an issue with alignment/padding. Since ffplay doesn't seem to have options for that, try different bigger video widths for ffplay instead of 1280 like 1282 or more.
It does looks like the avfoundation device is padding the extra 32 bytes onto each packe, and thus leading to the progressive change in stride, which shows up as a gradual shift in horizontal alignment.
Transcoding the stream forces a decode, which gets rids of the padding.
The warning of Frame rate very high for a muxer not efficiently supporting it is not connected to this issue. The avfoundation device is registering a framerate of 1 million (!) which is an issue for constant frame rate muxers, since ffmpeg will seek to duplicate frames to meet that rate in the output. -vsync vfr sidesteps that problem.
Related
I have a MJPEG stream and I'm trying to use ffmpeg to take it as an input and stream it to an rtmp server at a defined framerate.
I have already tried this as a command:
ffmpeg -f mjpeg -r 60 -i http://localhost:3030/ -f flv -vcodec flv rtmp://localhost/live/test
While ffmpeg looks like it is sending something...
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, mjpeg, from 'http://localhost:3030/':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 60 tbr, 1200k tbn, 60 tbc
[tcp # 0x7f95f9401ec0] Connection to tcp://localhost:1935 failed (Connection refused), trying next address
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> flv1 (flv))
Press [q] to stop, [?] for help
[swscaler # 0x7f95fa033e00] deprecated pixel format used, make sure you did set range correctly
Output #0, flv, to 'rtmp://localhost/live/test':
Metadata:
encoder : Lavf58.12.100
Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 60 fps, 1k tbn, 60 tbc
Metadata:
encoder : Lavc58.18.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 20 fps=3.2 q=31.0 size= 194kB time=00:00:00.31 bitrate=4999.6kbits/s speed=0.0512x
I cannot preview the stream through VLC. Weirdly enough, if I let VLC try to load the url (rtmp://localhost/live/test) and then close ffmpeg, VLC will actually show the video stream for a few frames and then stop again.
Help on how to achieve this would be much appreciated.
I'm trying to capture a screenshot from a udp stream using ffmpeg in a Ubuntu 14.04 System.
Following is the command
ffmpeg -y -i udp_ip -vframes 1 -q:v 1 test.png
But the image captured is of very poor resolution and I observed a lag while taking the screenshot.
Please suggest a best tool or a way to take a screenshot in the fastest way and also of the best image resolution possible.
edit:
log files
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --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-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
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
[mpeg2video # 0x390cc60] Invalid frame dimensions 0x0.
Last message repeated 7 times
Input #0, mpegts, from 'udp://#xxx.xx.xx.xx:xxxx':
Duration: N/A, start: 144.130744, bitrate: 4128 kb/s
Program 1
Metadata:
service_name : Program-1
service_provider: Encoder
Stream #0:0[0x42]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 16:15 DAR 4:3], 4000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x43]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'player.png':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: png, rgb24, 720x576 [SAR 16:15 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.89.100 png
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=1 drop=1 speed=0.729x
video:777kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Since, this seems to be an issue of aspect ratio, and not quality, per se, use
ffmpeg -y -i udp_ip -vf scale=iw*sar:ih,setsar=1 -vframes 1 -q:v 1 test.png
The scale filter rescales the video to square pixels. The SAR filter isn't strictly necessary but in case the PNG muxer writes that data, better to reset it.
I have two video streams from which I'd like to take one frame of each, both of them are RTSP. I'm using the same FFMPEG instruction for both of them but changing the URL of the stream, the first one works but the second one throws the error:
method SETUP failed: 455 Method Not Valid In This State
Can anyone tell me what could be the reason for this error and how to solve it?
WORKING
ffmpeg -ss 1 -i rtsp://streamreader:trudat55#69.84.126.216:88/videoMain -an -vcodec mjpeg -vframes 1 -aspect 16:9 -q:v 2 -y test.jpg
ffmpeg version 2.8.2 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --enable-gpl --enable-avresample --enable-libopencore-amrnb --enable-libx264 --enable-libxvid --enable-postproc --enable-version3 --enable-shared --enable-pic --extra-ldexeflags=-pie
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[rtsp # 0x55a60a0a7420] UDP timeout, retrying with TCP
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://streamreader:password#69.84.126.216:88/videoMain':
Metadata:
title : IP Camera Video
comment : videoMain
Duration: N/A, start: 0.200044, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480, 50 tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
[swscaler # 0x55a60a102460] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'test.jpg':
Metadata:
title : IP Camera Video
comment : videoMain
encoder : Lavf56.40.101
Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x480 [SAR 4:3 DAR 16:9], q=2-31, 200 kb/s, 50 fps, 50 tbn, 50 tbc
Metadata:
encoder : Lavc56.60.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.5 q=2.0 Lsize=N/A time=00:00:00.02 bitrate=N/A dup=1 drop=1
video:66kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
NOT WORKING
ffmpeg -ss 1 -i rtsp://camaras.corredorautomotriz.cl:554/live.sdp -an -vcodec mjpeg -vframes 1 -aspect 16:9 -q:v 2 -y test.jpg
ffmpeg version 2.8.2 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --enable-gpl --enable-avresample --enable-libopencore-amrnb --enable-libx264 --enable-libxvid --enable-postproc --enable-version3 --enable-shared --enable-pic --extra-ldexeflags=-pie
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[rtsp # 0x55b98f2de420] UDP timeout, retrying with TCP
[rtsp # 0x55b98f2de420] method SETUP failed: 455 Method Not Valid In This State
[rtsp # 0x55b98f2de420] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://camaras.corredorautomotriz.cl:554/live.sdp':
Metadata:
title : RTSP server
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 90k tbr, 90k tbn, 90k tbc
Stream #0:1: Data: none
Output #0, image2, to 'test.jpg':
Output file #0 does not contain any stream
I found that if I specify that the protocol is TCP with the instruction -rtsp_transport tcp then i don't get an error:
ffmpeg -ss 5 -rtsp_transport tcp -i rtsp://camaras.corredorautomotriz.cl:554/live.sdp -s 640x480 -aspect 16:9 -b:v 800k -r 24 video.flv
But I would still like to know the reason and solution of the problem I got before, because I am not sure I can use this parameter. Anyone knows?
Thanks
As I see in your output, ffmpeg failed to determine input stream type in the second case (rtsp://camaras.corredorautomotriz.cl:554/live.sdp).
I checked it, and it got me mpeg4:
Input #0, rtsp, from 'rtsp://camaras.corredorautomotriz.cl:554/live.sdp':
Metadata:
title : RTSP server
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 720x480 [SAR 1:1 DAR 3:2], 30 tbr, 30k tbn
Thus possibly you compiled ffmpeg without mpeg4 decoder (or with broken decoder).
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 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.