
Recherche avancée
Médias (3)
-
Exemple de boutons d’action pour une collection collaborative
27 février 2013, par
Mis à jour : Mars 2013
Langue : français
Type : Image
-
Exemple de boutons d’action pour une collection personnelle
27 février 2013, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
Autres articles (55)
-
Submit bugs and patches
13 avril 2011Unfortunately a software is never perfect.
If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
You may also (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...) -
De l’upload à la vidéo finale [version standalone]
31 janvier 2010, parLe chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
Upload et récupération d’informations de la vidéo source
Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)
Sur d’autres sites (6760)
-
Shotdetect : compiling error ("undefined reference")
8 juillet 2015, par VoprosnikI am using Cygwin and I trying to install the program Shotdetect. I downloaded the source with git and also downloaded, compiled and installed ffmpeg through git.
Installation of shotdetect doesn’t follow the ./configure && make && make install routine, but a cmake system of which I have no experience. Nonetheless there is a script that automates compiling and installation.
Near the final stages of the compiling, I get a long series of errors concerning some ffmpeg modules :
Linking CXX executable shotdetect-cmd.exe
/usr/local/lib/libavformat.a(matroskadec.o): In function `matroska_decode_buffer':
/git/ffmpeg/libavformat/matroskadec.c:1321: undefined reference to `BZ2_bzDecompressInit'
/git/ffmpeg/libavformat/matroskadec.c:1336: undefined reference to `BZ2_bzDecompress'
/git/ffmpeg/libavformat/matroskadec.c:1329: undefined reference to `BZ2_bzDecompressEnd'
/git/ffmpeg/libavformat/matroskadec.c:1339: undefined reference to `BZ2_bzDecompressEnd'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
/git/ffmpeg/libavcodec/opusdec.c:374: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/git/ffmpeg/libavcodec/opusdec.c:220: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_init_resample':
/git/ffmpeg/libavcodec/opusdec.c:161: undefined reference to `swr_init'
/git/ffmpeg/libavcodec/opusdec.c:167: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/git/ffmpeg/libavcodec/opusdec.c:234: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_flush_resample':
/git/ffmpeg/libavcodec/opusdec.c:115: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
/git/ffmpeg/libavcodec/opusdec.c:406: undefined reference to `swr_close'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_flush':
/git/ffmpeg/libavcodec/opusdec.c:567: undefined reference to `swr_close'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_close':
/git/ffmpeg/libavcodec/opusdec.c:589: undefined reference to `swr_free'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_init':
/git/ffmpeg/libavcodec/opusdec.c:642: undefined reference to `swr_alloc'
/usr/local/lib/libavcodec.a(tiff.o): In function `tiff_uncompress_lzma':
/git/ffmpeg/libavcodec/tiff.c:396: undefined reference to `lzma_stream_decoder'
/git/ffmpeg/libavcodec/tiff.c:401: undefined reference to `lzma_code'
/git/ffmpeg/libavcodec/tiff.c:402: undefined reference to `lzma_end'
/usr/local/lib/libavcodec.a(utils.o): In function `recode_subtitle':
/git/ffmpeg/libavcodec/utils.c:2672: undefined reference to `libiconv_open'
/git/ffmpeg/libavcodec/utils.c:2707: undefined reference to `libiconv_close'
/git/ffmpeg/libavcodec/utils.c:2693: undefined reference to `libiconv'
/git/ffmpeg/libavcodec/utils.c:2694: undefined reference to `libiconv'
/git/ffmpeg/libavcodec/utils.c:2707: undefined reference to `libiconv_close'
/git/ffmpeg/libavcodec/utils.c:2707: undefined reference to `libiconv_close'
/git/ffmpeg/libavcodec/utils.c:2707: undefined reference to `libiconv_close'
/usr/local/lib/libavcodec.a(utils.o): In function `avcodec_open2':
/git/ffmpeg/libavcodec/utils.c:1698: undefined reference to `libiconv_open'
/git/ffmpeg/libavcodec/utils.c:1705: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
CMakeFiles/shotdetect-cmd.dir/build.make:122: recipe for target 'shotdetect-cmd.exe' failed
make[2]: *** [shotdetect-cmd.exe] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/shotdetect-cmd.dir/all' failed
make[1]: *** [CMakeFiles/shotdetect-cmd.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2Searching online for similar errors, I found the following proposed solutions
1) fix pkg-config setup so configure will find out all dependencies ;
2) build ffmpeg (libavcodec) without external dependencies ;
3) add external dependencies manually with configure —extra-ldflags
I guess the problem lies on how i compiled ffmpeg (just configure with no options) but other than that have no idea what to do with either of the above suggestions. Should I recompile ffmpeg with different options ?
-
Error of "Built target opencv_imgproc" while compiling opencv2
23 mars 2017, par HongFollowing https://github.com/menpo/conda-opencv3, while I compile opencv, there is following error (please read the error at the end of the post). The only change I made is to enable ffmpeg by modifying "-DWITH_FFMPEG=1" in BUILD.SH. Any suggestion ?
$conda build conda/
BUILD START: opencv3-3.1.0-py27_0
updating index in: /home/cocadas/anaconda2/conda-bld/linux-64
updating index in: /home/cocadas/anaconda2/conda-bld/noarch
The following NEW packages will be INSTALLED:
bzip2: 1.0.6-3
cmake: 3.6.3-0
curl: 7.52.1-0
eigen: 3.2.7-0 menpo
expat: 2.1.0-0
mkl: 2017.0.1-0
ncurses: 5.9-10
numpy: 1.12.1-py27_0
openssl: 1.0.2k-1
pip: 9.0.1-py27_1
python: 2.7.13-0
readline: 6.2-2
setuptools: 27.2.0-py27_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py27_0
xz: 5.2.2-1
zlib: 1.2.8-3
Source cache directory is: /home/cocadas/anaconda2/conda-bld/src_cache
Found source in cache: opencv-3.1.0.tar.gz
Extracting download
Applying patch: u'/home/cocadas/conda-opencv3/conda/no_rpath.patch'
patching file CMakeLists.txt
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 397 with fuzz 1 (offset 11 lines).
Package: opencv3-3.1.0-py27_0
source tree in: /home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0
source /home/cocadas/anaconda2/bin/activate /home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl
mkdir build
cd build
CMAKE_GENERATOR='Unix Makefiles'
CMAKE_ARCH=-m64
++ uname -s
SHORT_OS_STR=Linux
'[' Linux == Linux ']'
DYNAMIC_EXT=so
TBB=
OPENMP=-DWITH_OPENMP=1
IS_OSX=0
-- 3rdparty dependencies: zlib libjpeg libwebp libpng libtiff libjasper IlmImf
--
-- OpenCV modules:
-- To be built: core flann hdf imgproc ml photo reg surface_matching video dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow sfm stitching python2
-- Disabled: world contrib_world
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 ts viz cvv matlab
--
-- GUI:
-- QT: NO
-- GTK+ 3.x: YES (ver 3.18.9)
-- GThread : YES (ver 2.48.2)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: build (ver 1.2.8)
-- JPEG: build (ver 90)
-- WEBP: build (ver 0.3.1)
-- PNG: build (ver 1.6.19)
-- TIFF: build (ver 42 - 4.0.2)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
-- GDAL: NO
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES (ver 2.2.4)
-- FFMPEG: YES
-- codec: YES (ver 56.60.100)
-- format: YES (ver 56.40.101)
-- util: YES (ver 54.31.100)
-- swscale: YES (ver 3.1.101)
-- resample: NO
-- gentoo-style: YES
-- GStreamer: NO
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- OpenNI2: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l1 (ver 1.10.0) / libv4l2 (ver 1.10.0)
-- XIMEA: NO
-- Xine: NO
-- gPhoto2: NO
--
-- Parallel framework: OpenMP
--
-- Other third-party libraries:
-- Use IPP: 9.0.1 [9.0.1]
-- at: /home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx
-- Use IPP Async: NO
-- Use VA: NO
-- Use Intel VA-API/OpenCL: NO
-- Use Eigen: YES (ver 3.2.7)
-- Use Cuda: NO
-- Use OpenCL: NO
-- Use custom HAL: NO
--
-- Python 2:
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:554:22: error: ‘H5Tclose’ was not declared in this scope
H5Tclose( dstype );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:555:22: error: ‘H5Sclose’ was not declared in this scope
H5Sclose( dspace );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:557:22: error: ‘H5Dclose’ was not declared in this scope
H5Dclose( dsdata );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp: At global scope:
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:466:50: warning: unused parameter ‘dslabel’ [-Wunused-parameter]
void HDF5Impl::dsread( OutputArray Array, String dslabel,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp: In member function ‘virtual void cv::hdf::HDF5Impl::dswrite(cv::InputArray, cv::String, const int*, const int*) const’:
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:583:5: error: ‘hsize_t’ was not declared in this scope
hsize_t dsdims[n_dims];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:584:13: error: expected ‘;’ before ‘offset’
hsize_t offset[n_dims];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:588:7: error: ‘offset’ was not declared in this scope
offset[d] = 0;
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:590:7: error: ‘dsdims’ was not declared in this scope
dsdims[d] = matrix.size[d];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:601:9: error: ‘dsdims’ was not declared in this scope
dsdims[d] = dims_counts[d];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:605:5: error: ‘hid_t’ was not declared in this scope
hid_t dsdata = H5Dopen( m_h5_file_id, dslabel.c_str(), H5P_DEFAULT );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:608:11: error: expected ‘;’ before ‘dspace’
hid_t dspace = H5Screate_simple( n_dims, dsdims, NULL );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:614:9: error: ‘offset’ was not declared in this scope
offset[d] = dims_offset[d];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:618:11: error: expected ‘;’ before ‘fspace’
hid_t fspace = H5Dget_space( dsdata );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:619:26: error: ‘fspace’ was not declared in this scope
H5Sselect_hyperslab( fspace, H5S_SELECT_SET,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:619:34: error: ‘H5S_SELECT_SET’ was not declared in this scope
H5Sselect_hyperslab( fspace, H5S_SELECT_SET,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:620:26: error: ‘offset’ was not declared in this scope
offset, NULL, dsdims, NULL );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:620:40: error: ‘dsdims’ was not declared in this scope
offset, NULL, dsdims, NULL );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:620:53: error: ‘H5Sselect_hyperslab’ was not declared in this scope
offset, NULL, dsdims, NULL );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:623:11: error: expected ‘;’ before ‘dstype’
hid_t dstype = GetH5type( matrix.type() );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:628:15: error: expected ‘;’ before ‘adims’
hsize_t adims[1] = { channs };
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:629:7: error: ‘dstype’ was not declared in this scope
dstype = H5Tarray_create( dstype, 1, adims );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:629:44: error: ‘adims’ was not declared in this scope
dstype = H5Tarray_create( dstype, 1, adims );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:629:50: error: ‘H5Tarray_create’ was not declared in this scope
dstype = H5Tarray_create( dstype, 1, adims );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:633:15: error: ‘dsdata’ was not declared in this scope
H5Dwrite( dsdata, dstype, dspace, fspace,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:633:23: error: ‘dstype’ was not declared in this scope
H5Dwrite( dsdata, dstype, dspace, fspace,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:633:31: error: ‘dspace’ was not declared in this scope
H5Dwrite( dsdata, dstype, dspace, fspace,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:634:15: error: ‘H5P_DEFAULT’ was not declared in this scope
H5P_DEFAULT, matrix.data );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:634:40: error: ‘H5Dwrite’ was not declared in this scope
H5P_DEFAULT, matrix.data );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:637:24: error: ‘H5Tclose’ was not declared in this scope
H5Tclose( dstype );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:639:22: error: ‘H5Sclose’ was not declared in this scope
H5Sclose( dspace );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:641:22: error: ‘H5Dclose’ was not declared in this scope
H5Dclose( dsdata );
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:580:9: warning: unused variable ‘channs’ [-Wunused-variable]
int channs = matrix.channels();
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp: In member function ‘virtual void cv::hdf::HDF5Impl::dsinsert(cv::InputArray, cv::String, const int*, const int*) const’:
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:670:5: error: ‘hsize_t’ was not declared in this scope
hsize_t dsdims[n_dims];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:671:13: error: expected ‘;’ before ‘offset’
hsize_t offset[n_dims];
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:675:7: error: ‘offset’ was not declared in this scope
offset[d] = 0;
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:676:7: error: ‘dsdims’ was not declared in this scope
dsdims[d] = matrix.size[d];......
hsize_t foffset[1] = 0 ;
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:1022:11 : error : expected ‘ ;’ before ‘dspace’
hid_t dspace = H5Screate_simple( 1, dsddims, NULL ) ;
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:1025:26 : error : ‘dspace’ was not declared in this scope
H5Sselect_hyperslab( dspace, H5S_SELECT_SET,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:1025:34 : error : ‘H5S_SELECT_SET’ was not declared in this scope
H5Sselect_hyperslab( dspace, H5S_SELECT_SET,
^
/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/build/opencv_contrib/modules/hdf/src/hdf5.cpp:1026:26 : error : ‘foffset’ was not declared in this scope
foffset, NULL, dsddims, NULL ) ;[ 57%] Building CXX object modules/ml/CMakeFiles/opencv_ml.dir/src/svm.cpp.o
[ 57%] Building CXX object modules/ml/CMakeFiles/opencv_ml.dir/src/testset.cpp.o
[ 57%] Building CXX object modules/ml/CMakeFiles/opencv_ml.dir/src/tree.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/approx.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/blend.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/canny.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/clahe.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/color.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/colormap.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/connectedcomponents.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/contours.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/convhull.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/corner.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/cornersubpix.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/demosaicing.cpp.o
[ 57%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/deriv.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/distransform.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/drawing.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/emd.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/featureselect.cpp.o
[ 59%] Linking CXX shared library ../../lib/libopencv_ml.so
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/filter.cpp.o
[ 59%] Built target opencv_ml
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/floodfill.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/gabor.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/generalized_hough.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/geometry.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/grabcut.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/hershey_fonts.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/histogram.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/hough.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/imgwarp.cpp.o
[ 59%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/intersection.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/linefit.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/lsd.cpp.o
[ 60%] Linking CXX shared library ../../lib/libopencv_flann.so
[ 60%] Built target opencv_flann
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/matchcontours.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/main.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/min_enclosing_triangle.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/moments.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/morph.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/phasecorr.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/pyramids.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/rotcalipers.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/samplers.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/segmentation.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/shapedescr.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/smooth.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/spatialgradient.cpp.o
[ 60%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/subdivision2d.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/sumpixels.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/tables.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/templmatch.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/thresh.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/undistort.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/utils.cpp.o
[ 62%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc.dir/opencl_kernels_imgproc.cpp.o
[ 62%] Linking CXX shared library ../../lib/libopencv_imgproc.so
[ 62%] Built target opencv_imgproc
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
File "/home/cocadas/anaconda2/bin/conda-build", line 6, in
sys.exit(conda_build.cli.main_build.main())
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_build.py", line 334, in main
execute(sys.argv[1:])
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_build.py", line 325, in execute
noverify=args.no_verify)
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/api.py", line 97, in build
need_source_download=need_source_download, config=config)
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/build.py", line 1502, in build_tree
config=config)
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/build.py", line 1137, in build
utils.check_call_env(cmd, env=env, cwd=src_dir)
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/utils.py", line 616, in check_call_env
return _func_defaulting_env_to_os_environ(subprocess.check_call, *popenargs, **kwargs)
File "/home/cocadas/anaconda2/lib/python2.7/site-packages/conda_build/utils.py", line 612, in _func_defaulting_env_to_os_environ
return func(_args, **kwargs)
File "/home/cocadas/anaconda2/lib/python2.7/subprocess.py", line 186, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/bin/bash', '-x', '-e', '/home/cocadas/anaconda2/conda-bld/opencv3_1490285248642/work/opencv-3.1.0/conda_build.sh']' returned non-zero exit status 2 -
ffmpeg error "Could not allocate picture : Invalid argument Found Video Stream Found Audio Stream"
26 octobre 2020, par DinkanI am trying to write a C program to stream AV by copying both AV codecs with
rtp_mpegts
using RTP over network

ffmpeg -re -i Sample_AV_15min.ts -acodec copy -vcodec copy -f rtp_mpegts rtp://192.168.1.1:5004



using muxing.c as example which used ffmpeg libraries.
ffmpeg application works fine.


Stream details


Input #0, mpegts, from 'Weather_Nation_10min.ts':
 Duration: 00:10:00.38, start: 41313.400811, bitrate: 2840 kb/s
 Program 1
 Stream #0:0[0x11]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
 Stream #0:1[0x14]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 448 kb/s
Output #0, rtp_mpegts, to 'rtp://192.168.1.1:5004':
 Metadata:
 encoder : Lavf54.63.104
 Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 29.97 fps, 90k tbn, 29.97 tbc
 Stream #0:1: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, 448 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)



However, my application fails with


./my_test_app Sample_AV_15min.ts rtp://192.168.1.1:5004 
[h264 @ 0x800b30] non-existing PPS referenced 
[h264 @ 0x800b30] non-existing PPS 0 referenced 
[h264 @ 0x800b30] decode_slice_header error 
[h264 @ 0x800b30] no frame! 

[....snipped...]
[h264 @ 0x800b30] non-existing PPS 0 referenced 
[h264 @ 0x800b30] non-existing PPS referenced 
[h264 @ 0x800b30] non-existing PPS 0 referenced 
[h264 @ 0x800b30] decode_slice_header error 
[h264 @ 0x800b30] no frame! 
[h264 @ 0x800b30] mmco: unref short failure 
[h264 @ 0x800b30] mmco: unref short failure

[mpegts @ 0x800020] max_analyze_duration 5000000 reached at 5024000 microseconds 
[mpegts @ 0x800020] PES packet size mismatch could not find codec tag for codec id 
17075200, default to 0. could not find codec tag for codec id 86019, default to 0. 
Could not allocate picture: Invalid argument 
Found Video Stream Found Audio Stream



How do I fix this ? My complete source code based on muxing.c


/**
 * @file
 * libavformat API example.
 *
 * Output a media file in any supported libavformat format.
 * The default codecs are used.
 * @example doc/examples/muxing.c
 */

#include 
#include 
#include 
#include 

#include <libavutil></libavutil>mathematics.h>
#include <libavformat></libavformat>avformat.h>
#include <libswscale></libswscale>swscale.h>

/* 5 seconds stream duration */
#define STREAM_DURATION 200.0
#define STREAM_FRAME_RATE 25 /* 25 images/s */
#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */

static int sws_flags = SWS_BICUBIC;

/**************************************************************/
/* audio output */

static float t, tincr, tincr2;
static int16_t *samples;
static int audio_input_frame_size;
#if 0
/* Add an output stream. */
static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
 enum AVCodecID codec_id)
{
 AVCodecContext *c;
 AVStream *st;

 /* find the encoder */
 *codec = avcodec_find_encoder(codec_id);
 if (!(*codec)) {
 fprintf(stderr, "Could not find encoder for '%s'\n",
 avcodec_get_name(codec_id));
 exit(1);
 }

 st = avformat_new_stream(oc, *codec);
 if (!st) {
 fprintf(stderr, "Could not allocate stream\n");
 exit(1);
 }
 st->id = oc->nb_streams-1;
 c = st->codec;

 switch ((*codec)->type) {
 case AVMEDIA_TYPE_AUDIO:
 st->id = 1;
 c->sample_fmt = AV_SAMPLE_FMT_S16;
 c->bit_rate = 64000;
 c->sample_rate = 44100;
 c->channels = 2;
 break;

 case AVMEDIA_TYPE_VIDEO:
 c->codec_id = codec_id;

 c->bit_rate = 400000;
 /* Resolution must be a multiple of two. */
 c->width = 352;
 c->height = 288;
 /* timebase: This is the fundamental unit of time (in seconds) in terms
 * of which frame timestamps are represented. For fixed-fps content,
 * timebase should be 1/framerate and timestamp increments should be
 * identical to 1. */
 c->time_base.den = STREAM_FRAME_RATE;
 c->time_base.num = 1;
 c->gop_size = 12; /* emit one intra frame every twelve frames at most */
 c->pix_fmt = STREAM_PIX_FMT;
 if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
 /* just for testing, we also add B frames */
 c->max_b_frames = 2;
 }
 if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
 /* Needed to avoid using macroblocks in which some coeffs overflow.
 * This does not happen with normal video, it just happens here as
 * the motion of the chroma plane does not match the luma plane. */
 c->mb_decision = 2;
 }
 break;

 default:
 break;
 }

 /* Some formats want stream headers to be separate. */
 if (oc->oformat->flags & AVFMT_GLOBALHEADER)
 c->flags |= CODEC_FLAG_GLOBAL_HEADER;

 return st;
}
#endif 
/**************************************************************/
/* audio output */

