error when converting mts to mp4 - ffmpeg

I have many video files that I want to convert to mp4.
so I installed ffmpeg on my win7 PC (64 bit) which is using shared library.
I tried to convert an MTS file to MP4 and I get this error.
What is the problem?
$ ffmpeg -i 20140806114251.MTS 20140806114251.mp4
ffmpeg version N-68788-g37b35fe Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 30 2014 22:18:55 with gcc 4.9.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --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-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 19.100 / 56. 19.100
libavformat 56. 16.102 / 56. 16.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 6.100 / 5. 6.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mpegts, from '20140806114251.MTS':
Duration: 00:00:19.04, start: 1.033367, bitrate: 16273 kb/s
Program 1
Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
[libx264 # 0000000002b60a20] using SAR=1/1
[libx264 # 0000000002b60a20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0000000002b60a20] profile High, level 4.0
[libx264 # 0000000002b60a20] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libvo_aacenc # 00000000028a4020] Unable to set encoding parameters
Output #0, mp4, to '20140806114251.mp4':
Stream #0:0: Video: h264 (libx264), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 29.97 tbn, 29.97 tbc
Metadata:
encoder : Lavc56.19.100 libx264
Stream #0:1: Audio: aac, 0 channels, 128 kb/s
Metadata:
encoder : Lavc56.19.100 libvo_aacenc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (ac3 (native) -> aac (libvo_aacenc))
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
EDIT : I thought I solved this problem by using
ffmpeg -i filename1.mts filename1.mkv
my Samsung LED TV supports mkv file and during the conversion, it shows
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (ac3 (native) -> vorbis (libvorbis))
But Alas! my TV doesn't support vorbis codec. It only supports mp3, ac3, lpcm, and ADPCM when using mkv container. So the question is : How do people select output audio codec?

I solved this by using
ffmpeg -i file1.mts -y -acodec ac3_fixed file1.mkv
see my EDIT above.
and if you want to change the file format (keeping the codec type),
ffmpeg -i file1.MTS -c copy file1.avi
This doesn't take any time and finishes instantly.
EDIT : the file generated using -c copy cannot be played on my Samsung LED TV. The first method works though slow in conversion.

Selecting an audio encoder
So the question is: How do people select output audio codec?
Choose an audio encoder with -c:a such as -c:a libmp3lame for MP3 audio.
See ffmpeg -encoders for a list of encoders supported by your ffmpeg build.
Stream copy
You may be able to simply re-mux (stream copy) to a new container format, and avoid re-encoding, and your TV may play it:
ffmpeg -i input.mts -c copy output.mkv

Related

ffmpeg video merging issues for videos recorded from andriod mobile phone

Following is the command I'm using:
sudo ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[1]tpad=start_mode=clone:start_duration=15[tr];[0][tr]xstack=inputs=2:layout=0_0|w0_0[v];[1:a]adelay=15s:all=true[a1];[0:a][a1]amix=inputs=2[a]" -map "[v]" -map "[a]" output.mp4
It took a couple of hours to merge the videos. Original videos are 6 MBs in size. Merged video is approx 2 GB in size.
It is working fine with videos recorded from the iphone.
Update:
The issue is regarding different fps in different videos. If two videos are of different fps, then it is taking too long and eventually break.
Full log:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[1]tpad=start_mode=clone:start_duration=15[tr];[0][tr]xstack=inputs=2:layout=0_0|w0_0[v];[1:a]adelay=15s:all=true[a1];[0:a][a1]amix=inputs=2[a]" -map "[v]" -map "[a]" output_ia_2.mp4
ffmpeg version 4.3.2-0york0~16.04 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
configuration: --prefix=/usr --extra-version='0york0~16.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '97FD4344-23C3-4668-AA40-E5E724338352-3149-0000018389D9630F.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2021-04-09T00:43:28.000000Z
Duration: 00:00:15.03, start: 0.000000, bitrate: 10342 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 226 kb/s (default)
Metadata:
creation_time : 2021-04-09T00:43:28.000000Z
handler_name : Core Media Audio
Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 720x1280, 10111 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2021-04-09T00:43:28.000000Z
handler_name : Core Media Video
encoder : H.264
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'android_ritesh.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2021-04-13T06:39:16.000000Z
com.android.version: 10
Duration: 00:00:09.59, start: 0.000000, bitrate: 5288 kb/s
Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown), 720x1280, 5152 kb/s, SAR 1:1 DAR 9:16, 17.31 fps, 59.94 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2021-04-13T06:39:16.000000Z
handler_name : VideoHandle
Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 131 kb/s (default)
Metadata:
creation_time : 2021-04-13T06:39:16.000000Z
handler_name : SoundHandle
Stream mapping:
Stream #0:0 (aac) -> amix:input0
Stream #0:1 (h264) -> xstack:input0
Stream #1:0 (h264) -> tpad
Stream #1:1 (aac) -> adelay
xstack -> Stream #0:0 (libx264)
amix -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[swscaler # 0x5628692bd340] deprecated pixel format used, make sure you did set range correctly
[mp4 # 0x562868aa7dc0] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 # 0x562868af2400] MB rate (648000000) > level limit (16711680)
[libx264 # 0x562868af2400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x562868af2400] profile High, level 6.2
[libx264 # 0x562868af2400] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output_ia_2.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1440x1280, q=-1--1, 90k tbn, 90k tbc (default)
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
encoder : Lavc58.91.100 aac
More than 1000 frames duplicated 0kB time=00:00:00.00 bitrate=N/A speed= 0x
More than 10000 frames duplicated 4352kB time=00:00:00.09 bitrate=358592.3kbits/s dup=8991 drop=0 speed=0.00141x
frame=15000 fps=131 q=33.0 size= 7680kB time=00:00:00.16 bitrate=378802.6kbits/s dup=14985 drop=0 speed=0.00145x

how to remove duplicated frame from 00:00:00,00 to 00:00:00,25 section not overall with mpdecimate filter?

how to remove duplicated frame from 00:00:00,00 to 00:00:00,25 (00frame ~ 25frames)section not overall with mpdecimate filter ??
normally H264 video have some duplicated frames on video start section ..
i have tried like this ,
1) ./ffmpeg -i cated_2-3.UMMJI.MTS -map 0:0 -c:v prores_ks -profile:v 1 -qscale:v 8 -s 1920x1080 -r 29.97 -top 1 -c:a pcm_s16le -map 0:1 -filter:a:0 "pan=mono|c0=c0" -map 0:1 -filter:a:1 "pan=mono|c0=c1" -metadata:s encoder="Apple ProRes 422 LT" -filter_complex "[0]split=2[a][b];[a]trim=end_frame=26,mpdecimate[a];[b]trim=start_frame=25,setpts=PTS-STARTPTS[b];[a][b]concat=n=2:v=1:a=0" -vsync vfr -vf blackdetect=d=0.1:pix_th=.1 cated_2-3.UMMJI_MTS_mpdecimate26_section.mov
and tried to check black_frame on out prores mov file
2)./ffmpeg -i cated_2-3.UMMJI_MTS_mpdecimate26_section.mov -vf blackdetect=d=0.1:pix_th=.1 test.mov
then , will be shown like below
macmini-master:1. two_file_test khan$ ./ffmpeg -i cated_2-3.UMMJI_MTS_mpdecimate26_section.mov -vf blackdetect=d=0.1:pix_th=.1 test.mov
ffmpeg version N-92108-ge08a876e67-tessus https://evermeet.cx/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.2)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
libavutil 56. 19.101 / 56. 19.101
libavcodec 58. 32.100 / 58. 32.100
libavformat 58. 18.104 / 58. 18.104
libavdevice 58. 4.105 / 58. 4.105
libavfilter 7. 33.100 / 7. 33.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cated_2-3.UMMJI_MTS_mpdecimate26_section.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.18.104
Duration: 00:25:12.58, start: 0.000000, bitrate: 86198 kb/s
Stream #0:0(eng): Video: prores (apcs / 0x73637061), yuv422p10le(tv, top first), 1920x1080, 84662 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 11988 tbn, 11988 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Apple ProRes 422 LT
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16, 768 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16, 768 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (prores (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x7f8eb2804200] using SAR=1/1
[libx264 # 0x7f8eb2804200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7f8eb2804200] profile High 4:2:2, level 4.0, 4:2:2, 8-bit
[libx264 # 0x7f8eb2804200] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'test.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.18.104
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 11988 tbn, 29.97 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.32.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.32.100 aac
frame= 8224 fps= 21 q=29.0 size= 86528kB time=00:04:34.49 bitrate=2582.3kbits/s dup=19 drop=0 speed=0.689x
as you can see duplicated frame just changed to black frame , not removed
this MTS file have 19 duplicated frames !
also i have checked in FCPX and count how many dupicated frame on out prores mov file ...
Use
ffmpeg -i in -filter_complex "[0]split=2[a][b];[a]trim=end_frame=26,mpdecimate[a];[b]trim=start_frame=26,setpts=PTS-STARTPTS[b];[a][b]concat=n=2:v=1:a=0" -vsync vfr out

ffmpeg: Streaming with RTSP and recording at the same time

My goal is to stream a part of my desktop to a remote machine, and to record the sent stream at the same time.
The streaming technology chosen is the RTSP protocol with FFserver as rtsp server.
I already succeed the streaming part with ffmpeg, but now I'm trying to record the stream at the same time. To do so, I'm trying to use the tee pseudo-muxer as referenced here:
http://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs
https://ffmpeg.org/ffmpeg-formats.html#tee
Unfortunately, I'm having an error message when launching my command which is the following:
ffmpeg -loglevel debug -f alsa -ac 2 -thread_queue_size 512 -ar 44100 -i hw:0 \
-f x11grab -framerate 30 -show_region 1 -video_size 800x480 -thread_queue_size 512 -i :0.0 \
-f tee -c:v libx264 -c:a mp3 -pix_fmt yuv422p -flags +global_header -map 1:v -map 0:a \
"test.mp4|[f=ffm]http://localhost:8000/feed.ffm/"
And here is the output:
ffmpeg version 3.4-1~xenial1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609
configuration: --prefix=/usr --extra-version='1~xenial1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-nvenc --enable-libdc1394 --enable-libiec61883 --enable-libopencv --enable-frei0r --enable-libx264 --enable-shared
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
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:0':
Duration: N/A, start: 1512038836.756092, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Input #1, x11grab, from ':0.0':
Duration: N/A, start: 1512038836.789836, bitrate: N/A
Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 800x480, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 # 0x5621206c0180] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x5621206c0180] profile High 4:2:2, level 3.1, 4:2:2 8-bit
[libx264 # 0x5621206c0180] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[tee # 0x5621206bef60] Slave '[f=ffm]http://localhost:8000/feed.ffm/': error writing header: Broken pipe
[tee # 0x5621206bef60] Slave muxer #1 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?):
Broken pipe
Error initializing output stream 0:1 --
Conversion failed!
I also tried with f=rtsp, with no chance and this error message:
[tee # 0x559b26ea2f40] Slave '[f=rtsp]http://localhost:8000/feed.ffm/': error writing header: Invalid data found when processing input
[tee # 0x559b26ea2f40] Slave muxer #1 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Error initializing output stream 0:1 --
FFserver configuration:
<Feed feed.ffm>
File /tmp/feed.ffm
FileMaxSize 20M
</Feed>
<Stream test.mp4>
Feed feed.ffm
Format rtp
VideoSize 800x480
VideoQMin 1
VideoQMax 25
VideoFrameRate 30
VideoBitRate 8000
VideoCodec libx264
PixelFormat yuv422p
#h264 options
AVOptionVideo flags +global_header
AVOptionVideo preset ultrafast
AVOptionVideo crf 25
AVOptionVideo profile high422
AVOptionVideo tune zerolatency
NoAudio
</Stream>
"Slave '[f=ffm]http://localhost:8000/feed.ffm/': error writing header: Broken pipe" is the key, but I can't figure what is wrong in my command. Without tee, it works flawlessly.
I did many searches and cannot find the problem yet, so I'm asking here.
Thanks,
Barzou.

FFMPEG doesn't work with mp4 and stdout

I need to add text to mp4 video. If I write result to file then everything is OK, but I want to read data from ffmpeg stream.
I run command:
ffmpeg -i sample.mp4 -filter_complex "drawtext='text=\"Sample Text\"':x=(w-text_w)/2:y=(h-text_h-line_h)/2:fontsize=40:fontcolor=white:fontfile=TimesNewRoman.ttf:enable='between(t,1,5)'" -f mp4 -
I received the following error:
ffmpeg version 2.2.2-tessus Copyright (c) 2000-2014 the FFmpeg developers
built on May 7 2014 23:17:42 with clang version 3.3 (tags/RELEASE_33/final)
configuration: --cc=/opt/local/bin/clang-mp-3.3 --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-libmodplug --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --disable-indev=qtkit --enable-runtime-cpudetect
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 'a5732-480x320-clip01-sound.mp4':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
creation_time : 2014-02-12 02:23:02
Duration: 00:00:15.10, start: 0.000000, bitrate: 509 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 480x320 [SAR 1:1 DAR 3:2], 457 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2014-02-12 02:23:02
handler_name : Mainconcept MP4 Video Media Handler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 32000 Hz, stereo, fltp, 46 kb/s (default)
Metadata:
creation_time : 2014-02-12 02:23:02
handler_name : Mainconcept MP4 Sound Media Handler
[libx264 # 0x10400d800] using SAR=1/1
[libx264 # 0x10400d800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x10400d800] profile High, level 2.1
[libx264 # 0x10400d800] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 # 0x10400d200] muxer does not support non seekable output
Output #0, mp4, to 'pipe:':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 480x320 [SAR 1:1 DAR 3:2], q=-1--1, 90k tbn, 29.97 tbc (default)
Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 32000 Hz, stereo, s16, 128 kb/s (default)
Metadata:
creation_time : 2014-02-12 02:23:02
handler_name : Mainconcept MP4 Sound Media Handler
Stream mapping:
Stream #0:0 (h264) -> drawtext (graph 0)
drawtext (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Conversion failed!
It seems the problem is related to mp4 and "muxer does not support non seekable output"
Is there a solution how to make such text adding on the fly and return video as we have data and not to wait until all file is processed.
Thanks
You can't use MP4 with STDOUT. The MP4 container requires the encoder to go back and make changes to the beginning of the file after it is done writing through the end. Since STDOUT cannot seek, outputting media in an MP4 container is not possible with STDOUT.
You can use the empty_moov example ffmpeg -y -framerate 0.5 -pattern_type glob -i '*.jpg' -f mp4 -movflags empty_moov - | ffprobe -
-movflags empty_moov
Write an initial moov atom directly at the start of the file, without describing any samples in it. Generally, an mdat/moov pair is written at the start of the file, as a normal MOV/MP4 file, containing only a short portion of the file. With this option set, there is no initial mdat atom, and the moov atom only describes the tracks but has a zero duration.
This option is implicitly set when writing ismv (Smooth Streaming) files.
https://www.ffmpeg.org/ffmpeg-formats.html
Add param
-movflags frag_keyframe+empty_moov
from: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/346#issuecomment-67299526

why ffmpeg is not working in new installation

I was working on live encoding from FFmpeg from last few days. One day I re-installed my OS and tried to run FFmpeg commands again after configuration. My publish points get in starting but could not started. Why? Am I missing any configuration required?
The command I am trying to run is:
ffmpeg -y -re -i D:\video2.mp4 -pix_fmt yuv420p -movflags isml+frag_keyframe -f ismv -threads 0 -c:v libx264 -preset fast -profile:v baseline -map 0:v -b:v:0 800k http://localhost/PPS/PublishPoint.isml/Streams(Encode
r1)
Output what I got in command prompt is:
ffmpeg version N-54772-g53c853e Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 16 2013 22:25:42 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.101 / 3. 81.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\video2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.10.100
Duration: 00:00:12.12, start: 0.072562, bitrate: 945 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x396 [
SAR 1:1 DAR 16:9], 882 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 64
kb/s
Metadata:
handler_name : SoundHandler
[libx264 # 00000000047e0860] using SAR=1/1
[libx264 # 00000000047e0860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 # 00000000047e0860] profile Constrained Baseline, level 3.0
[libx264 # 00000000047e0860] 264 - core 135 r2345 f0c1c53 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 r
ef=2 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pski
p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyi
nt=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=abr mbtree=1
bitrate=800 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1
:1.00
Output #0, ismv, to 'http://localhost/My_SSMN_PPS/saturday.isml/Streams(Encoder1
)':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.12.102
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 7
04x396 [SAR 1:1 DAR 16:9], q=-1--1, 800 kb/s, 10000k tbn, 29.97 tbc
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
frame= 13 fps=0.0 q=0.0 size= 2kB time=00:00:00.00 bitrate=N/A dup=2 dro
frame= 29 fps= 29 q=0.0 size= 2kB time=00:00:00.00 bitrate=N/A dup=2 dro
av_interleaved_write_frame(): Unknown error
Advanced Thanks.
I changed my devices as I was using HD Webcam replaced with simple devices and It worked fine.
So, I found one solution of this problem but can't say it is ideal.
Thanks.

Resources