
Recherche avancée
Médias (1)
-
The Great Big Beautiful Tomorrow
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
Autres articles (80)
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)
Sur d’autres sites (4306)
-
OpenCV VideoWriter using ffmpeg with "Could not open codec 'libx264'" Error
19 avril, par user2262504I am new to OpenCV, and I want write Mat images into video using VideoWriter on Ubuntu 12.04. But when constructing VideoWriter, errors came out.



It seems that OpenCV invoke ffmpeg API using default parameters and ffmpeg invoke x264 using its default parameters. Then these setting is broken for libx264. Thus the "Could not open codec 'libx264'" error.



Anyone has ideas to solve this problem ?



More specifically :



- 

- anyone knows where and how OpenCV invoke ffmpeg API ?
- how to change ffmpeg default settings using code, hopefull, can be easily embeded into OpenCV ?
- will changes of default in ffmpeg be carried to libx264 ?









Errors :



1. Uising CV_FOURCC('H', '2', '6', '4')
[libx264 @ 0x255de40] broken ffmpeg default settings detected
[libx264 @ 0x255de40] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x255de40] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x255de40] speed presets are listed in x264 --help
[libx264 @ 0x255de40] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified error

2. Using FOURCC = -1 to invoke user customized codec
OpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv 
backend doesn't support this codec acutally.) in CvVideoWriter_GStreamer::open, 
file /home/XXX/Downloads/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp, 
line 505 terminate called after throwing an instance of 'cv::Exception'
what(): /home/XXX/Downloads/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp:
505: error: (-210) Gstreamer Opencv backend doesn't support this codec acutally.
in function CvVideoWriter_GStreamer::open
</profile></speed>



Codes :



int main(int argc, char *argv[])
{
 VideoWriter outputVideo;
 bool fourcc_on = true; //switch on / off different error
 if (fourcc_on)
 outputVideo.open("outVideo.avi", CV_FOURCC('H', '2', '6', '4'), 25, Size(100, 100), true);
 else
 outputVideo.open("outVideo.avi", -1, 25, Size(100, 100), true);

 if (!outputVideo.isOpened())
 {
 cout << "Could not open the output video for write" << endl;
 return -1;
 }
 return 0;
}




OpenCV Configuration :



-- Detected version of GNU GCC: 46 (406)
-- Found OpenEXR: /usr/lib/libIlmImf.so
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
-- 
-- General configuration for OpenCV 2.4.8 =====================================
-- Version control: unknown
-- 
-- Platform:
-- Host: Linux 3.8.0-38-generic x86_64
-- CMake: 2.8.7
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
-- 
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/bin/c++ (ver 4.6)
-- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/gcc
-- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): 
-- Linker flags (Debug): 
-- Precompiled headers: YES
-- 
-- OpenCV modules:
-- To be built: core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib python stitching superres ts videostab
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: androidcamera dynamicuda java
-- 
-- GUI: 
-- QT: NO
-- GTK+ 2.x: YES (ver 2.24.10)
-- GThread : YES (ver 2.32.4)
-- GtkGlExt: NO
-- OpenGL support: NO
-- 
-- Media I/O: 
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.3.4)
-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.46)
-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 3.9.5)
-- JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
-- OpenEXR: /usr/lib/libImath.so /usr/lib/libIlmImf.so /usr/lib/libIex.so /usr/lib/libHalf.so /usr/lib/libIlmThread.so (ver 1.6.1)
-- 
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES (ver 2.2.0)
-- FFMPEG: YES
-- codec: YES (ver 55.58.105)
-- format: YES (ver 55.37.101)
-- util: YES (ver 52.78.100)
-- swscale: YES (ver 2.6.100)
-- gentoo-style: YES
-- GStreamer: 
-- base: YES (ver 0.10.36)
-- app: YES (ver 0.10.36)
-- video: YES (ver 0.10.36)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l (ver 1.0.1)
-- XIMEA: NO
-- Xine: NO
-- 
-- Other third-party libraries:
-- Use IPP: NO
-- Use Eigen: NO
-- Use TBB: NO
-- Use OpenMP: NO
-- Use GCD NO
-- Use Concurrency NO
-- Use C=: NO
-- Use Cuda: NO
-- Use OpenCL: YES
-- 
-- OpenCL:
-- Version: dynamic
-- Include path: /home/shixudongleo/Downloads/opencv-2.4.8/3rdparty/include/opencl/1.2
-- Use AMD FFT: NO
-- Use AMD BLAS: NO
-- 
-- Python:
-- Interpreter: /usr/bin/python (ver 2.7.3)
-- Libraries: /usr/lib/libpython2.7.so
-- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.6.1)
-- packages path: lib/python2.7/dist-packages
-- 
-- Java:
-- ant: NO
-- JNI: NO
-- Java tests: NO
-- 
-- Documentation:
-- Build Documentation: NO
-- Sphinx: NO
-- PdfLaTeX compiler: /usr/bin/pdflatex
-- 
-- Tests and samples:
-- Tests: YES
-- Performance tests: YES
-- C/C++ Examples: NO
-- 
-- Install path: /usr/local
-- 
-- cvconfig.h is in: /home/shixudongleo/Downloads/opencv-2.4.8/build
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/XXX/Downloads/opencv-2.4.8/build