static float t, tincr, tincr2;
static int16_t *samples;
static int audio_input_frame_size;

static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st)
{
 AVCodecContext *c;
 int ret;

 c = st->codec;

 /* open it */
 ret = avcodec_open2(c, codec, NULL);
 if (ret < 0) {
 fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
 exit(1);
 }

 /* init signal generator */
 t = 0;
 tincr = 2 * M_PI * 110.0 / c->sample_rate;
 /* increment frequency by 110 Hz per second */
 tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;

 if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)
 audio_input_frame_size = 10000;
 else
 audio_input_frame_size = c->frame_size;
 samples = av_malloc(audio_input_frame_size *
 av_get_bytes_per_sample(c->sample_fmt) *
 c->channels);
 if (!samples) {
 fprintf(stderr, "Could not allocate audio samples buffer\n");
 exit(1);
 }
}

/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
 * 'nb_channels' channels. */
static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels)
{
 int j, i, v;
 int16_t *q;

 q = samples;
 for (j = 0; j < frame_size; j++) {
 v = (int)(sin(t) * 10000);
 for (i = 0; i < nb_channels; i++)
 *q++ = v;
 t += tincr;
 tincr += tincr2;
 }
}

static void write_audio_frame(AVFormatContext *oc, AVStream *st)
{
 AVCodecContext *c;
 AVPacket pkt = { 0 }; // data and size must be 0;
 AVFrame *frame = avcodec_alloc_frame();
 int got_packet, ret;

 av_init_packet(&pkt);
 c = st->codec;

 get_audio_frame(samples, audio_input_frame_size, c->channels);
 frame->nb_samples = audio_input_frame_size;
 avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
 (uint8_t *)samples,
 audio_input_frame_size *
 av_get_bytes_per_sample(c->sample_fmt) *
 c->channels, 1);

 ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
 if (ret < 0) {
 fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
 exit(1);
 }

 if (!got_packet)
 return;

 pkt.stream_index = st->index;

 /* Write the compressed frame to the media file. */
 ret = av_interleaved_write_frame(oc, &pkt);
 if (ret != 0) {
 fprintf(stderr, "Error while writing audio frame: %s\n",
 av_err2str(ret));
 exit(1);
 }
 avcodec_free_frame(&frame);
}

