I am trying to convert a .mpg to .flv with ffmpeg. On other servers I got it working but here with the ffmpeg clone (avconv) it just does not do it.
Originally I was working with libfaac and preset fastfirstpass but thats not available in this build so I switched to the experimental acc and preset libx264-fast_firstpass:
$ /usr/bin/ffmpeg -i /data/upload/videos/original/150128_Test_731_9d5b83.mpg
-strict experimental -acodec aac -ab 128k -ar 44100 -vcodec libx264 -pass 1
-pre libx264-fast_firstpass -b 512k -s 360x204
-f flv /data/upload/videos/encoded/150129_Test_731_54f06a.flv
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mpeg # 0xc87de0] max_analyze_duration reached
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mpeg, from '/data/upload/videos/original/150128_Test_731_9d5b83.mpg':
Duration: 00:01:00.12, start: 0.989978, bitrate: 4814 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x406 [PAR 406:405 DAR 16:9], 104857 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 224 kb/s
[libx264 # 0xc8b4c0] using SAR=136/135
[libx264 # 0xc8b4c0] MB rate (26910000) > level limit (2073600)
[libx264 # 0xc8b4c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 # 0xc8b4c0] profile Main, level 5.2
[libx264 # 0xc8b4c0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=abr mbtree=1 bitrate=512 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Option preset not found.
What does the error in the last line mean?
I already made sure the preset libx264-fast_firstpass.avpreset exists in /usr/share/avconv/ and if I change it to invalid ffmpeg complains with Preset invalid specified for stream 0:0, but could not be opened., so the preset is correct.
Google does provide two results for this error. This chatlog and it's pastebin about live streaming with the solution to add -f flv and some russian page. Nothing helped.
Any advice?
I had a look ìnto this preset file /usr/share/avconv/libx264-fast_firstpass and there I found this wrong "preset" option. I delete it and now it works.
Related
I use release: 4.2.2 (static) from "https://johnvansickle.com/ffmpeg/"
Final code will be on "Amazon AWS lambda"
Goal: use a url stream and add watermak
Link to video: https://feoval.fr/519.mp4
Link to Watermak: https://feoval.fr/watermark.png
./ffmpeg -i "https://feoval.fr/519.mp4" -i "./watermark.png" -filter_complex "overlay=W-w-10:H-h-10:format=rgb" -f "mp4" -movflags "frag_keyframe+empty_moov" -pix_fmt "yuv420p" test.mp4
return "Segmentation fault"
I have the same error on my computer and on AWS Lambda server
./ffmpeg -i "https://feoval.fr/519.mp4" -f "mp4" -movflags "frag_keyframe+empty_moov" -pix_fmt "yuv420p" test.mp4
work (but not watermak)
./ffmpeg -i "./519.mp4" -i "./watermark.png" -filter_complex "overlay=W-w-10:H-h-10:format=rgb" -f "mp4" -movflags "frag_keyframe+empty_moov" -pix_fmt "yuv420p" test.mp4
work (but not with stream)
Thanks you very much !
Logs for the first case who return "Segmentation fault":
...
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #1:0 (png) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, ? for help
[libx264 # 0x742e480] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x742e480] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x742e480] 264 - core 159 r2991 1771b55 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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
Output #0, mp4, to 'test.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: isommp41mp42
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 480x848, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.54.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), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-01-13T08:54:26.000000Z
handler_name : Core Media Audio
encoder : Lavc58.54.100 aac
Segmentation fault (core dumped)
According to readme.txt that is packaged with the build from johnvansickle.com:
A limitation of statically linking glibc is the loss of DNS
resolution. Installing nscd through your package manager will fix
this.
Solution is to install and start the nscd service.
Alternative solutions:
Compile (see tutorials) your own ffmpeg (during ./configure enable gnutls, openssl, libtls or mbedtls for HTTPS support).
Use ffmpeg from your repository
Download the input file before using it in ffmpeg
Use IP address instead of domain name
I want to merge two images (names are not numbered in a sequence) to a video, but the result includes only a video of the first image.
I would appreciate any kind of help!
ffmpeg.exe -r 1/5 -i image_x.png -r 1/5 -i image_y.png -codec:v libx264 -vf fps=50 video.mp4
Output:
Input #0, png_pipe, from
'C:\Users\khj\Desktop\SpeakerLayoutTool\Images_video\iamge_x.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 3840x2160, 25 tbr, 25 tbn, 25 tbc Input #1, png_pipe, from
'C:\Users\khj\Desktop\SpeakerLayoutTool\Images_video\image_y.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 3840x2160, 25 tbr, 25 tbn, 25 tbc File 'C:\Users\khj\Desktop\SpeakerLayoutTool\video.mp4' already
exists. Overwrite ? [y/N] y Stream mapping: Stream #0:0 -> #0:0 (png
(native) -> h264 (libx264)) Press [q] to stop, [?] for help [libx264 #
0000016c2a46e000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2 [libx264 # 0000016c2a46e000] profile High 4:4:4
Predictive, level 5.2, 4:4:4, 8-bit [libx264 # 0000016c2a46e000] 264 -
core 157 r2970 5493be8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 -
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=4 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 Output #0, mp4, to
'C:\Users\khj\Desktop\SpeakerLayoutTool\video.mp4': Metadata:
encoder : Lavf58.27.103
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 3840x2160, q=-1--1, 50 fps, 12800 tbn, 50 tbc
Metadata:
encoder : Lavc58.52.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 frame= 250 fps= 22 q=-1.0 Lsize= 162kB time=00:00:04.94 bitrate=
268.1kbits/s speed=0.444x
Use
ffmpeg.exe -loop 1 -t 5 -i image_x.png -loop 1 -t 5 -i image_y.png -filter_complex "concat=n=2:v=1:a=0" -pix_fmt yuv420p -c:v libx264 video.mp4
My goal is to compress video making it's bitrate lower.
For experiment I used following command
ffmpeg -ss 00:00:00 -i V.mkv -to 00:10:00 -c:a copy -b:v 7500k -maxrate 7500k -minrate 5500k -bufsize 1M V7500.mkv
1. What are possible reasons speed of conversion was close to 1.0x utilizing all 8 cores?
2. Bitrate of output video stream is about 4700 (5500 was set as minrate). Is there proper way to specify bitrate?
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 # 0x55e54ad189a0] using SAR=1/1
[libx264 # 0x55e54ad189a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x55e54ad189a0] profile High, level 4.0
[libx264 # 0x55e54ad189a0] 264 - core 152 r2854 e9a5903 - 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=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=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=7500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=7500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'V7500.mkv':
Metadata:
title : Valerian.and.the.City.of.a.Thousand.Planets.2017.1080p.BluRay.x264.DTS-HD.MA.7.1-FGT
encoder : Lavf57.83.100
Chapter #0:0: start 0.000000, end 600.000000
Metadata:
title : Chapter 01
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x804 [SAR 1:1 DAR 160:67], q=-1--1, 7500 kb/s, 23.98 fps, 1k tbn, 23.98 tbc (default)
Metadata:
title : Valerian.and.the.City.of.a.Thousand.Planets.2017.1080p.BluRay.x264.DTS-HD.MA.7.1-FGT
DURATION : 02:17:03.277000000
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 7500000/0/7500000 buffer size: 1000000 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp (default)
Metadata:
title : Valerian.and.the.City.of.a.Thousand.Planets.2017.1080p.BluRay.x264.DTS-HD.MA.7.1-FGT
ENCODER : Lavc57.107.100 aac
DURATION : 02:17:03.317000000
Past duration 0.994987 too large
frame=14385 fps= 31 q=-1.0 Lsize= 363641kB time=00:09:59.99 bitrate=4964.9kbits/s speed=1.28x
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
In Ubuntu 12.04 LTS I have used -movflags frag_keyframe+empty_moov in my ffmpeg command:
ffmpeg -i http://filesbe.vocativ.internal.net/03/44/SN/q1/xg/xl/0344SNq1xgxl.flv \
-crf 32.0 -g 250 -keyint_min 25 -aspect 4:3 -movflags frag_keyframe -vcodec \
libx264 -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 128k -map 0:0 \
-map 0:1 -f flv -y test.flv
ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Apr 2 2013 17:02:36 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[flv # 0x10569a0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'http://filesbe.vocativ.internal.net/03/44/SN/q1/xg/xl/0344SNq1xgxl.flv':
Metadata:
starttime : 0
totalduration : 64
totaldatarate : 710
bytelength : 5674798
canseekontime : true
sourcedata : BADC23401MH1326550770698632
purl :
pmsg :
Duration: 00:01:03.96, start: 0.000000, bitrate: 718 kb/s
Stream #0.0: Video: h264 (Main), yuv420p, 854x480, 590 kb/s, 25 tbr, 1k tbn, 50 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
[buffer # 0x105c600] w:854 h:480 pixfmt:yuv420p
[movie # 0x105c440] seek_point:0 format_name:(null) file_name:/home/assetproxy/htdocs/transcoder/helper_asset/voca_scaled.png stream_index:0
[overlay # 0x1060840] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed filter 0 movie' and the filter 'Parsed filter 1 overlay'
[scale # 0x11d8300] w:90 h:51 fmt:rgb24 -> w:90 h:51 fmt:yuva420p flags:0x4
[overlay # 0x1060840] main w:854 h:480 fmt:yuv420p overlay x:754 y:419 w:90 h:51 fmt:yuva420p
[overlay # 0x1060840] main_tb:1/1000000 overlay_tb:1/25 -> tb:1/1000000 exact:1
[libx264 # 0x1059d20] using SAR=191/255
[libx264 # 0x1059d20] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 # 0x1059d20] profile Main, level 3.0
[libx264 # 0x1059d20] 264 - core 120 r2151 a3f4407 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1 b_bias=0 direct=1 weightb=0 open_gop=1 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=32.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00
Option movflags not found.
First of all you're not actually using ffmpeg from FFmpeg, but an old and outdated version from a fork which does not have the -movflags option. You will need to update your ffmpeg: you can simply download a Linux build of ffmpeg (see detailed instructions), or you can follow a step-by-step guide to compile ffmpeg on Ubuntu.
Also see:
Who can tell me the difference and relation between ffmpeg, libav, and avconv?
FFmpeg and x264 Encoding Guide
FFmpeg and AAC Encoding Guide