FFMPEG



ffmpeg is enable to support OpenCV and libx264 is enabled when compiling ffmpeg.
By using ffmpeg command line, libx264 is running normally.



$ ffmpeg -i test.avi -vcodec libx264 test.mp4
ffmpeg -i test.avi -vcodec libx264 test.mp4 > ~/Downloads/ffmpeg_log.txt
ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
 built on Apr 24 2014 16:39:51 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
 configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared --enable-pic
 libavutil 52. 78.100 / 52. 78.100
 libavcodec 55. 58.105 / 55. 58.105
 libavformat 55. 37.101 / 55. 37.101
 libavdevice 55. 13.100 / 55. 13.100
 libavfilter 4. 4.100 / 4. 4.100
 libswscale 2. 6.100 / 2. 6.100
 libswresample 0. 18.100 / 0. 18.100
 libpostproc 52. 3.100 / 52. 3.100
Input #0, avi, from 'test.avi':
 Duration: 00:00:03.73, start: 0.000000, bitrate: 1757 kb/s
 Stream #0:0: Video: msvideo1 (CRAM / 0x4D415243), rgb555le, 320x240, 1781 kb/s, 15 tbr, 15 tbn, 15 tbc
 Metadata:
 title : julius.avi Video #1
File 'test.mp4' already exists. Overwrite ? [y/N] y
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x25d08e0] using cpu capabilities: none!
[libx264 @ 0x25d08e0] profile High 4:4:4 Predictive, level 1.2, 4:4:4 8-bit
[libx264 @ 0x25d08e0] 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=4 threads=12 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=15 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:
 encoder : Lavf55.37.101
 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 320x240, q=-1--1, 15360 tbn, 15 tbc
 Metadata:
 title : julius.avi Video #1
Stream mapping:
 Stream #0:0 -> #0:0 (msvideo1 -> libx264)