static void close_audio(AVFormatContext *oc, AVStream *st)
{
 avcodec_close(st->codec);

 av_free(samples);
}

/**************************************************************/
/* video output */

static AVFrame *frame;
static AVPicture src_picture, dst_picture;
static int frame_count;

static void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st)
{
 int ret;
 AVCodecContext *c = st->codec;

 /* open the codec */
 ret = avcodec_open2(c, codec, NULL);
 if (ret < 0) {
 fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
 exit(1);
 }

 /* allocate and init a re-usable frame */
 frame = avcodec_alloc_frame();
 if (!frame) {
 fprintf(stderr, "Could not allocate video frame\n");
 exit(1);
 }

 /* Allocate the encoded raw picture. */
 ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height);
 if (ret < 0) {
 fprintf(stderr, "Could not allocate picture: %s\n", av_err2str(ret));
 exit(1);
 }

 /* If the output format is not YUV420P, then a temporary YUV420P
 * picture is needed too. It is then converted to the required
 * output format. */
 if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
 ret = avpicture_alloc(&src_picture, AV_PIX_FMT_YUV420P, c->width, c->height);
 if (ret < 0) {
 fprintf(stderr, "Could not allocate temporary picture: %s\n",
 av_err2str(ret));
 exit(1);
 }
 }

 /* copy data and linesize picture pointers to frame */
 *((AVPicture *)frame) = dst_picture;
}

