invalid frame size error while using WxH in ffmpeg - windows

I am trying to convert a video to images.
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
But every time it shows error in Windows CMD :
Invalid frame size: WxH.
The full Error code is posted below
C:\Users\HP\Desktop\New folder>ffmpeg -i "C:\Users\HP\Desktop\foo.mp4" -r 1 -s WxH -f image2 afoo-%03d.jpeg
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
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
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 'C:\Users\HP\Desktop\foo.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:45.05, start: 0.000000, bitrate: 1163 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 854x480 [SAR 1:1 DAR 427:240], 1032 kb/s, 25.02 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
Invalid frame size: WxH.
I tried with multiple video formats and video sizes but still not working :(
I've checked whether it is really 'x' and I typed it by hand.
This question implies about the 'x' problem and mine is different.

As Gyan mentioned, you need to specify the actual width (W) and (x) height (H).
You should also update your ancient FFMPEG version.
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
should be changed to (assuming you want 1280x720):
ffmpeg -i foo.avi -r 1 -s 1280x720 -f image2 foo-%03d.jpeg
You can also specify the size like this:
ffmpeg -i foo.avi -r 1 -filter:v "scale=1280:720" -f image2 foo-%03d.jpeg
If you want to Not force both a width And height and keep the aspect ratio you could use:
ffmpeg -i foo.avi -r 1 -filter:v "scale=1280:-2" -f image2 foo-%03d.jpeg
ffmpeg -i foo.avi -r 1 -filter:v "scale=-2:720" -f image2 foo-%03d.jpeg
The -2 will auto resize that dimension (W or H) to the correct size (Mod 2) to maintain the aspect ratio.
This page may be worth reading: FFMPEG Scaling

Related

Problem concatenating an mp4 file with an mp4 created by repeating a single image, with the same codec with ffmpeg concat demuxer

I have an mp4 video (of a lecture) containing two streams, video and audio. I wanted an introduction for it (title slide of the presentation that accompanied it), so I made an mp4 out of the intro image via ffmpeg -framerate 30 -i lec01_title.jpg -t 3 -c:v libx264 -pix_fmt yuvj420p -vf "scale=1920:1080" lec01_title.mp4 -f lavfi -i anullsrc -c:a aac. When I try to concat the files using the demuxer, it doesn't work. First, I try to verify that the properties (encoding, etc.) of the two videos are the same.
If I run ffmpeg -i lec01.mp4, I get:
ffmpeg version 5.1.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dcai_lec01.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Wide
encoder : Lavf58.20.100
Duration: 00:45:24.01, start: 0.000000, bitrate: 743 kb/s
Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 96000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 606 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
If I run ffmpeg -i lec01_title.mp4, I get:
ffmpeg version 5.1.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dcai_lec01_title.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
Duration: 00:00:03.00, start: 0.000000, bitrate: 150 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt470bg/unknown/unknown, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 12877 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
encoder : Lavc59.37.100 libx264
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
I tried to verify that the properties of the two videos match via ffprobe -select_streams a:0 -show_entries stream=codec_name,channels -of default=nw=1:nk=1 -v 0 lec01.mp4 and ffprobe -select_streams v:0 -show_entries stream=codec_name,width,height,r_frame_rate,pix_fmt -of default=nw=1:nk=1 -v 0 lec01.mp4, and they do. The first command gives me
aac
2
and the second command gives me
h264
1920
1080
yuvj420p
30/1
for both videos.
Now, if I have a file called lec01.txt containing:
file 'lec01_title.mp4'
file 'lec01.mp4'
when I run ffmpeg -f concat -i lec01.txt -c copy output.mp4, the resulting video is of length 04:44:04 (four hours, when my two input videos were 3 seconds and 45:24 minutes respectively), and it only shows the title slide for that entire duration.
Furthermore, when I run this concat command, I get the following message repeated many times: [mp4 # 0x7f82b9013b80] Non-monotonous DTS in output stream 0:1; previous: 133290, current: 133120; changing to 133291. This may result in incorrect timestamps in the output file.
I'm missing something. When I look up this error, it seems to be something related to the decoding time stamps (DTS) or presentation time stamps. Anyone know what I'm doing wrong and how to fix? Thank you for your help!
Edit:
It appears to work if I re-encode via ffmpeg -i lec01_title.mp4 -i lec01.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4, but I'd like to avoid doing this since I have tons of videos I need to do this for.

ffmpeg cannot open connection tcp://a.rtmp.youtube.com

I want to live stream using ffmpeg, when live on Facebook it runs normally, but when I live on YouTube there is an error, is there anything wrong with the command I entered? even though the command is the same as live on Facebook, but only the RTMP link has been changed
ffmpeg -re -i out.mp4 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "rtmp://a.rtmp.youtube.com/live2/my-key-streaming"
and the output is
ffmpeg version N-55112-g7eb9cf593e-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 61.100 / 56. 61.100
libavcodec 58.114.100 / 58.114.100
libavformat 58. 64.100 / 58. 64.100
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7. 91.100 / 7. 91.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2020-12-26T11:13:27.000000Z
com.android.version: 10
Duration: 00:00:03.27, start: 0.000000, bitrate: 21344 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown), 1920x1080, 20225 kb/s, SAR 1:1 DAR 16:9, 29.99 fps, 30.01 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2020-12-26T11:13:27.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-12-26T11:13:27.000000Z
handler_name : SoundHandle
[tcp # 0x58bf880] Connection to tcp://a.rtmp.youtube.com:1935 failed: Connection timed out
[rtmp # 0x5893140] Cannot open connection tcp://a.rtmp.youtube.com:1935
rtmp://a.rtmp.youtube.com/live2/my-key: Connection timed out
how to fix this, btw i use vps, sorry, my english so bad and this is the first time i asked on this website

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

Is it possible to merge 3 videos with ffmpeg by -f concat and crossfade without video content

I want to merge 3 .mov files quickly without losing any resolution. I want to be able to distinguish the 3 pieces of videos after merge.
"ffmpeg -f concat" does not lose resolution and quick without crossfade.
But, I can't distinguish 3 videos.
As far as I know ffmpeg filter can be used add crossfade, but it have to use video start/end content to do the merger, which might involve transcoding. It won't be fast compared with 'concat', which won't do transcoding, but simply copying.
Here is the content (ffmpeg -i video.mov) of one of 3 videos:
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.3)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/openjdk-12.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/openjdk-12.jdk/Contents/Home/include/darwin' --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-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-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '..../(edited)/VMEK8375.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-06-30T01:28:04.000000Z
com.apple.quicktime.model: iPhone
com.apple.quicktime.software: ZHIYUN
com.apple.quicktime.creationdate: 2019-06-30T09:28:04Z
Duration: 00:00:07.61, start: 0.000000, bitrate: 4386 kb/s
Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, smpte170m/bt709/bt709), 1280x720, 4329 kb/s, 30.01 fps, 30 tbr, 600 tbn, 600 tbc (default)
Metadata:
creation_time : 2019-06-30T01:28:04.000000Z
handler_name : Core Media Video
encoder : HEVC
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 94 kb/s (default)
Metadata:
creation_time : 2019-06-30T01:28:04.000000Z
handler_name : Core Media Audio
If I don't care about crossfade with video content, just some 'nice' black screen in between (It would be nice I add some text, like date + time on the black screen) is good enough for me. Is it possible to do 'concat' and simple crossfade without video 'content'?
Filtering requires re-encoding, so fading is not an option. Instead you can make videos that go between the main content.
Create middle videos. Ensure that you match the attributes of the main videos:
ffmpeg -y -f lavfi -i color=c=black:s=1280x720:r=30 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -vf "drawtext=text='your text':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2" -c:v libx265 -profile:v main -c:a aac -tag:v hvc1 -t 5 -video_track_timescale 600 black1.mov
Make input.txt:
file '1.mov'
file 'black1.mov'
file '2.mov'
file 'black2.mov'
file '3.mov'
Then use concat demuxer:
ffmpeg -f concat -i input.txt -c copy output.mov

Want to send a video from desktop to Wowza using ffmpeg

I am trying to stream a local .mp4 video file from my laptop to Wowza Streaming Engine using ffmpeg. Both systems are able to ping each other. I give the following command on my laptop
ffmpeg -re -i bunny_1080p_60fps_normal.mp4 -vcodec libx264 -acodec aac -ar 48000 -strict experimental -f flv "rtmp://192.168.1.22:1935/live/myStream"
192.168.1.22 is the IP address of Wowza server residing on another system running Ubuntu 17.04.
I see the following on the command prompt of my laptop when I give the above command,
ffmpeg version N-89894-g18e2ac032e Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
libavutil 56. 7.100 / 56. 7.100
libavcodec 58. 9.100 / 58. 9.100
libavformat 58. 5.101 / 58. 5.101
libavdevice 58. 0.101 / 58. 0.101
libavfilter 7. 11.101 / 7. 11.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bunny_1080p_60fps_normal.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2013-12-16T17:59:32.000000Z
title : Big Buck Bunny, Sunflower version
artist : Blender Foundation 2008, Janus Bager Kristensen 2013
comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
genre : Animation
composer : Sacha Goedegebure
Duration: 00:10:34.53, start: 0.000000, bitrate: 4486 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4001 kb/s, 60 fps, 60 tbr, 60k tbn, 120 tbc (default)
Metadata:
creation_time : 2013-12-16T17:59:32.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 160 kb/s (default)
Metadata:
creation_time : 2013-12-16T17:59:37.000000Z
handler_name : GPAC ISO Audio Handler
Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)
Metadata:
creation_time : 2013-12-16T17:59:37.000000Z
handler_name : GPAC ISO Audio Handler
Side data:
audio service type: main
[rtmp # 000001ed7c4108c0] No credentials set
[rtmp # 000001ed7c4108c0] Server error: [ AccessManager.Reject ] : [ code=403 need auth; authmod=adobe ] :
rtmp://192.168.1.22:1935/live/myStream: Unknown error occurred
Can anyone please tell me what the exact procedure is to stream a video file to Wowza .
How will I be able to view the stream at Wowza ?
Looks like RTMP authentication for encoders is enabled? In that case you need to either disable it for given live application you are connecting to or provide the credentials.
For the first scenario, remove the authentication as per https://www.wowza.com/docs/how-to-enable-username-password-authentication-for-rtmp-and-rtsp-publishing
For the second scenario, modify your FFmpeg commandline to incorporate the credentials:
ffmpeg -re -i bunny_1080p_60fps_normal.mp4 -vcodec libx264 -acodec aac -ar 48000 -strict experimental -f flv "rtmp://192.168.1.22:1935/live/myStream flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=xxx pubPasswd=yyy"
where xxx is user name and yyy is password.

Resources