So I want to try and use the ffmpeg MAP command to do the following:
Merge audio and jpg
Concatenate mp4 to end
Still.jpg
audio.mp3 -> video.mp4 = output.mp4
Right now I have
/home/admin/ffmpeg/ffmpeg -i still.jpg -i audio.mp3 render1.mp4
But I want to also go ahead and add on the video.mp4 as well. I tried reading the map function but I'm so confused as to how you know how many streams a file has, etc
Heres the output of the command....note I have different file names
Input #0, image2, from 'slide_2.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 8276 kb/s
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #1, mp3, from '/home/admin/web/admin.simplewebevents.com/public_html/cron/steveng1.mp3':
Metadata:
encoder : Lavf57.56.100
Duration: 00:00:05.78, start: 0.023021, bitrate: 64 kb/s
Stream #1:0: Audio: mp3, 48000 Hz, mono, s16p, 64 kb/s
File 'introFile62.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (native) -> aac (native))
Press [q] to stop, [?] for help
No pixel format specified, yuvj420p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0x3589a00] using SAR=1/1
[libx264 # 0x3589a00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x3589a00] profile High, level 3.1
[libx264 # 0x3589a00] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=1 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 'introFile62.mp4':
Metadata:
encoder : Lavf57.72.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj420p(pc, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.96.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, mono, fltp, 69 kb/s
Metadata:
encoder : Lavc57.96.101 aac
frame= 1 fps=0.2 q=28.0 Lsize= 70kB time=00:00:05.76 bitrate= 99.2kbits/s speed=1.27x
video:18kB audio:49kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.483214%
[libx264 # 0x3589a00] frame I:1 Avg QP:25.71 size: 18268
[libx264 # 0x3589a00] mb I I16..4: 25.6% 63.4% 10.9%
[libx264 # 0x3589a00] 8x8 transform intra:63.4%
[libx264 # 0x3589a00] coded y,uvDC,uvAC intra: 14.3% 18.5% 8.9%
[libx264 # 0x3589a00] i16 v,h,dc,p: 81% 9% 10% 1%
[libx264 # 0x3589a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 50% 12% 33% 1% 1% 1% 0% 1% 1%
[libx264 # 0x3589a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46% 21% 13% 3% 4% 5% 2% 4% 2%
[libx264 # 0x3589a00] i8c dc,h,v,p: 76% 8% 15% 1%
[libx264 # 0x3589a00] kb/s:3653.60
[aac # 0x358aea0] Qavg: 118.057
Related
I developed a video conferencing app that records the video streams separately, and I am now looking for a way to merge them. At the moment I am experimenting with -itsoffset and hstack to stack 2 videos side by side using this command:
ffmpeg \
-itsoffset 17 -i smaller.mp4 \
-itsoffset 0 -i bigger.mp4 \
-filter_complex hstack=inputs=2 \
-c:v libx264 -crf 23 out.mp4
The result is a side by side video where both streams remain frozen for 17 seconds then start playing, even the bigger.mp4 video that should start at time 0.
Any help would be really appreciated!
ffmpeg verbose:
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10+deb8u1)
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libx264 --enable-libspeex --enab le-shared --enable-pthreads --enable-libopenjpeg --enable-nonfree --enable-libopus --enable-libvorbis --enable-libvpx
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, mov,mp4,m4a,3gp,3g2,mj2, from 'smaller.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:05.16, start: 0.000000, bitrate: 444 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 330 kb/s, 32 fps, 32 tbr, 16384 tbn, 64 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 103 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'bigger.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.36.100
Duration: 00:00:22.03, start: 0.000000, bitrate: 290 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 177 kb/s, 32 fps, 32 tbr, 16384 tbn, 64 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 103 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'out.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 (h264) -> hstack:input0 (graph 0)
Stream #1:0 (h264) -> hstack:input1 (graph 0)
hstack (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x206ed00] using SAR=1/1
[libx264 # 0x206ed00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x206ed00] profile High, level 3.1
[libx264 # 0x206ed00] 264 - core 146 - 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=3 lookahead_threads=1 sliced_thre ads=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 scene cut=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 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 960x360 [SAR 1:1 DAR 8:3], q=-1--1, 32 fps, 16384 tbn, 32 tbc (default)
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.35.100 aac
frame= 709 fps=130 q=-1.0 Lsize= 573kB time=00:00:22.12 bitrate= 212.2kbits/s dup=544 drop=0 speed=4.05x
video:478kB audio:81kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.445685%
[libx264 # 0x206ed00] frame I:3 Avg QP:16.86 size: 38355
[libx264 # 0x206ed00] frame P:190 Avg QP:18.22 size: 1633
[libx264 # 0x206ed00] frame B:516 Avg QP:16.23 size: 123
[libx264 # 0x206ed00] consecutive B-frames: 1.3% 2.8% 6.8% 89.1%
[libx264 # 0x206ed00] mb I I16..4: 6.6% 54.8% 38.6%
[libx264 # 0x206ed00] mb P I16..4: 0.4% 1.5% 0.2% P16..4: 8.7% 4.0% 1.9% 0.0% 0.0% skip:83.3%
[libx264 # 0x206ed00] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 4.2% 0.3% 0.0% direct: 0.0% skip:95.4% L0:37.2% L1:58.9% BI: 4.0%
[libx264 # 0x206ed00] 8x8 transform intra:66.2% inter:63.4%
[libx264 # 0x206ed00] coded y,uvDC,uvAC intra: 66.1% 65.6% 21.6% inter: 1.7% 1.1% 0.0%
[libx264 # 0x206ed00] i16 v,h,dc,p: 21% 26% 11% 42%
[libx264 # 0x206ed00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 23% 13% 5% 7% 8% 7% 7% 6%
[libx264 # 0x206ed00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 24% 9% 6% 7% 7% 6% 7% 7%
[libx264 # 0x206ed00] i8c dc,h,v,p: 46% 25% 20% 9%
[libx264 # 0x206ed00] Weighted P-Frames: Y:1.1% UV:0.0%
[libx264 # 0x206ed00] ref P L0: 66.0% 19.4% 12.0% 2.6% 0.0%
[libx264 # 0x206ed00] ref B L0: 87.2% 11.8% 1.0%
[libx264 # 0x206ed00] ref B L1: 95.2% 4.8%
[libx264 # 0x206ed00] kb/s:176.52
[aac # 0x204aa00] Qavg: 247.398
hstack doesn't sync by timestamps. You'll need to pad the delayed video.
ffmpeg \
-i smaller.mp4 \
-i bigger.mp4 \
-filter_complex \
"[0]tpad=start_duration=17[left];\
[left][1]hstack=inputs=2;\
[0]adelay=17s|17s[lefta];[lefta][1]amix=2" \
-c:v libx264 -crf 23 out.mp4
So, I'm using this code to compress my *mp4 file. I need to get lower quality and decrease bitrate:
ffmpeg -i input.mp4 -c:v libx264 output.mp4
The problem is: the last frame of footage is dropped after ffmpeg compression.
Screenshot is here: screenshot_ffmpeg_drop frame
I tried to use full preferences I need, but the problem is the same.
ffmpeg -i input.mp4 -c:v libx264 -vf scale=1280:720 -preset fast -crf 29 -r 25 -c:a copy output.mp4
logfile during ffmpeg encoding:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '\input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2018-10-28T11:06:03.000000Z
Duration: 00:00:12.76, start: 0.000000, bitrate: 5374 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 5368 kb/s, 25 fps, 25 tbr, 50k tbn, 50 tbc (default)
Metadata:
creation_time : 2018-10-28T11:06:03.000000Z
handler_name : Alias Data Handler
encoder : AVC Coding
Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264
(libx264)) Press [q] to stop, [?] for help [libx264 #
000002fae8b50780] using SAR=1/1 [libx264 # 000002fae8b50780] using cpu
capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 #
000002fae8b50780] profile High, level 3.1 [libx264 # 000002fae8b50780]
264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft
2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=2
deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=1 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf
mbtree=1 crf=29.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00 Output #0, mp4, to '\output.mp4': Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
encoder : Lavf58.17.100
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25
tbc (default)
Metadata:
creation_time : 2018-10-28T11:06:03.000000Z
handler_name : Alias Data Handler
encoder : Lavc58.19.104 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 318 fps=127 q=-1.0 Lsize= 855kB time=00:00:12.60 bitrate=
556.0kbits/s speed=5.05x video:851kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.534683% [libx264 #
0000015d5cef0500] frame I:2 Avg QP:26.18 size: 67800 [libx264 #
0000015d5cef0500] frame P:80 Avg QP:27.93 size: 5439 [libx264 #
0000015d5cef0500] frame B:236 Avg QP:32.44 size: 1269 [libx264 #
0000015d5cef0500] consecutive B-frames: 0.9% 0.0% 0.9% 98.1%
[libx264 # 0000015d5cef0500] mb I I16..4: 10.6% 62.5% 26.8% [libx264
# 0000015d5cef0500] mb P I16..4: 0.5% 1.0% 0.2% P16..4: 36.1%
5.1% 3.6% 0.0% 0.0% skip:53.6% [libx264 # 0000015d5cef0500] mb B I16..4: 0.6% 0.5% 0.0% B16..8: 22.2% 0.6% 0.0% direct: 2.0%
skip:74.2% L0:44.9% L1:54.5% BI: 0.6% [libx264 # 0000015d5cef0500]
8x8 transform intra:55.0% inter:86.2% [libx264 # 0000015d5cef0500]
coded y,uvDC,uvAC intra: 48.1% 54.9% 27.0% inter: 3.2% 5.2% 0.2%
[libx264 # 0000015d5cef0500] i16 v,h,dc,p: 19% 56% 10% 15% [libx264 #
0000015d5cef0500] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 25% 18% 5% 6%
5% 8% 5% 8% [libx264 # 0000015d5cef0500] i4
v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 24% 9% 5% 8% 7% 9% 5% 7%
[libx264 # 0000015d5cef0500] i8c dc,h,v,p: 60% 20% 15% 4% [libx264 #
0000015d5cef0500] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 #
0000015d5cef0500] ref P L0: 67.7% 32.3% [libx264 # 0000015d5cef0500]
ref B L0: 80.4% 19.6% [libx264 # 0000015d5cef0500] ref B L1: 92.1%
7.9% [libx264 # 0000015d5cef0500] kb/s:547.35
Use
ffmpeg -ignore_editlist 1 -i input.mp4 ... output.mp4
I am using the following command:
ffmpeg
-i "video1a.flv"
-i "video1b.flv"
-i "video1c.flv"
-i "video2a.flv"
-i "video3a.flv"
-i "video4a.flv"
-i "video4b.flv"
-i "video4c.flv"
-i "video4d.flv"
-i "video4e.flv"
-filter_complex
nullsrc=size=640x480[base];
[0:v]setpts=PTS-STARTPTS+0.12/TB,scale=320x240[1a];
[1:v]setpts=PTS-STARTPTS+3469.115/TB,scale=320x240[1b];
[2:v]setpts=PTS-STARTPTS+7739.299/TB,scale=320x240[1c];
[5:v]setpts=PTS-STARTPTS+4390.466/TB,scale=320x240[4a];
[6:v]setpts=PTS-STARTPTS+6803.937/TB,scale=320x240[4b];
[7:v]setpts=PTS-STARTPTS+8242.005/TB,scale=320x240[4c];
[8:v]setpts=PTS-STARTPTS+9811.577/TB,scale=320x240[4d];
[9:v]setpts=PTS-STARTPTS+10765.19/TB,scale=320x240[4e];
[base][1a]overlay=eof_action=pass[o1];
[o1][1b]overlay=eof_action=pass[o1];
[o1][1c]overlay=eof_action=pass:shortest=1[o1];
[o1][4a]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4b]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4c]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4d]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4e]overlay=eof_action=pass:x=320:y=240;
[0:a]asetpts=PTS-STARTPTS+0.12/TB,aresample=async=1,pan=1c|c0=c0,apad[a1a];
[1:a]asetpts=PTS-STARTPTS+3469.115/TB,aresample=async=1,pan=1c|c0=c0,apad[a1b];
[2:a]asetpts=PTS-STARTPTS+7739.299/TB,aresample=async=1,pan=1c|c0=c0[a1c];
[3:a]asetpts=PTS-STARTPTS+82.55/TB,aresample=async=1,pan=1c|c0=c0,apad[a2a];
[4:a]asetpts=PTS-STARTPTS+2687.265/TB,aresample=async=1,pan=1c|c0=c0,apad[a3a];
[a1a][a1b][a1c][a2a][a3a]amerge=inputs=5
-c:v libx264 -c:a aac -ac 2 output.mp4
This is the stream data from ffmpeg:
Input #0
Stream #0:0: Video: vp6f, yuv420p, 160x128, 1k tbr, 1k tbn
Stream #0:1: Audio: nellymoser, 11025 Hz, mono, flt
Input #1
Stream #1:0: Audio: nellymoser, 11025 Hz, mono, flt
Stream #1:1: Video: vp6f, yuv420p, 160x128, 1k tbr, 1k tbn
Input #2
Stream #2:0: Audio: nellymoser, 11025 Hz, mono, flt
Stream #2:1: Video: vp6f, yuv420p, 160x128, 1k tbr, 1k tbn
Input #3
Stream #3:0: Audio: nellymoser, 11025 Hz, mono, flt
Input #4
Stream #4:0: Audio: nellymoser, 11025 Hz, mono, flt
Input #5
Stream #5:0: Video: vp6f, yuv420p, 1680x1056, 1k tbr, 1k tbn
Input #6
Stream #6:0: Video: vp6f, yuv420p, 1680x1056, 1k tbr, 1k tbn
Input #7
Stream #7:0: Video: vp6f, yuv420p, 1680x1056, 1k tbr, 1k tbn
Input #8
Stream #8:0: Video: vp6f, yuv420p, 1680x1056, 1k tbr, 1k tbn
Input #9
Stream #9:0: Video: vp6f, yuv420p, 1680x1056, 1k tbr, 1k tbn
Stream mapping:
Stream #0:0 (vp6f) -> setpts
Stream #0:1 (nellymoser) -> asetpts
Stream #1:0 (nellymoser) -> asetpts
Stream #1:1 (vp6f) -> setpts
Stream #2:0 (nellymoser) -> asetpts
Stream #2:1 (vp6f) -> setpts
Stream #3:0 (nellymoser) -> asetpts
Stream #4:0 (nellymoser) -> asetpts
Stream #5:0 (vp6f) -> setpts
Stream #6:0 (vp6f) -> setpts
Stream #7:0 (vp6f) -> setpts
Stream #8:0 (vp6f) -> setpts
Stream #9:0 (vp6f) -> setpts
overlay -> Stream #0:0 (libx264)
amerge -> Stream #0:1 (aac)
This is the error:
Press [q] to stop, [?] for help
Enter command: <target>|all <time>|-1 <command>[ <argument>]
Parse error, at least 3 arguments were expected, only 1 given in string 'ho Oscar'
[Parsed_amerge_44 # 0a7238c0] No channel layout for input 1
[Parsed_amerge_44 # 0a7238c0] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
[Parsed_pan_27 # 07681880] Pure channel mapping detected: 0
[Parsed_pan_31 # 07681b40] Pure channel mapping detected: 0
[Parsed_pan_35 # 0a7232c0] Pure channel mapping detected: 0
[Parsed_pan_38 # 0a7234c0] Pure channel mapping detected: 0
[Parsed_pan_42 # 0a723740] Pure channel mapping detected: 0
[libx264 # 069e8a40] using SAR=1/1
[libx264 # 069e8a40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 069e8a40] profile High, level 3.0
[libx264 # 069e8a40] 264 - core 155 r2901 7d0ff22 - 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=15 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
Output #0, mp4, to 'output.mp4':
Metadata:
canSeekToEnd : false
encoder : Lavf58.16.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
encoder : Lavc58.19.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc58.19.102 aac
frame= 200 fps=0.0 q=28.0 size= 0kB time=00:00:07.82 bitrate= 0.0kbits/s speed=15.6x
...
frame=30132 fps=497 q=28.0 size= 29952kB time=00:20:05.14 bitrate= 203.6kbits/s speed=19.9x
Error while filtering: Cannot allocate memory
Failed to inject frame into filter network: Cannot allocate memory
Error while processing the decoded data for stream #2:1
[libx264 # 069e8a40] frame I:121 Avg QP: 8.83 size: 7052
[libx264 # 069e8a40] frame P:7609 Avg QP:18.33 size: 1527
[libx264 # 069e8a40] frame B:22367 Avg QP:25.44 size: 112
[libx264 # 069e8a40] consecutive B-frames: 0.6% 0.7% 1.0% 97.8%
[libx264 # 069e8a40] mb I I16..4: 75.7% 18.3% 6.0%
[libx264 # 069e8a40] mb P I16..4: 0.3% 0.7% 0.1% P16..4: 10.6% 3.3% 1.6% 0.0% 0.0% skip:83.4%
[libx264 # 069e8a40] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 3.2% 0.2% 0.0% direct: 0.2% skip:96.5% L0:47.7% L1:48.2% BI: 4.0%
[libx264 # 069e8a40] 8x8 transform intra:37.4% inter:70.2%
[libx264 # 069e8a40] coded y,uvDC,uvAC intra: 38.9% 46.1% 28.7% inter: 1.7% 3.3% 0.1%
[libx264 # 069e8a40] i16 v,h,dc,p: 78% 8% 4% 10%
[libx264 # 069e8a40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 20% 12% 3% 6% 8% 6% 6% 7%
[libx264 # 069e8a40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 22% 9% 4% 6% 7% 5% 5% 4%
[libx264 # 069e8a40] i8c dc,h,v,p: 60% 16% 17% 7%
[libx264 # 069e8a40] Weighted P-Frames: Y:0.7% UV:0.6%
[libx264 # 069e8a40] ref P L0: 65.5% 12.3% 14.2% 8.0% 0.0%
[libx264 # 069e8a40] ref B L0: 90.2% 7.5% 2.3%
[libx264 # 069e8a40] ref B L1: 96.4% 3.6%
[libx264 # 069e8a40] kb/s:99.58
[aac # 069e9600] Qavg: 65519.982
[aac # 069e9600] 2 frames left in the queue on closing
Conversion failed!
I am trying to figure out how to fix these errors:
Error while filtering: Cannot allocate memory
Failed to inject frame into filter network: Cannot allocate memory
Error while processing the decoded data for stream #2:1
Observation #1
If I run the following command on stream #2:1 by itself:
ffmpeg -i video1c.flv -vcodec libx264 -acodec aac video1c.mp4
The files is converted fine with no errors.
Observation #2
Running MediaInfo on video1c.flv (stream #2) shows the following:
Format: Flash Video
Video Codecs: On2 VP6
Audio Codecs: Nellymoser
Any help would be appreciated in resolving this error.
Update #1
I have tried splitting the filter graph into two as requested but I receive the same errors:
Error while filtering: Cannot allocate memory
Failed to inject frame into filter network: Cannot allocate memory
Error while processing the decoded data for stream #1:1
However, I did discover something, if I try to bring up stream #1:1 mentioned above (video1b.flv) using VLC Media Player, I can hear the audio file but I cannot see the video and I receive this error message:
No suitable decoder module:
VLC Does not support the audio or video format "undf".
Unfortunately there is no way for you to fix this.
Update #2
The above error was with the 32bit version of ffmpeg. I switched to a 64 bit machine and am now running the 64 bit ffmpeg version ffmpeg-20180605-b748772-win64-static.
Now I no longer receive the following error:
Error while processing the decoded data for stream #1:1
But, I have a new error. About an hour into running it, I receive the following error:
av_interleaved_write_frame(): Cannot allocate memory
[mp4 # 000000000433f080] Application provided duration: 3327365388930198318
/ timestamp: 17178820096 is out of range for mov/mp4 format
I also tried first remuxing all the files as suggested and using those files to run the above command and that did not help. I still get the same error.
Try with audio and video in different filtergraphs
ffmpeg
-i "video1a.flv"
-i "video1b.flv"
-i "video1c.flv"
-i "video2a.flv"
-i "video3a.flv"
-i "video4a.flv"
-i "video4b.flv"
-i "video4c.flv"
-i "video4d.flv"
-i "video4e.flv"
-filter_complex
nullsrc=size=640x480[base];
[0:v]setpts=PTS-STARTPTS+0.12/TB,scale=320x240[1a];
[1:v]setpts=PTS-STARTPTS+3469.115/TB,scale=320x240[1b];
[2:v]setpts=PTS-STARTPTS+7739.299/TB,scale=320x240[1c];
[5:v]setpts=PTS-STARTPTS+4390.466/TB,scale=320x240[4a];
[6:v]setpts=PTS-STARTPTS+6803.937/TB,scale=320x240[4b];
[7:v]setpts=PTS-STARTPTS+8242.005/TB,scale=320x240[4c];
[8:v]setpts=PTS-STARTPTS+9811.577/TB,scale=320x240[4d];
[9:v]setpts=PTS-STARTPTS+10765.19/TB,scale=320x240[4e];
[base][1a]overlay=eof_action=pass[o1];
[o1][1b]overlay=eof_action=pass[o1];
[o1][1c]overlay=eof_action=pass:shortest=1[o1];
[o1][4a]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4b]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4c]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4d]overlay=eof_action=pass:x=320:y=240[o4];
[o4][4e]overlay=eof_action=pass:x=320:y=240
-filter_complex
[0:a]asetpts=PTS-STARTPTS+0.12/TB,aresample=async=1,pan=1c|c0=c0,apad[a1a];
[1:a]asetpts=PTS-STARTPTS+3469.115/TB,aresample=async=1,pan=1c|c0=c0,apad[a1b];
[2:a]asetpts=PTS-STARTPTS+7739.299/TB,aresample=async=1,pan=1c|c0=c0[a1c];
[3:a]asetpts=PTS-STARTPTS+82.55/TB,aresample=async=1,pan=1c|c0=c0,apad[a2a];
[4:a]asetpts=PTS-STARTPTS+2687.265/TB,aresample=async=1,pan=1c|c0=c0,apad[a3a];
[a1a][a1b][a1c][a2a][a3a]amerge=inputs=5
-c:v libx264 -c:a aac -ac 2 output.mp4
I am trying to convert raw video file captured from Cisco EX60 to valid MP4 file.
I use the following command
ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 25 -i input2 -vcodec libx264 output2.mp4
and get
libpostproc 54. 0.100 / 54. 0.100
[rawvideo # 0000000000703920] Estimating duration from bitrate, this may be inac
curate
Input #0, rawvideo, from 'input2':
Duration: 00:00:00.20, start: 0.000000, bitrate: 630883 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 622080
kb/s, 25 tbr, 25 tbn, 25 tbc
File 'output2.mp4' already exists. Overwrite ? [y/N] y
[libx264 # 00000000007115e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 00000000007115e0] profile High, level 4.0
[libx264 # 00000000007115e0] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=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_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=3 b_pyramid=2 b_
adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2
5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.6
0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output2.mp4':
Metadata:
encoder : Lavf57.18.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1
080, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.15.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[rawvideo # 00000000007101c0] ****Invalid buffer size, packet size 220075 < expected
frame_size 3110400
Error while decoding stream #0:0: Invalid argument****
frame= 5 fps=2.5 q=-1.0 Lsize= 6514kB time=00:00:00.12 bitrate=444706.9kbi
ts/s
video:6513kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 0.013209%
[libx264 # 00000000007115e0] frame I:1 Avg QP:35.99 size:1334571
[libx264 # 00000000007115e0] frame P:4 Avg QP:35.00 size:1333616
[libx264 # 00000000007115e0] mb I I16..4: 0.0% 0.0% 100.0%
[libx264 # 00000000007115e0] mb P I16..4: 98.7% 0.0% 1.3% P16..4: 0.0% 0.0
% 0.0% 0.0% 0.0% skip: 0.0%
with
Invalid buffer size, packet size 220075 < expected
frame_size 3110400
Error while decoding stream #0:0: Invalid argument**
inside
When I use just
ffmpeg -f h264 -i input -vcodec copy -r 25 outfile.mp4
It replace initial IFrame with B-frames so I cannot playback it. I can view it with VCL, but not with Windows Media player, for example.
What is wrong with the command?
Thanks
Efim
Stream #0:0: Video: h264 (libx264)
This is the source video stream, which is already encoded with h264. So it’s unlikely that rawvideo will work. You actually have to decode the stream in order to encode it again.
As for why you can’t play it back in Windows Media Player, please check the H.264 encoding guide. By default the highest profile is used when encoding as h264 which is not compatible with every device and player. For maximum compatibility, add the following options:
-profile:v baseline -level 3.0
Sometimes it works great and sometimes I'm getting this message
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
by running this command
ffmpeg -i a1.mp4 -i watermark150x125.png -filter_complex 'overlay=10:10' output.mp4
I tried different variation of "overlay" like overlay=W-w-5:H-h-5, overlay=10:main_h-overlay_h-10, overlay=main_w-overlay_w-10:main_h-overlay_h-10 - getting the same result.
Here is the output of the ffmpeg command.
ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7f952101d200] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
artist : a1
album :
comment :
date : 0
genre :
title : a1
encoder : Lavf56.4.101
Duration: 00:01:41.51, start: 0.000000, bitrate: 227 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 426x240 [SAR 1:1 DAR 71:40], 97 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 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
Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 120x90 [SAR 1:1 DAR 4:3], 90k tbr, 90k tbn, 90k tbc
Input #1, png_pipe, from 'watermark150x125.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba, 150x125 [SAR 2835:2835 DAR 6:5], 25 tbr, 25 tbn, 25 tbc
[swscaler # 0x7f9521013e00] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x7f9521030e00] using SAR=1/1
[libx264 # 0x7f9521030e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x7f9521030e00] profile High, level 2.1
[libx264 # 0x7f9521030e00] 264 - core 144 r2533 c8a773e - 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
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
artist : a1
album :
comment :
date : 0
genre :
title : a1
encoder : Lavf56.25.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 426x240 [SAR 1:1 DAR 71:40], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc56.26.100 libx264
Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc56.26.100 libvo_aacenc
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #0:2 (mjpeg) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
Last message repeated 385 times
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
Last message repeated 564 times
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
Last message repeated 546 times
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
Last message repeated 569 times
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
Last message repeated 593 times
[Parsed_overlay_0 # 0x7f9520518800] [framesync # 0x7f9521021e28] Buffer queue overflow, dropping.
Last message repeated 312 times
frame= 3041 fps=645 q=-1.0 Lsize= 1800kB time=00:01:41.52 bitrate= 145.3kbits/s dup=2975 drop=0
video:149kB audio:1587kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.700745%
[libx264 # 0x7f9521030e00] frame I:14 Avg QP:19.91 size: 6947
[libx264 # 0x7f9521030e00] frame P:768 Avg QP:10.30 size: 27
[libx264 # 0x7f9521030e00] frame B:2259 Avg QP:13.67 size: 15
[libx264 # 0x7f9521030e00] consecutive B-frames: 0.9% 0.1% 0.1% 98.9%
[libx264 # 0x7f9521030e00] mb I I16..4: 18.7% 59.0% 22.3%
[libx264 # 0x7f9521030e00] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.1% 0.0% 0.0% 0.0% 0.0% skip:99.9%
[libx264 # 0x7f9521030e00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0:50.7% L1:49.3% BI: 0.0%
[libx264 # 0x7f9521030e00] 8x8 transform intra:59.1% inter:31.9%
[libx264 # 0x7f9521030e00] coded y,uvDC,uvAC intra: 21.4% 12.4% 7.4% inter: 0.0% 0.0% 0.0%
[libx264 # 0x7f9521030e00] i16 v,h,dc,p: 39% 30% 30% 0%
[libx264 # 0x7f9521030e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 47% 16% 1% 0% 0% 1% 0% 1%
[libx264 # 0x7f9521030e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 38% 15% 3% 3% 3% 6% 4% 7%
[libx264 # 0x7f9521030e00] i8c dc,h,v,p: 80% 15% 4% 1%
[libx264 # 0x7f9521030e00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7f9521030e00] ref P L0: 96.5% 1.2% 2.3%
[libx264 # 0x7f9521030e00] ref B L0: 51.5% 48.5%
[libx264 # 0x7f9521030e00] ref B L1: 99.6% 0.4%
[libx264 # 0x7f9521030e00] kb/s:11.97
I only got errors with videos that didn't have libx264 codec.
So, after adding ffmpeg -i a1.mp4 -vcodec libx264 -crf 0 newa1.mp4 - everything starts working fine.