/* Prepare a dummy image. */
static void fill_yuv_image(AVPicture *pict, int frame_index,
 int width, int height)
{
 int x, y, i;

 i = frame_index;

 /* Y */
 for (y = 0; y < height; y++)
 for (x = 0; x < width; x++)
 pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3;

 /* Cb and Cr */
 for (y = 0; y < height / 2; y++) {
 for (x = 0; x < width / 2; x++) {
 pict->data[1][y * pict->linesize[1] + x] = 128 + y + i * 2;
 pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5;
 }
 }
}

static void write_video_frame(AVFormatContext *oc, AVStream *st)
{
 int ret;
 static struct SwsContext *sws_ctx;
 AVCodecContext *c = st->codec;

 if (frame_count >= STREAM_NB_FRAMES) {
 /* No more frames to compress. The codec has a latency of a few
 * frames if using B-frames, so we get the last frames by
 * passing the same picture again. */
 } else {
 if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
 /* as we only generate a YUV420P picture, we must convert it
 * to the codec pixel format if needed */
 if (!sws_ctx) {
 sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P,
 c->width, c->height, c->pix_fmt,
 sws_flags, NULL, NULL, NULL);
 if (!sws_ctx) {
 fprintf(stderr,
 "Could not initialize the conversion context\n");
 exit(1);
 }
 }
 fill_yuv_image(&src_picture, frame_count, c->width, c->height);
 sws_scale(sws_ctx,
 (const uint8_t * const *)src_picture.data, src_picture.linesize,
 0, c->height, dst_picture.data, dst_picture.linesize);
 } else {
 fill_yuv_image(&dst_picture, frame_count, c->width, c->height);
 }
 }

 if (oc->oformat->flags & AVFMT_RAWPICTURE) {
 /* Raw video case - directly store the picture in the packet */
 AVPacket pkt;
 av_init_packet(&pkt);

 pkt.flags |= AV_PKT_FLAG_KEY;
 pkt.stream_index = st->index;
 pkt.data = dst_picture.data[0];
 pkt.size = sizeof(AVPicture);

 ret = av_interleaved_write_frame(oc, &pkt);
 } else {
 /* encode the image */
 AVPacket pkt;
 int got_output;

 av_init_packet(&pkt);
 pkt.data = NULL; // packet data will be allocated by the encoder
 pkt.size = 0;

 ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
 if (ret < 0) {
 fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
 exit(1);
 }

 /* If size is zero, it means the image was buffered. */
 if (got_output) {
 if (c->coded_frame->key_frame)
 pkt.flags |= AV_PKT_FLAG_KEY;

 pkt.stream_index = st->index;

 /* Write the compressed frame to the media file. */
 ret = av_interleaved_write_frame(oc, &pkt);
 } else {
 ret = 0;
 }
 }
 if (ret != 0) {
 fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
 exit(1);
 }
 frame_count++;
}

