Detect rotation angle and rotate final video using ffmpeg version 2.8 - ffmpeg

I used to work on ffmpeg 2.2 until now and was detecting rotation angle of video uploaded from android / iPhone mobiles and rotate the resulting video so that it run perfectly on a correct angle.
But since I have updated the ffmpeg to version 2.8 I am getting this rotation problem. My queries are not rotating the videos as they were earlier.
Here'r the commands I was using:
To check rotation angle:
ffprobe -of json -show_streams {$input} | grep rotate
below is my final command to convert a video to mp4
"ffmpeg -i {$input} -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ".fix_video_orientation($input)."' -threads 0 -ab 64k -s {$resolution} -movflags faststart -metadata:s:v:0 rotate=0 {$output}";
"fix_video_orientation" function is given below. It detect the angle of rotation of the initial video and output optimal option for rotating the final video.
function fix_video_orientation($input){
$return= ", transpose=1 ";
$dd= exec("ffprobe -of json -show_streams {$input} | grep rotate");
if(!empty($dd)){
$dd=explode(":",$dd);
$rotate=str_replace(",","",str_replace('"',"",$dd[1]));
if($rotate=="90")return $return;
else if ($rotate=="180") return ", transpose=2,transpose=2 ";
else if($rotate == "270") return ", transpose=2 ";
}
Currently above script is supporting "flv","avi","mp4","mkv","mpg","wmv","asf","webm","mov","3gp","3gpp" extensions, also the script is supporting the resulting .mp4 file to play on all browsers and devices.
Now the ffprobe command is not returning rotation angle and so a portrait video if uploaded from iphone is showing as landscape on the website.
Output console of ffprobe command:
ffprobe version N-77455-g4707497 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
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-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. 11.100 / 55. 11.100
libavcodec 57. 20.100 / 57. 20.100
libavformat 57. 20.100 / 57. 20.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 21.101 / 6. 21.101
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 '/standard/PORTRAIT.m4v':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2016-02-03 05:25:18
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 4S
com.apple.quicktime.software: 9.2.1
com.apple.quicktime.creationdate: 2016-02-03T10:52:11+0530
Duration: 00:00:03.34, start: 0.000000, bitrate: 7910 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 7832 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 50 tbc (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3
If latest version of ffmpeg (2.8) is used to auto rotate the video, can you please suggest me what option I need to add or remove from my final command.

Try asking this in superuser.com.
ffmpeg -i in.mp4 -c copy -metadata:s:v:0 rotate=0 -an out.mp4
Source:
https://superuser.com/questions/1092951/how-to-delete-a-single-metadata-item-from-an-mp4-file

Related

Concatenating two.mov files results in identical sized file

I try to concatenate two video files a.mov & b.mov on Win 10 using ffmpeg with the following command:
ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy c.mov
There are no errors displayed however when I open the resulting file c it has the same length as file a with the last frame appering to be a frame of b.
File a is a longer video, file b are credits (couple of seconds) made with ffmpeg from an image file.
Both files have the same aspect ratio, size and framerate.
I try to concatenate two video files a.mov & b.mov on Win 10 using ffmpeg with the following command:
ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy c.mov
There are no errors displayed however when I open the resulting file c it has the same length as file a with the last frame appering to be a frame of b.
File a is a longer video, file b are credits (couple of seconds) made with ffmpeg from an image file.
Both files have the same aspect ratio, size and framerate.
Here the log:
ffmpeg -n -i a.mov -i b.mov
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9.3.1 (GCC) 20200523 configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 /
58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 /
3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mov': Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.62.100 Duration: 00:31:50.04, start: 0.000000, bitrate: 5309 kb/s
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 4151 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : Core Media Video
encoder : Lavc58.54.100 libx264
Stream #0:1: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
Metadata:
handler_name : SoundHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'b.mov': Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.29.100 Duration: 00:00:10.01, start: 0.000000, bitrate: 67 kb/s
Stream #1:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 64 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.54.100 libx264
Thank you.
Problems
Your inputs have some different attributes, but they need to be the same to concatenate:
The timescales (30k vs 11988) are different. This is probably due to a.mov having 30000/1001 proper NTSC frame rate and b.mov is 29.97. ffprobe can confirm this. The ffmpeg output is for "entertainment purposes only" and reports an abbreviated frame rate.
a.mov has audio, but b.mov does not.
To fix it
Re-mux b.mov and add silent audio:
ffmpeg -i b.mov -f lavfi -i anullsrc=r=48000:cl=mono -c:v copy -c:a pcm_s24le -video_track_timescale 30k -shortest b2.mov
Then update list.txt with the new file (b2.mov).
Concatenate:
ffmpeg -safe 0 -f concat -i list.txt -c copy c.mov
Options
-f lavfi -i anullsrc=r=48000:cl=mono makes silent audio with 48000 sample rate and mono channel layout. This matches the sample rate and channel layout of a.mov. You can't concatenate an input with audio with an input that has no audio, so this just creates silent filler/dummy audio.
-c:v copy stream copy the video.
-c:a pcm_s24le chooses the encoder pcm_s24le to create an audio format that matches a.mov.
-video_track_timescale 30k sets video timescale to match a.mov. See What is video timescale, timebase, or timestamp in ffmpeg?
-shortest ends the output whenever the shortest input ends. Needed because I did not set a duration for anullsrc (using -shortest is easier).

Convert videos from .264 to .265 (HEVC) with ffmpeg

I see that there are a few questions on this subject but I am still getting errors. All I want to do is convert videos in my library to HEVC so they take up less space.
I've tried this:
ffmpeg -i input.mp4 -c:v libx265 output.mp4
ffmpeg seems to take a long time and the output seems to be about the right size. The video will play with VLC but the icon is weird and when I try to open it with QuickTime, I get the error: 'The document “output.mov” could not be opened. The file isn’t compatible with QuickTime Player.'
I don't want to change any of the fancy settings. I just want the files to take up less space and with minimal or no quality loss.
Thanks!
EDIT:
Having trouble keeping the time stamp that I put into the videos.
Originally I was using exiftool in terminal. But, sometimes that doesn’t work with videos, so I would airdrop them to my iPhone, use an app called Metapho to change the dates, and then airdrop them back. Exiftool was create but sometimes I just wouldn’t work. It would change the date to something like 1109212 Aug 2nd. Weird. Bottom line is that when I do these conversions, I really don’t want lose the time stamps in them.
ORIGINAL FILE THAT I TIMESTAMPED, IN .264
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.8)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_original.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-10-22T18:48:43.000000Z
encoder : HandBrake 0.10.2 2015060900
com.apple.quicktime.creationdate: 1994-12-25T18:00:00Z
Duration: 00:01:21.27, start: 0.000000, bitrate: 800 kb/s
Chapter #0:0: start 0.000000, end 81.265000
Metadata:
title : Chapter 12
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 710x482 [SAR 58409:65535 DAR 1043348:794715], 634 kb/s, SAR 9172:10291 DAR 404229:307900, 29.95 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2019-10-22T18:48:43.000000Z
handler_name : Core Media Video
encoder : 'avc1'
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
creation_time : 2019-10-22T18:48:43.000000Z
handler_name : Core Media Audio
Stream #0:2(und): Data: bin_data (text / 0x74786574), 0 kb/s
Metadata:
creation_time : 2019-10-22T18:48:43.000000Z
handler_name : Core Media Text
At least one output file must be specified
FILE CONVERTED TO HEVC, WITHOUT -COPYTS TAG
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.8)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_original_HEVC.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.29.100
Duration: 00:01:21.30, start: 0.000000, bitrate: 494 kb/s
Chapter #0:0: start 0.000000, end 81.265000
Metadata:
title : Chapter 12
Stream #0:0: Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, progressive), 710x482 [SAR 9172:10291 DAR 404229:307900], 356 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
Metadata:
handler_name : Core Media Video
encoder : Lavc58.54.100 libx265
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : Core Media Audio
Stream #0:2(eng): Data: bin_data (text / 0x74786574), 0 kb/s
Metadata:
handler_name : SubtitleHandler
At least one output file must be specified
FILE CONVERTED TO HEVC, WITH -COPYTS TAG
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.8)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_original_HEVC_keepts.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.29.100
Duration: 00:01:21.30, start: 0.000000, bitrate: 494 kb/s
Chapter #0:0: start 0.000000, end 81.265000
Metadata:
title : Chapter 12
Stream #0:0: Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, progressive), 710x482 [SAR 9172:10291 DAR 404229:307900], 356 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
Metadata:
handler_name : Core Media Video
encoder : Lavc58.54.100 libx265
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : Core Media Audio
Stream #0:2(eng): Data: bin_data (text / 0x74786574), 0 kb/s
Metadata:
handler_name : SubtitleHandler
At least one output file must be specified
This answer was posted (under the CC BY-SA 4.0 license) as a comment by Gyan to the question Convert videos from .264 to .265 (HEVC) with ffmpeg.
Run this command for x265 convertation:
ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 output.mp4
Convert 4k to 1080 (no change in codec)
ffmpeg -i input4kvid.mp4 -vf scale=1920:1080 -c:a copy output1080vid.mp4
Convert h.264 to h.265 (no change in resolution)
ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -c:a copy output.mp4
Convert 4k(h.264) to 1080(h.265)
Downscaling + Change in compression codec
ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -vf scale=1920:1080 -crf 20 -c:a copy output.mp4
Options Explained
-i input file name or file path
-c:v libx265 -vtag hvc1 selecting compression. Default is libx264
-vf scale=1920:1080 specifying output resolution
-c:a copy copy audio as it is without any compression
-preset slow ask compression algorithm to take more time & look for more areas for compression. Default is medium. Other options are faster, fast, medium, slow, slower
-crf 20 Compression quality
-crf 0 high-quality, low compression, large file
-crf 23 default
-crf 51 low-quality, high compression, small file
-vtag hvc1 use codec hvc1 (a.k.a. HEVC or h.265) during conversion.
If -vtag isn't specified (like in the first snippet), it will then use the codec used in the src file.
If you have NVIDIA GPU, you can use hevc_nvenc for the encoder parameter which should be faster than a CPU encoder.
ffmpeg -i input.mp4 -c:v hevc_nvenc -rc vbr_hq -cq 18 -b:v 0k -2pass 0 output.mp4
However, note that hardware encoded files aren't as optimized as CPU encoded
for mobile phone users it's better to use the scale of 1080*1920.
ffmpeg -i input4kvid.mp4 -vf scale=1080:1920 -c:a copy output1080vid.mp4

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

