the command I use to encode:
ffmpeg -y -i VideoCapture.mp4 -c:v libx264 -b:v 444k -pass 1 -an -f null /dev/null && \
ffmpeg -i VideoCapture.mp4 -c:v libx264 -b:v 444k -pass 2 -c:a aac -b:a 128k output.mp4
I took this code from the official ffmpeg documentation, by changing the audio and video bitrate values according to the examples in the documentation. This code error when I run it on Linux.
The above code can run on windows (by changing the characters "NULL" and "").
This is the full output of the error:
ffmpeg version N-59498-g45dc668aea-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2021 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 57. 7.100 / 57. 7.100
libavcodec 59. 12.100 / 59. 12.100
libavformat 59. 8.100 / 59. 8.100
libavdevice 59. 0.101 / 59. 0.101
libavfilter 8. 16.101 / 8. 16.101
libswscale 6. 1.100 / 6. 1.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VideoCapture.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2021-07-02T07:26:53.000000Z
Duration: 00:23:50.31, start: 0.000000, bitrate: 803 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 736 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
Metadata:
creation_time : 2021-07-02T07:26:53.000000Z
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 63 kb/s (default)
Metadata:
creation_time : 2021-07-02T07:09:01.000000Z
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x75dea80] using SAR=1/1
[libx264 # 0x75dea80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Why this happened? is there any solution for this problem?
thank you.
I am trying to relay an stream from one rtsp url to another without recoding using this command:
ffmpeg
-rtsp_transport tcp
-fflags nobuffer
-re
-i rtsp://xxx.xxx.xxx.xxx:554/[stream_name]
-vcodec copy
-an
-f rtsp rtsp://yyy.yyy.yyy.yyy/[new_stream_name]
But FFMPEG doesn't stream anything and stats shows bitrate=N/A
This is the exact output that i get:
ffmpeg version 4.1.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libxml2 --enable-libxvid --enable-libzimg
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
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, rtsp, from
'rtsp://xxx.xxx.xxx.xxx:554/[stream_name]':
Metadata:
title : RTSP Session
Duration: N/A, start: 0.318111, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 944x1080, 22 fps, 22 tbr, 90k tbn, 180k tbc
Output #0, rtsp, to
'rtsp://yyy.yyy.yyy.yyy/[new_stream_name]':
Metadata:
title : RTSP Session
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (High), yuv420p(progressive), 944x1080, q=2-31, 22 fps, 22 tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 113 fps= 32 q=-1.0 Lsize=N/A time=00:00:06.77 bitrate=N/A speed=1.92x
Although when i change output stream container to 'flv' and protocol to 'rtmp' it works.
Any help will be appreciated.
To have stream accessible you need to publish it to a streaming server that supports RTSP input (like Wowza SE) and that usually also involves publishing credentials like:
rtsp://user:password#yyy.yyy.yyy.yyy/[new_stream_name]
You can test re-streaming with this tool https://videonow.live/broadcast-ip-camera-or-stream/ that can also publish it in a HTML5 accessible format like HLS.
I am able to generate m3u8 and list of segment(.ts) files from mp4 video file using following ffmpeg command
ffmpeg -i Bee_Free.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list free.m3u8 -segment_time 10 free%03d.ts
I am using the same command to generate m3u8 and ts files from .wmv and .avi files
command for .avi file
ffmpeg -i PalivalaBadraVatakam.avi -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list palivaala.m3u8 -segment_time 10 palivaala%03d.ts
Error
ffmpeg version N-89041-g91a565e20f 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 56. 0.100 / 56. 0.100
libavcodec 58. 3.101 / 58. 3.101
libavformat 58. 2.100 / 58. 2.100
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 0.101 / 7. 0.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from 'PalivalaBadraVatakam.avi':
Metadata:
date : 2018-04-24T17:08:40+05:30
encoder : Adobe Premiere Pro CC 2018.1 (Windows)
Duration: 00:00:53.19, start: 0.000000, bitrate: 30317 kb/s
Stream #0:0: Video: dvvideo (dvsd / 0x64737664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28789 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
[AVBSFContext # 000001e976f84080] Codec 'dvvideo' (24) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_mp4toannexb
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
Command for .wmv file
ffmpeg -i Palivaalaa.wmv -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list palivaalaa.m3u8 -segment_time 10 palivaalaa%03d.ts
Error
ffmpeg version N-89041-g91a565e20f 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 56. 0.100 / 56. 0.100
libavcodec 58. 3.101 / 58. 3.101
libavformat 58. 2.100 / 58. 2.100
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 0.101 / 7. 0.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
[wmv3 # 0000024020a04a40] Extra data: 8 bits left, value: 20
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'Palivaalaa.wmv':
Metadata:
Application : Windows Movie Maker 2.6.4037.0
WMFSDKVersion : 12.0.16299.248
WMFSDKNeeded : 0.0.0.0000
artist : Sathish
IsVBR : 0
DeviceConformanceTemplate: MP#ML
Duration: 00:01:00.10, start: 0.000000, bitrate: 571 kb/s
Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, fltp, 96 kb/s
Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 768 kb/s, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 1k tbc
[AVBSFContext # 0000024020a9b420] Codec 'wmv3' (71) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_mp4toannexb
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
HLS with TS files only supports h.264 video codec and aac or mp3 audio. Hence -codec copy will not work. Just remove that, and ffmpeg should choose libx264 automatically.
This file formats support by the TS muxer are listed here https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/mpegts.h#L45-L64
In summary they are:
VIDEO_MPEG1
VIDEO_MPEG2
AUDIO_MPEG1
AUDIO_MPEG2
AUDIO_AAC
AAC_LATM
VIDEO_MPEG4
METADATA
VIDEO_H264
VIDEO_HEVC
VIDEO_CAVS
VIDEO_VC1
VIDEO_DIRAC
AUDIO_AC3
AUDIO_DTS
AUDIO_TRUEHD
AUDIO_EAC3
None of the codecs you are trying are listed. And as it has in it's name the -vbsf h264_mp4toannexb and the error message Codec 'wmv3' (71) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27), the h264_mp4toannexb filter only supports h264
I can't get ffmpeg to work with live streams from youtube. Normal non-live videos work just fine. But with live streams ffmpeg seems like it doesn't make enough requests for new segments. It basically downloads, say a 3 second segment, then nothing happens for 10 seconds or so, then it downloads a new segment, repeat...
ffmpeg -i '$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)' -f flv rtmp://192.168.0.11/myapp/mystream
So what's the automagic command?
ffmpeg version:
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
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
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
youtube-dl version: 2018.03.14
Following is the output of the command above. The <MY NOTE #> is added by me for description purposes.
At start execution goes smoothly. It then freezes for 10 or 15 sec at <MY NOTE 1>. It then downloads the part of the stream - <MY NOTE 2>, plays is, then freezes again for some seconds. Then downloads the next part - <MY NOTE 3>, plays it, freezes, and so on...
$ ffmpeg -i '$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)' -f flv rtmp://192.168.0.11/myapp/mystream
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
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
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308292/goap/clen%3D48852%3Blmt%3D1520930742662673/govp/clen%3D347004%3Blmt%3D1520930742662679/dur/2.000/file/seg.ts' for reading
Input #0, hls,applehttp, from 'https://manifest.googlevideo.com/api/manifest/hls_playlist/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/dover/10/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8':
Duration: N/A, start: 39603.798400, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
Metadata:
variant_bitrate : 0
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> flv1 (flv))
Stream #0:0 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmp://192.168.0.11/myapp/mystream':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
variant_bitrate : 0
encoder : Lavc57.107.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
<MY NOTE 1>encoder : Lavc57.107.100 libmp3lame
<MY NOTE 2>[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308293/goap/clen%3D48853%3Blmt%3D1520930742662680/govp/clen%3D404944%3Blmt%3D1520930742662686/dur/2.000/file/seg.ts' for reading
<MY NOTE 3>[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308294/goap/clen%3D48852%3Blmt%3D1520930742662688/govp/clen%3D403294%3Blmt%3D1520930742662693/dur/2.000/file/seg.ts' for reading
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308295/goap/clen%3D48355%3Blmt%3D1520930742662695/govp/clen%3D358330%3Blmt%3D1520930742662700/dur/2.000/file/seg.ts' for reading
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308296/goap/clen%3D48852%3Blmt%3D1520930742662701/govp/clen%3D347658%3Blmt%3D1520930742662707/dur/2.000/file/seg.ts' for reading
frame= 225 fps=1.8 q=31.0 size= 947kB time=00:00:07.92 bitrate= 979.2kbits/s speed=0.0625x
And you don't have to output to a rtmp. Can be a local file - behavior is the same.
Try using the hls prefix. Example:
ffmpeg -i "hls+$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)" -f flv rtmp://192.168.0.11/myapp/mystream
I use this simple script to convert video to images using ffmpeg, but frame rate is fixed, how can I determine it automatically?
FRAME_RATE="30"
SEPARATOR='/'
VIDEO_PATH=$1
VIDEO_BASE_DIR=`dirname $1`
FRAMES_DIR=$VIDEO_BASE_DIR$SEPARATOR"Frames"
rm -rf $FRAMES_DIR
mkdir $FRAMES_DIR
#Convert video to images
./ffmpeg -r $FRAME_RATE -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d.png"
UPDATE:
By ffprobe I checked that my 1st video frame rate is 30.
Also results are the same (339 frames are produced) even I reduce frame rate, so -r option doesn't work or work in some other way?
These command give the same result:
./ffmpeg -r 10 -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d"$EXTENSION
./ffmpeg -r 30 -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d"$EXTENSION
./ffmpeg -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d"$EXTENSION
Output:
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 '/home/user/myvideo1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-01-16 05:30:03
Duration: 00:00:11.33, start: 0.000000, bitrate: 4659 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 4539 kb/s, SAR 65536:65536 DAR 4:3, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-01-16 05:30:03
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
creation_time : 2016-01-16 05:30:03
handler_name : SoundHandle
Output #0, image2, to '/home/user/Frames/image%d.png':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf55.43.100
Stream #0:0(eng): Video: png, rgb24, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
rotate : 90
creation_time : 2016-01-12 05:38:03
handler_name : VideoHandle
encoder : Lavc55.66.101 png
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> png (png))
Press [q] to stop, [?] for help
frame= 339 fps= 68 q=0.0 Lsize=N/A time=00:00:11.30 bitrate=N/A
video:195852kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
ffprobe -v 0 -of compact=p=0 -select_streams 0 \
-show_entries stream=r_frame_rate 'The Master (2012).mp4'
Result:
r_frame_rate=24000/1001
You can use ffprobe and awk to grab fps for you:
ffprobe -show_streams "video" 2>&1 | \
grep fps | \
awk '{split($0,a,"fps")}END{print a[1]}' | \
awk '{print $NF}'
Some time ago I wrote an article about generating ffmpeg previews from videos which is maybe similar to what you're trying to do. I had to count total number of frames in a video:
See https://www.binpress.com/tutorial/how-to-generate-video-previews-with-ffmpeg/138
What about
./ffmpeg -i input_file 2>&1 | sed -n "s/.*, \(.*\) tbr.*/\1/p"
ON windows 10,
ffmpeg -i <input video file>
The last portion will show fps info. Please check the line beginning with "Stream...."
The following video file is encoded in 60 fps .
C:\user\mitchell\ffmpeg -i video0001.mp4
ffmpeg version 2021-09-22-git-447cf53774-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 6.100 / 57. 6.100
libavcodec 59. 9.100 / 59. 9.100
libavformat 59. 5.100 / 59. 5.100
libavdevice 59. 0.101 / 59. 0.101
libavfilter 8. 9.100 / 8. 9.100
libswscale 6. 1.100 / 6. 1.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100
Input #0, matroska,webm, from 'video0001.mp4':
Metadata:
encoder : GStreamer matroskamux version 1.14.5
creation_time : 2021-09-22T17:52:09.000000Z
Duration: 00:00:25.75, start: 2.470000, bitrate: 4256 kb/s
Stream #0:0(eng): Video: hevc (Main), yuvj420p(pc, progressive), 3840x2160, SAR 1:1 DAR 16:9, 60 fps, 60 tbr, 1k tbn (default)
Metadata:
title : Video