static void close_video(AVFormatContext *oc, AVStream *st)
{
 avcodec_close(st->codec);
 av_free(src_picture.data[0]);
 av_free(dst_picture.data[0]);
 av_free(frame);
}

/**************************************************************/
/* media file output */

int main(int argc, char **argv)
{
 const char *filename;
 AVOutputFormat *fmt;
 AVFormatContext *oc;
 AVStream *audio_st, *video_st;
 AVCodec *audio_codec, *video_codec;
 double audio_pts, video_pts;
 int ret;
 char errbuf[50];
 int i = 0;
 /* Initialize libavcodec, and register all codecs and formats. */
 av_register_all();

 if (argc != 3) {
 printf("usage: %s input_file out_file|stream\n"
 "API example program to output a media file with libavformat.\n"
 "This program generates a synthetic audio and video stream, encodes and\n"
 "muxes them into a file named output_file.\n"
 "The output format is automatically guessed according to the file extension.\n"
 "Raw images can also be output by using '%%d' in the filename.\n"
 "\n", argv[0]);
 return 1;
 }

 filename = argv[2];

 /* allocate the output media context */
 avformat_alloc_output_context2(&oc, NULL, "rtp_mpegts", filename);
 if (!oc) {
 printf("Could not deduce output format from file extension: using MPEG.\n");
 avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
 }
 if (!oc) {
 return 1;
 }
 fmt = oc->oformat;
 //Find input stream info.

 video_st = NULL;
 audio_st = NULL;

 avformat_open_input( &oc, argv[1], 0, 0);

 if ((ret = avformat_find_stream_info(oc, 0))< 0)
 {
 av_strerror(ret, errbuf,sizeof(errbuf));
 printf("Not Able to find stream info::%s ", errbuf);
 ret = -1;
 return ret;
 }
 for (i = 0; i < oc->nb_streams; i++)
 {
 if(oc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
 {
 AVCodecContext *codec_ctx;
 unsigned int tag = 0;

 printf("Found Video Stream ");
 video_st = oc->streams[i];
 codec_ctx = video_st->codec;
 // m_num_frames = oc->streams[i]->nb_frames;
 video_codec = avcodec_find_decoder(codec_ctx->codec_id);
 ret = avcodec_open2(codec_ctx, video_codec, NULL);
 if (ret < 0) 
 {
 av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
 return ret;
 }
 if (av_codec_get_tag2(oc->oformat->codec_tag, video_codec->id, &tag) == 0) 
 {
 av_log(NULL, AV_LOG_ERROR, "could not find codec tag for codec id %d, default to 0.\n", audio_codec->id);
 }
 video_st->codec = avcodec_alloc_context3(video_codec);
 video_st->codec->codec_tag = tag;
 }

 if(oc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
 {
 AVCodecContext *codec_ctx;
 unsigned int tag = 0;

 printf("Found Audio Stream ");
 audio_st = oc->streams[i];
 // aud_dts = audio_st->cur_dts;
 // aud_pts = audio_st->last_IP_pts; 
 codec_ctx = audio_st->codec;
 audio_codec = avcodec_find_decoder(codec_ctx->codec_id);
 ret = avcodec_open2(codec_ctx, audio_codec, NULL);
 if (ret < 0) 
 {
 av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
 return ret;
 }
 if (av_codec_get_tag2(oc->oformat->codec_tag, audio_codec->id, &tag) == 0) 
 {
 av_log(NULL, AV_LOG_ERROR, "could not find codec tag for codec id %d, default to 0.\n", audio_codec->id);
 }
 audio_st->codec = avcodec_alloc_context3(audio_codec);
 audio_st->codec->codec_tag = tag;
 }
 }
 /* Add the audio and video streams using the default format codecs
 * and initialize the codecs. */
 /*
 if (fmt->video_codec != AV_CODEC_ID_NONE) {
 video_st = add_stream(oc, &video_codec, fmt->video_codec);
 }
 if (fmt->audio_codec != AV_CODEC_ID_NONE) {
 audio_st = add_stream(oc, &audio_codec, fmt->audio_codec);
 }
 */

 /* Now that all the parameters are set, we can open the audio and
 * video codecs and allocate the necessary encode buffers. */
 if (video_st)
 open_video(oc, video_codec, video_st);
 if (audio_st)
 open_audio(oc, audio_codec, audio_st);

 av_dump_format(oc, 0, filename, 1);

 /* open the output file, if needed */
 if (!(fmt->flags & AVFMT_NOFILE)) {
 ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE);
 if (ret < 0) {
 fprintf(stderr, "Could not open '%s': %s\n", filename,
 av_err2str(ret));
 return 1;
 }
 }

 /* Write the stream header, if any. */
 ret = avformat_write_header(oc, NULL);
 if (ret < 0) {
 fprintf(stderr, "Error occurred when opening output file: %s\n",
 av_err2str(ret));
 return 1;
 }

 if (frame)
 frame->pts = 0;
 for (;;) {
 /* Compute current audio and video time. */
 if (audio_st)
 audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
 else
 audio_pts = 0.0;

 if (video_st)
 video_pts = (double)video_st->pts.val * video_st->time_base.num /
 video_st->time_base.den;
 else
 video_pts = 0.0;

 if ((!audio_st || audio_pts >= STREAM_DURATION) &&
 (!video_st || video_pts >= STREAM_DURATION))
 break;

 /* write interleaved audio and video frames */
 if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {
 write_audio_frame(oc, audio_st);
 } else {
 write_video_frame(oc, video_st);
 frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
 }
 }

 /* Write the trailer, if any. The trailer must be written before you
 * close the CodecContexts open when you wrote the header; otherwise
 * av_write_trailer() may try to use memory that was freed on
 * av_codec_close(). */
 av_write_trailer(oc);

 /* Close each codec. */
 if (video_st)
 close_video(oc, video_st);
 if (audio_st)
 close_audio(oc, audio_st);

 if (!(fmt->flags & AVFMT_NOFILE))
 /* Close the output file. */
 avio_close(oc->pb);

 /* free the stream */
 avformat_free_context(oc);

 return 0;
}