Press [q] to stop, [?] for help
frame= 56 fps=0.0 q=-1.0 Lsize= 321kB time=00:00:03.60 bitrate= 731.0kbits/s 
video:320kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.409949%
[libx264 @ 0x25d08e0] frame I:3 Avg QP:15.36 size: 7975
[libx264 @ 0x25d08e0] frame P:38 Avg QP:26.05 size: 6230
[libx264 @ 0x25d08e0] frame B:15 Avg QP:28.25 size: 4418
[libx264 @ 0x25d08e0] consecutive B-frames: 46.4% 53.6% 0.0% 0.0%
[libx264 @ 0x25d08e0] mb I I16..4: 1.4% 72.8% 25.8%
[libx264 @ 0x25d08e0] mb P I16..4: 1.6% 5.7% 15.1% P16..4: 7.6% 6.3% 7.4% 0.0% 0.0% skip:56.3%
[libx264 @ 0x25d08e0] mb B I16..4: 0.2% 1.0% 2.0% B16..8: 13.3% 7.8% 8.7% direct: 8.3% skip:58.8% L0:34.9% L1:36.6% BI:28.5%
[libx264 @ 0x25d08e0] 8x8 transform intra:37.7% inter:2.3%
[libx264 @ 0x25d08e0] coded y,u,v intra: 52.1% 42.1% 30.1% inter: 19.6% 9.2% 5.2%
[libx264 @ 0x25d08e0] i16 v,h,dc,p: 56% 17% 24% 2%
[libx264 @ 0x25d08e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 16% 68% 1% 1% 1% 1% 1% 1%
[libx264 @ 0x25d08e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 18% 28% 5% 6% 5% 7% 5% 6%
[libx264 @ 0x25d08e0] Weighted P-Frames: Y:31.6% UV:21.1%
[libx264 @ 0x25d08e0] ref P L0: 70.5% 9.0% 12.1% 6.5% 2.0%
[libx264 @ 0x25d08e0] ref B L0: 91.3% 8.7%
[libx264 @ 0x25d08e0] kb/s:700.56



-
ffmpeg says : "option framerate not found"
29 novembre 2018, par JasonGood afternoon.
I’ve been trying to use ffmpeg to split a .mpeg into a sequence of .jpeg images. Please note that this is the inverse problem of the one specified here, but the problem I’m facing is not the same as the problem the author of that thread is facing.
Specifically, I have tried all the following mpeg codecs available in my ffmpeg installation :
DEV D ffv1 FFmpeg video codec #1
DEVSD ffvhuff Huffyuv FFmpeg variant
DEVSDT mpeg1video MPEG-1 video
D V DT mpeg1video_vdpau MPEG-1 video (VDPAU acceleration)
D V D mpeg2_crystalhd MPEG-2 Video (CrystalHD acceleration)
DEVSDT mpeg2video MPEG-2 video
DEVSDT mpeg4 MPEG-4 part 2
D V D mpeg4_crystalhd MPEG-4 Part 2 (CrystalHD acceleration)
D V DT mpeg4_vdpau MPEG-4 part 2 (VDPAU)
D VSDT mpegvideo MPEG-1 video
D V DT mpegvideo_vdpau MPEG-1/2 video (VDPAU acceleration)
D VSDT mpegvideo_xvmc MPEG-1/2 video XvMC (X-Video Motion Compensation)
DEVSD msmpeg4 MPEG-4 part 2 Microsoft variant version 3
D V D msmpeg4_crystalhd MPEG-4 Part 2 Microsoft variant version 3 (CrystalHD acceleration)
D VSD msmpeg4v1 MPEG-4 part 2 Microsoft variant version 1
DEVSD msmpeg4v2 MPEG-4 part 2 Microsoft variant version 2I’ve tried supplying ffmpeg with all different codecs to try to split an input .mpeg video file with 2548 frames into 2548 .jpegs, by using the -vcodec option :
ffmpeg -r 2548 -i frames.mpeg frames_%06d.jpg -vcodec $codec
where
$codec
is any codec among the ones listed above, e.g.ffv1
,mpeg4
, etc. However, all my efforts result in the following error :[NULL @ 0x1948f20] Value 4707126720094797824.000000 for parameter 'probesize' out of range
[NULL @ 0x1948f20] Value 4707126720094797824.000000 for parameter 'analyzeduration' out of range
[NULL @ 0x1948f20] Value 4697254411347427328.000000 for parameter 'indexmem' out of range
[NULL @ 0x1948f20] Value 4703785510416416768.000000 for parameter 'rtbufsize' out of range
[NULL @ 0x1948f20] Value -4616189618054758400.000000 for parameter 'fpsprobesize' out of range
[NULL @ 0x1948f20] Value 4607182418800017408.000000 for parameter 'f_err_detect' out of range
[NULL @ 0x1948f20] Value 4607182418800017408.000000 for parameter 'err_detect' out of range
Option framerate not found.Which is weird, because I’ve actually specified the frame rate parameter through the -r switch. I googled a bit and it appears that this error was mentioned approximately a year and a half ago on the ffmpeg bug tracker but that information makes little sense to me because it’s relevant to the devs. Curiously, if I interchange the position of the parameters and put -r after -i or even after -vcodec, the error message changes to :
[NULL @ 0x24abf20] Value 4707126720094797824.000000 for parameter 'probesize' out of range
[NULL @ 0x24abf20] Value 4707126720094797824.000000 for parameter 'analyzeduration' out of range
[NULL @ 0x24abf20] Value 4697254411347427328.000000 for parameter 'indexmem' out of range
[NULL @ 0x24abf20] Value 4703785510416416768.000000 for parameter 'rtbufsize' out of range
[NULL @ 0x24abf20] Value -4616189618054758400.000000 for parameter 'fpsprobesize' out of range
[NULL @ 0x24abf20] Value 4607182418800017408.000000 for parameter 'f_err_detect' out of range
[NULL @ 0x24abf20] Value 4607182418800017408.000000 for parameter 'err_detect' out of range
[NULL @ 0x24b23c0] Value 4686111960511545344.000000 for parameter 'b' out of range
[NULL @ 0x24b23c0] Value 4683532506232782848.000000 for parameter 'ab' out of range
[NULL @ 0x24b23c0] Value 4705844345939427328.000000 for parameter 'bt' out of range
[NULL @ 0x24b23c0] Value 4617315517961601024.000000 for parameter 'me_method' out of range
[NULL @ 0x24b23c0] Value 4622945017495814144.000000 for parameter 'g' out of range
[NULL @ 0x24b23c0] Value 4611686018427387904.000000 for parameter 'qmin' out of range
[NULL @ 0x24b23c0] Value 4629418941960159232.000000 for parameter 'qmax' out of range
[NULL @ 0x24b23c0] Value 4613937818241073152.000000 for parameter 'qdiff' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'wpredp' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'bug' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'er' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'err_detect' out of range
[NULL @ 0x24b23c0] Value 4613937818241073152.000000 for parameter 'ec' out of range
[NULL @ 0x24b23c0] Value 4620693217682128896.000000 for parameter 'ildctcmp' out of range
[NULL @ 0x24b23c0] Value 4620693217682128896.000000 for parameter 'subq' out of range
[NULL @ 0x24b23c0] Value 4696837138094751744.000000 for parameter 'ibias' out of range
[NULL @ 0x24b23c0] Value 4696837138094751744.000000 for parameter 'pbias' out of range
[NULL @ 0x24b23c0] Value 4642507528377204736.000000 for parameter 'lmin' out of range
[NULL @ 0x24b23c0] Value 4660262442142531584.000000 for parameter 'lmax' out of range
[NULL @ 0x24b23c0] Value 4696130710463840256.000000 for parameter 'flags2' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'threads' out of range
[NULL @ 0x24b23c0] Value 4620693217682128896.000000 for parameter 'nssew' out of range
[NULL @ 0x24b23c0] Value -4586705114244317184.000000 for parameter 'profile' out of range
[NULL @ 0x24b23c0] Value -4586705114244317184.000000 for parameter 'level' out of range
[NULL @ 0x24b23c0] Value 4623507967449235456.000000 for parameter 'skipcmp' out of range
[NULL @ 0x24b23c0] Value 4642507528377204736.000000 for parameter 'mblmin' out of range
[NULL @ 0x24b23c0] Value 4660262442142531584.000000 for parameter 'mblmax' out of range
[NULL @ 0x24b23c0] Value 4643211215818981376.000000 for parameter 'mepc' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'bidir_refine' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'cqp' out of range
[NULL @ 0x24b23c0] Value 4627730092099895296.000000 for parameter 'keyint_min' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'refs' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'directpred' out of range
[NULL @ 0x24b23c0] Value 4618441417868443648.000000 for parameter 'sc_factor' out of range
[NULL @ 0x24b23c0] Value 4643211215818981376.000000 for parameter 'mv0_threshold' out of range
[NULL @ 0x24b23c0] Value 4630826316843712512.000000 for parameter 'b_sensitivity' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'compression_level' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'min_prediction_order' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'max_prediction_order' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'prediction_order_method' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'min_partition_order' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'max_partition_order' out of range
[NULL @ 0x24b23c0] Value 4607182418800017408.000000 for parameter 'ticks_per_frame' out of range
[NULL @ 0x24b23c0] Value 4611686018427387904.000000 for parameter 'color_primaries' out of range
[NULL @ 0x24b23c0] Value 4611686018427387904.000000 for parameter 'color_trc' out of range
[NULL @ 0x24b23c0] Value 4611686018427387904.000000 for parameter 'colorspace' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'aq_mode' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'rc_lookahead' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'lpc_type' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'lpc_passes' out of range
[NULL @ 0x24b23c0] Value 4613937818241073152.000000 for parameter 'thread_type' out of range
[NULL @ 0x24b23c0] Value -4616189618054758400.000000 for parameter 'request_sample_fmt' out of range
frames.mpeg: could not find codec parametersI’m at a loss as to what to do with this problem, and am looking for some assistance.
Kind regards,
Jason
-
ffmpeg convert to webm error "too many invisible frames"
24 janvier 2019, par Вадим КоломиецI need to convert any format (for example, mp4, avi etc) to .webm with own ioContext. I build ffmpeg with vpx, ogg, vorbis, opus and create simple project. But when i write any frame i get error "Too many invisible frames. Failed to send packet to filter vp9_superframe for stream 0"
I’ve already tried convert from webm to webm with copy codec params with avcodec_parameters_copy and this works.
#include <qcoreapplication>
#include <qfileinfo>
#include <iostream>
#include <fstream>
extern "C" {
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>timestamp.h>
#include <libavformat></libavformat>avformat.h>
#include <libavfilter></libavfilter>buffersink.h>
#include <libavfilter></libavfilter>buffersrc.h>
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>pixdesc.h>
}
using namespace std;
struct BufferData {
QByteArray data;
uint fullsize;
BufferData() {
fullsize =0;
}
};
static int write_packet_to_buffer(void *opaque, uint8_t *buf, int buf_size) {
BufferData *bufferData = static_cast(opaque);
bufferData->fullsize += buf_size;
bufferData->data.append((const char*)buf, buf_size);
return buf_size;
}
static bool writeBuffer(const QString &filename, BufferData *bufferData) {
QFile file(filename);
if( !file.open(QIODevice::WriteOnly) ) return false;
file.write(bufferData->data);
qDebug()<<"FILE SIZE = " << file.size();
file.close();
return true;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
AVOutputFormat *ofmt = NULL;
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
AVPacket pkt;
int ret;
int stream_index = 0;
int *stream_mapping = NULL;
int stream_mapping_size = 0;
const char *in_filename = "../assets/sample.mp4";
const char *out_filename = "../assets/sample_new.webm";
//------------------------ Input file ----------------------------
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
fprintf(stderr, "Could not open input file '%s'", in_filename);
return 1;
}
if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) {
fprintf(stderr, "Failed to retrieve input stream information");
return 1;
}
av_dump_format(ifmt_ctx, 0, in_filename, 0);
//-----------------------------------------------------------------
//---------------------- BUFFER -------------------------
AVIOContext *avio_ctx = NULL;
uint8_t *avio_ctx_buffer = NULL;
size_t avio_ctx_buffer_size = 4096*1024;
const size_t bd_buf_size = 1024*1024;
/* fill opaque structure used by the AVIOContext write callback */
avio_ctx_buffer = (uint8_t*)av_malloc(avio_ctx_buffer_size);
if (!avio_ctx_buffer) return AVERROR(ENOMEM);
BufferData bufferData;
avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,
1, &bufferData, NULL,
&write_packet_to_buffer, NULL);
if (!avio_ctx) return AVERROR(ENOMEM);
//------------------------------------------------------
avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename);
if (!ofmt_ctx) {
fprintf(stderr, "Could not create output context\n");
ret = AVERROR_UNKNOWN;
return 1;
}
//------------------------ Stream list ----------------------------
stream_mapping_size = ifmt_ctx->nb_streams;
stream_mapping = (int*)av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
if (!stream_mapping) {
ret = AVERROR(ENOMEM);
return 1;
}
//-------------------------------------------------------------------
//------------------------ Output file ----------------------------
AVCodec *encoder;
AVCodecContext *input_ctx;
AVCodecContext *enc_ctx;
for (int i=0; i < ifmt_ctx->nb_streams; i++) {
AVStream *out_stream;
AVStream *in_stream = ifmt_ctx->streams[i];
AVCodecParameters *in_codecpar = in_stream->codecpar;
if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO &&
in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO &&
in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
stream_mapping[i] = -1;
continue;
}
enc_ctx = avcodec_alloc_context3(encoder);
if (!enc_ctx) {
av_log(NULL, AV_LOG_FATAL, "Failed to allocate the encoder context\n");
return AVERROR(ENOMEM);
}
stream_mapping[i] = stream_index++;
out_stream = avformat_new_stream(ofmt_ctx, NULL);
if (!out_stream) {
fprintf(stderr, "Failed allocating output stream\n");
ret = AVERROR_UNKNOWN;
return 1;
}
out_stream->codecpar->width = in_codecpar->width;
out_stream->codecpar->height = in_codecpar->height;
out_stream->codecpar->level = in_codecpar->level;
out_stream->codecpar->format =in_codecpar->format;
out_stream->codecpar->profile =in_codecpar->profile;
out_stream->codecpar->bit_rate =in_codecpar->bit_rate;
out_stream->codecpar->channels =in_codecpar->channels;
out_stream->codecpar->codec_tag = 0;
out_stream->codecpar->color_trc =in_codecpar->color_trc;
out_stream->codecpar->codec_type =in_codecpar->codec_type;
out_stream->codecpar->frame_size =in_codecpar->frame_size;
out_stream->codecpar->block_align =in_codecpar->block_align;
out_stream->codecpar->color_range =in_codecpar->color_range;
out_stream->codecpar->color_space =in_codecpar->color_space;
out_stream->codecpar->field_order =in_codecpar->field_order;
out_stream->codecpar->sample_rate =in_codecpar->sample_rate;
out_stream->codecpar->video_delay =in_codecpar->video_delay;
out_stream->codecpar->seek_preroll =in_codecpar->seek_preroll;
out_stream->codecpar->channel_layout =in_codecpar->channel_layout;
out_stream->codecpar->chroma_location =in_codecpar->chroma_location;
out_stream->codecpar->color_primaries =in_codecpar->color_primaries;
out_stream->codecpar->initial_padding =in_codecpar->initial_padding;
out_stream->codecpar->trailing_padding =in_codecpar->trailing_padding;
out_stream->codecpar->bits_per_raw_sample = in_codecpar->bits_per_raw_sample;
out_stream->codecpar->sample_aspect_ratio.num = in_codecpar->sample_aspect_ratio.num;
out_stream->codecpar->sample_aspect_ratio.den = in_codecpar->sample_aspect_ratio.den;
out_stream->codecpar->bits_per_coded_sample = in_codecpar->bits_per_coded_sample;
if (in_codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
out_stream->codecpar->codec_id =ofmt_ctx->oformat->video_codec;
}
else if(in_codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
out_stream->codecpar->codec_id = ofmt_ctx->oformat- >audio_codec;
}
}
av_dump_format(ofmt_ctx, 0, out_filename, 1);
ofmt_ctx->pb = avio_ctx;
ret = avformat_write_header(ofmt_ctx, NULL);
if (ret < 0) {
fprintf(stderr, "Error occurred when opening output file\n");
return 1;
}
//------------------------------------------------------------------------------
while (1) {
AVStream *in_stream, *out_stream;
ret = av_read_frame(ifmt_ctx, &pkt);
if (ret < 0)
break;
in_stream = ifmt_ctx->streams[pkt.stream_index];
if (pkt.stream_index >= stream_mapping_size ||
stream_mapping[pkt.stream_index] < 0) {
av_packet_unref(&pkt);
continue;
}
pkt.stream_index = stream_mapping[pkt.stream_index];
out_stream = ofmt_ctx->streams[pkt.stream_index];
/* copy packet */
pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AVRounding(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AVRounding(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
pkt.pos = -1;
ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
if (ret < 0) {
fprintf(stderr, "Error muxing packet\n");
break;
}
av_packet_unref(&pkt);
}
av_write_trailer(ofmt_ctx);
avformat_close_input(&ifmt_ctx);
/* close output */
writeBuffer(fileNameOut, &bufferData);
avformat_free_context(ofmt_ctx);
av_freep(&stream_mapping);
if (ret < 0 && ret != AVERROR_EOF) {
fprintf(stderr, "Error occurred: %d\n",ret);
return 1;
}
return a.exec();
}
</fstream></iostream></qfileinfo></qcoreapplication>