Extract image from video (ffmpeg)

I am trying to extract images from video using ffmpeg:
ffmpeg -i sample.mp4 -vf fps=1/30 img%03d.jpg
But I am getting this following error
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/sites/filemanager.dev/public_html/wout/image/sample.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp42mp41
creation_time : 2009-05-25 21:58:02
Duration: 00:04:03.12, start: 0.000000, bitrate: 309 kb/s
Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 26 kb/s (default)
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : Apple Sound Media Handler
Stream #0:1(eng): Video: mpeg4 (Advanced Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x320 [SAR 1:1 DAR 3:2], 120 kb/s, 30.12 fps, 30.12 tbr, 2500 tbn, 1k tbc (default)
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : Apple Video Media Handler
Stream #0:2(eng): Data: none (rtp / 0x20707472), 128 kb/s
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : hint media handler
Stream #0:3(eng): Data: none (rtp / 0x20707472), 29 kb/s
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : hint media handler
[NULL # 0x1d25ea0] Unable to find a suitable output format for 'image2'
image2: Invalid argument
The final out required is I need to extract image at fps 30.
For extracting images from a video:
ffmpeg -i sample.mp4 -r 30 -s WxH -f image2 image%03d.jpg
The -r flag defines extracted image frames per second. It will output them in files named image001.jpeg, image002.jpeg, etc. The optional -s flag will rescale images to fit the new WxH values.
If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes or -t option, or in combination with -ss to start extracting from a certain point in time.
For more informations, check documentation.

Changing portrait videos to landscape aspect with latest ffmpeg release is breaking

I am having an issue scaling videos recorded in portrait with the latest version of ffmpeg (2.1). This worked fine in a previous version, but I need the lastest version to fix a different issue.
I am trying to take any video passed and make it 852 wide by 480 high. It works fine when converting videos that are wider then tall, but when the video is taller then wide it corrupts the video. It actually adds a letter box to the top and bottom, rather then left and right. Also, the meta data shows it as the correct height & width, but its wrong when played in windows.
Here are the parameters I am using.
ffmpeg -i INPUT -s 852x480 -r 30 -aspect 1.775 -b:v 2000000 -vcodec mpeg4 -vf "scale=iw*min(852/iw\,480 /ih):ih*min(852/iw\,480 /ih),pad=852:480 :(852-iw)/2:(480 -ih)/2" -ac 2 -b:a 128k -ar 44100 -y OUTPUT
Console output from ffmpeg -i INPUT -r 30 -b:v 2000000 -vcodec mpeg4 -vf "scale=852:480" -ac 2 -b:a 128k -ar 44100 -y OUTPUT:
C:\Lib>ffmpeg -i "d\ca96cd13-2995-4794-b753-22be3b918659.mov" -r 30 -b:v 2000000 -vcodec mpeg4 -vf "
scale=852:480" -ac 2 -b:a 128k -ar 44100 -y "d\portx.mp4"
ffmpeg version N-58015-g8cdf4e0 Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 10 2013 18:04:45 with gcc 4.8.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32thread
s --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-icon
v --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr -
-enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enab
le-libxavs --enable-libxvid --enable-zlib
libavutil 52. 52.100 / 52. 52.100
libavcodec 55. 41.100 / 55. 41.100
libavformat 55. 21.100 / 55. 21.100
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.102 / 3. 90.102
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd\ca96cd13-2995-4794-b753-22be3b918659.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2013-11-12 15:02:21
model : iPhone 5
model-eng : iPhone 5
encoder : 7.0.2
encoder-eng : 7.0.2
date : 2013-11-12T10:02:21-0500
date-eng : 2013-11-12T10:02:21-0500
make : Apple
make-eng : Apple
Duration: 00:00:15.48, start: 0.000000, bitrate: 780 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 7
05 kb/s, 29.98 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 90
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 62 kb/s (default)
Metadata:
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Output #0, mp4, to 'd\portx.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
make-eng : Apple
model : iPhone 5
model-eng : iPhone 5
make : Apple
encoder-eng : 7.0.2
date : 2013-11-12T10:02:21-0500
date-eng : 2013-11-12T10:02:21-0500
encoder : Lavf55.21.100
Stream #0:0(und): Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 852x480, q=2-31, 2000 kb/s, 15360
tbn, 30 tbc (default)
Metadata:
rotate : 90
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128
kb/s (default)
Metadata:
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mpeg4)
Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
Press [q] to stop, [?] for help
frame= 465 fps=417 q=3.8 Lsize= 4118kB time=00:00:15.52 bitrate=2173.3kbits/s
video:3860kB audio:243kB subtitle:0 global headers:0kB muxing overhead 0.348231%
Try this:
ffmpeg -i input -filter:v "scale='w=min(720,trunc((480*33/40*dar)/2+0.5)*2):h=min(480,trunc((704*40/33/dar)/2+0.5)*2)',pad='w=720:h=480:x=(ow-iw)/2:y=(oh-ih)/2',setsar='r=40/33'" -target ntsc-dvd output

Resources