
Recherche avancée
Autres articles (101)
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Multilang : améliorer l’interface pour les blocs multilingues
18 février 2011, parMultilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.
Sur d’autres sites (15748)
-
FFmpeg using png with tranparency and exclusion blending mode
27 août 2016, par moorejI’m trying to use the exclusion blending mode to blend together a video and a png with transparency. I’ve looked around quite a bit but I can’t find a solution that works for me. Here’s the ffmpeg command :
ffmpeg -i movie.mkv -i text_white_bg_trans.png -filter_complex\
"[1:v]setsar=sar=1,format=rgba[txt]; [0:v]format=rgba[mo]; [mo][txt]blend=all_mode='exclusion'" out_exclusion.mkvEdit : and the console output :
ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --enable-videotoolbox --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from 'movie.mkv':
Metadata:
ENCODER : Lavf57.25.100
Duration: 00:00:11.88, start: 0.000000, bitrate: 5143 kb/s
Stream #0:0: Video: h264 (High), yuv420p, 1640x1232, SAR 1:1 DAR 205:154, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
ENCODER : Lavc57.24.102 libx264
DURATION : 00:00:11.880000000
Input #1, png_pipe, from 'text_white_bg_trans.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 1640x1232, 25 tbr, 25 tbn, 25 tbc
File 'out_exclusion.mkv' 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 @ 0x7fb10a01e200] using SAR=1/1
[libx264 @ 0x7fb10a01e200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fb10a01e200] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 @ 0x7fb10a01e200] 264 - core 148 - 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=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, matroska, to 'out_exclusion.mkv':
Metadata:
encoder : Lavf57.25.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 1640x1232 [SAR 1:1 DAR 205:154], q=-1--1, 25 fps, 1k tbn, 25 tbc (default)
Metadata:
encoder : Lavc57.24.102 libx264
Side data:
unknown side data type 10 (24 bytes)
Stream mapping:
Stream #0:0 (h264) -> format
Stream #1:0 (png) -> setsar
blend -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
frame= 24 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= frame= 47 fps= 40 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= frame= 61 fps= 36 q=28.0 size= 96kB time=00:00:00.12 bitrate=6567.3kbitsframe= 70 fps= 32 q=28.0 size= 264kB time=00:00:00.48 bitrate=4513.9kbitsframe= 83 fps= 30 q=28.0 size= 498kB time=00:00:01.00 bitrate=4079.5kbitsframe= 95 fps= 29 q=28.0 size= 691kB time=00:00:01.48 bitrate=3827.5kbitsframe= 106 fps= 28 q=28.0 size= 896kB time=00:00:01.92 bitrate=3823.7kbitsframe= 118 fps= 27 q=28.0 size= 1132kB time=00:00:02.40 bitrate=3863.7kbitsframe= 130 fps= 26 q=28.0 size= 1338kB time=00:00:02.88 bitrate=3806.1kbitsframe= 142 fps= 26 q=28.0 size= 1588kB time=00:00:03.36 bitrate=3871.7kbitsframe= 154 fps= 25 q=28.0 size= 1808kB time=00:00:03.84 bitrate=3856.9kbitsframe= 166 fps= 25 q=28.0 size= 2062kB time=00:00:04.32 bitrate=3910.9kbitsframe= 178 fps= 24 q=28.0 size= 2328kB time=00:00:04.80 bitrate=3972.8kbitsframe= 190 fps= 24 q=28.0 size= 2620kB time=00:00:05.28 bitrate=4064.7kbitsframe= 203 fps= 24 q=28.0 size= 2886kB time=00:00:05.80 bitrate=4076.0kbitsframe= 215 fps= 24 q=28.0 size= 3132kB time=00:00:06.28 bitrate=4085.9kbitsframe= 226 fps= 24 q=28.0 size= 3357kB time=00:00:06.72 bitrate=4092.5kbitsframe= 238 fps= 24 q=28.0 size= 3589kB time=00:00:07.20 bitrate=4083.9kbitsframe= 250 fps= 23 q=28.0 size= 3794kB time=00:00:07.68 bitrate=4047.3kbitsframe= 260 fps= 23 q=28.0 size= 3978kB time=00:00:08.08 bitrate=4032.7kbitsframe= 272 fps= 23 q=28.0 size= 4212kB time=00:00:08.56 bitrate=4031.0kbitsframe= 284 fps= 23 q=28.0 size= 4453kB time=00:00:09.04 bitrate=4035.3kbitsframe= 295 fps= 23 q=28.0 size= 4632kB time=00:00:09.48 bitrate=4002.9kbitsframe= 297 fps= 20 q=-1.0 Lsize= 5559kB time=00:00:11.80 bitrate=3859.4kbits/s speed=0.808x
video:5556kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.053747%
[libx264 @ 0x7fb10a01e200] frame I:2 Avg QP:21.70 size: 56001
[libx264 @ 0x7fb10a01e200] frame P:178 Avg QP:23.12 size: 24833
[libx264 @ 0x7fb10a01e200] frame B:117 Avg QP:25.78 size: 9886
[libx264 @ 0x7fb10a01e200] consecutive B-frames: 29.3% 49.8% 14.1% 6.7%
[libx264 @ 0x7fb10a01e200] mb I I16..4: 9.5% 75.0% 15.5%
[libx264 @ 0x7fb10a01e200] mb P I16..4: 4.0% 14.8% 1.0% P16..4: 43.3% 12.0% 4.5% 0.0% 0.0% skip:20.4%
[libx264 @ 0x7fb10a01e200] mb B I16..4: 0.6% 1.9% 0.1% B16..8: 48.5% 4.2% 0.3% direct: 0.6% skip:43.8% L0:42.5% L1:55.6% BI: 1.9%
[libx264 @ 0x7fb10a01e200] 8x8 transform intra:74.8% inter:85.5%
[libx264 @ 0x7fb10a01e200] coded y,u,v intra: 31.3% 0.0% 0.0% inter: 15.0% 0.0% 0.0%
[libx264 @ 0x7fb10a01e200] i16 v,h,dc,p: 30% 32% 13% 25%
[libx264 @ 0x7fb10a01e200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 22% 32% 3% 4% 3% 6% 3% 3%
[libx264 @ 0x7fb10a01e200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 33% 16% 3% 4% 3% 9% 4% 2%
[libx264 @ 0x7fb10a01e200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fb10a01e200] ref P L0: 72.2% 17.9% 7.5% 2.5%
[libx264 @ 0x7fb10a01e200] ref B L0: 90.9% 8.6% 0.5%
[libx264 @ 0x7fb10a01e200] ref B L1: 98.6% 1.4%
[libx264 @ 0x7fb10a01e200] kb/s:3830.94Edit : Here’s a frame from the output.
The output video is B&W rather than the original color (not sure why). The rectangle in the image is located where there is a block of text on a png with a transparent background. The png is the same size as the video.I’m expecting something more like this :
@Mulvya suggestion fixed the issue with color but I’m still seeing some problems with transparency being handled. I’m attaching a few different images below that each create different problems. All created in Photoshop CC (therein may lie the problem).
A transparent background with a separate text layer that is then exported by Save->png, Photoshop appears to merge these two layers but differently than when "merge layers" is chosen before export. The exported image looks like the B&W image I posted above but with color.
The in the second I merge the layers before exporting. It appears the entire image is treated as white.
In the third I draw "hello" on a transparent layer with a "soft" brush using different grays then export. Transparent areas are rendered as white, gray or translucent areas opaque or with a strange dithering "effect."
It seems I’m moving outside the realm of StackOverflow, but I’m not sure where this post would be better suited.
1
2
3
-
ffmpeg concatenation after using drawtext filter
12 août 2016, par Sven HoskensI’m fairly new to ffmpeg, but after a few days of searching on this issue, I’ve completely hit a brick wall. Any help would be appreciated.
My use case : Our client wants to upload videos for multiple regions. Each video will be the same format, 1920x1080, mp4. For each region, they want to add a different image at the end of the video, for a few seconds. This image contains their logo, some additional info, and a variable code. They will enter this code alongside the uploaded video. The image stays the same, so is already present on the server.
So basically, I have an input video, a video of an image, and a small code. I need to add this code to the video of the image (in a predefined position), and then I need to add the resulting video to the end of the input video. Once that is complete, I just need to output the video in 1920x1080 and in 1024x576.I have tried several things, but the concatenation step always fails with the manipulated video’s.
Attempt 1
In my first attempt, I used ffmpeg to create a video from an image, and add the text in the designated area.
ffmpeg -y -f lavfi -i image.png -r 30 -t 10 -pix_fmt yuv420p -map 0:v -vf drawtext="fontfile=HelveticaNeue.dfont: text='GLNS/TEST/1234b': fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=7: x=179: y=805" imageVideo.mp4
This command creates a .mp4 video of the correct size, with a duration of 10 seconds, and adds the text ’GLNS/TEST/1234b’ in the correct location.
Next, I use the following command to concatenate the two videos. Both have the same resolution and codec.
ffmpeg -f concat -safe 0 -i config.txt -vf scale=1920:1080 outputHD.mp4 -vf scale=1024:576 outputSD.mp4
config.txt contains following :
file my_input_file.mp4
file ImageVideo.mp4This concatenation works with regular videos. However, when I use it with ImageVideo.mp4 (the one created by the first command) I get this error log :
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f86dc924600] Auto-inserting h264_mp4toannexb bitstream filtereed=0.509x
[aac @ 0x7f86dc019e00] Number of bands (31) exceeds limit (5).
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 0x7f86dc019e00] Number of bands (27) exceeds limit (8).
Error while decoding stream #0:1: Invalid data found when processing input
[h264 @ 0x7f86dd857200] Error splitting the input into NAL units.
[h264 @ 0x7f86dd829400] Invalid NAL unit size.
[h264 @ 0x7f86dd829400] Error splitting the input into NAL units.
[aac @ 0x7f86dc019e00] Number of bands (10) exceeds limit (1).
Error while decoding stream #0:1: Invalid data found when processing input
[h264 @ 0x7f86dd816800] Invalid NAL unit size.
[h264 @ 0x7f86dd816800] Error splitting the input into NAL units.
[aac @ 0x7f86dc019e00] Number of bands (24) exceeds limit (1).
Error while decoding stream #0:1: Invalid data found when processing input
#this goes on for a few hundred linesThe resulting output is identical to the input video, but does not contain the desired image video at the end.
Attempt 2
Since the above attempt didn’t work, I tried concatenating a video I let our designer make of the image with Adobe After Effects. This video was also saved as a .mp4 with the H264 codec. If I concatenate the input video and this one, I get a correct result. However, as soon as I add the code in the designated area with this command :
ffmpeg -i new_image_video.mp4 -vf drawtext="fontfile=HelveticaNeue.dfont: text='GLNS/TEST/1234b': fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=7: x=179: y=805" -c:v libx264 imageVideo.mp4
I get this error :
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ff94c800000] Auto-inserting h264_mp4toannexb bitstream filter97x
[h264 @ 0x7ff94b053800] top block unavailable for requested intra mode -1
[h264 @ 0x7ff94b053800] error while decoding MB 0 0, bytestream 49526
[h264 @ 0x7ff94b053e00] number of reference frames (1+3) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0x7ff94b053e00] chroma_log2_weight_denom 28 is out of range
[h264 @ 0x7ff94b053e00] illegal long ref in memory management control operation 2
[h264 @ 0x7ff94b053e00] cabac_init_idc 32 overflow
[h264 @ 0x7ff94b053e00] decode_slice_header error
[h264 @ 0x7ff94b053e00] no frame!
[h264 @ 0x7ff94b053800] concealing 8160 DC, 8160 AC, 8160 MV errors in I frame
[h264 @ 0x7ff94b072a00] reference overflow 22 > 15 or 0 > 15
[h264 @ 0x7ff94b072a00] decode_slice_header error
[h264 @ 0x7ff94b072a00] no frame!
[h264 @ 0x7ff94b01a400] illegal modification_of_pic_nums_idc 20
[h264 @ 0x7ff94b01a400] decode_slice_header error
[h264 @ 0x7ff94b01a400] no frame!
[h264 @ 0x7ff94b01aa00] illegal modification_of_pic_nums_idc 20
[h264 @ 0x7ff94b01aa00] decode_slice_header error
[h264 @ 0x7ff94b01aa00] no frame!
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 0x7ff94b053800] deblocking_filter_idc 8 out of range
[h264 @ 0x7ff94b053800] decode_slice_header error
[h264 @ 0x7ff94b053800] no frame!
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 0x7ff94b053e00] illegal memory management control operation 8
[h264 @ 0x7ff94b053e00] co located POCs unavailable
[h264 @ 0x7ff94b053e00] error while decoding MB 2 0, bytestream -35
[h264 @ 0x7ff94b053e00] concealing 8160 DC, 8160 AC, 8160 MV errors in B frame
[h264 @ 0x7ff94b072a00] number of reference frames (1+3) exceeds max (3; probably corrupt input), discarding one
# this goes on for a while...
[h264 @ 0x7ff94b01a400] concealing 4962 DC, 4962 AC, 4962 MV errors in B frame
Error while decoding stream #0:0: Invalid data found when processing input
frame= 2553 fps= 17 q=-1.0 Lsize= 26995kB time=00:01:42.16 bitrate=2164.6kbits/s dup=0 drop=60 speed=0.697x
video:25258kB audio:1661kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.285236%
[libx264 @ 0x7ff94b810400] frame I:35 Avg QP:17.45 size: 55070
[libx264 @ 0x7ff94b810400] frame P:711 Avg QP:19.73 size: 18712
[libx264 @ 0x7ff94b810400] frame B:1807 Avg QP:21.53 size: 5884
[libx264 @ 0x7ff94b810400] consecutive B-frames: 3.4% 5.0% 4.9% 86.6%
[libx264 @ 0x7ff94b810400] mb I I16..4: 38.2% 49.3% 12.5%
[libx264 @ 0x7ff94b810400] mb P I16..4: 12.4% 14.0% 1.0% P16..4: 29.6% 4.8% 1.9% 0.0% 0.0% skip:36.2%
[libx264 @ 0x7ff94b810400] mb B I16..4: 1.5% 1.2% 0.1% B16..8: 27.3% 1.6% 0.1% direct: 1.8% skip:66.4% L0:45.8% L1:51.4% BI: 2.8%
[libx264 @ 0x7ff94b810400] 8x8 transform intra:49.5% inter:85.4%
[libx264 @ 0x7ff94b810400] coded y,uvDC,uvAC intra: 21.2% 22.3% 2.5% inter: 4.6% 7.0% 0.0%
[libx264 @ 0x7ff94b810400] i16 v,h,dc,p: 23% 26% 10% 41%
[libx264 @ 0x7ff94b810400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 19% 35% 3% 3% 3% 3% 3% 2%
[libx264 @ 0x7ff94b810400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 20% 16% 5% 7% 6% 5% 5% 4%
[libx264 @ 0x7ff94b810400] i8c dc,h,v,p: 67% 16% 15% 2%
[libx264 @ 0x7ff94b810400] Weighted P-Frames: Y:7.3% UV:4.2%
[libx264 @ 0x7ff94b810400] ref P L0: 66.3% 8.7% 17.9% 7.0% 0.1%
[libx264 @ 0x7ff94b810400] ref B L0: 88.2% 10.1% 1.7%
[libx264 @ 0x7ff94b810400] ref B L1: 94.9% 5.1%
[libx264 @ 0x7ff94b810400] kb/s:2026.12
[aac @ 0x7ff94b072400] Qavg: 635.626The resulting output is identical to the input video, but does not contain the desired image video at the end.
One thing I have noticed : When I inspect the video files on mac (Get info) they always contain these lines at ’More info’ :
Dimensions: 1920 x 1080
Codecs: H.264, AAC
Color profile: HD(1-1-1)
Duration: 01:42
Audio channels: 2
Last opened: Today 11:02However, the video’s which pass through the drawtext filter have this :
Dimensions: 1920 x 1080
Codecs: AAC, H.264
Duration: 00:10
Audio channels: 2
Last opened: Today 11:07As you can see, there is no color profile entry, and the codecs have switched places. I assume this is related to my issue, but I can’t seem to find a fix for it.
PS : The application will run in a php environment (Symfony). I noticed the concat command wasn’t available in the Symfony bundle for ffmpeg, so I’m using the regular terminal commands. I’ll execute these using php.
EDIT
Attempt 3On advise of a coworker, I tried converting the video to .avi and reconverting to .mp4, in the hopes this would lose any corrupted or extra info included by the drawtext filter. This spits out a completely different error.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f812413da00] Auto-inserting h264_mp4toannexb bitstream filtereed=0.516x
[concat @ 0x7f8124009a00] DTS 1569260 < 2551000 out of order
[h264 @ 0x7f8124846800] left block unavailable for requested intra4x4 mode -1
[h264 @ 0x7f8124846800] error while decoding MB 0 0, bytestream 47919
[h264 @ 0x7f8124846800] concealing 8160 DC, 8160 AC, 8160 MV errors in I frame
[aac @ 0x7f8125809a00] Queue input is backward in time
[aac @ 0x7f8125815a00] Queue input is backward in time
[h264 @ 0x7f8124846e00] number of reference frames (1+3) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0x7f8124846e00] chroma_log2_weight_denom 26 is out of range
[h264 @ 0x7f8124846e00] deblocking_filter_idc 32 out of range
[h264 @ 0x7f8124846e00] decode_slice_header error
[h264 @ 0x7f8124846e00] no frame!
[mp4 @ 0x7f8124802200] Non-monotonous DTS in output stream 0:1; previous: 4902912, current: 4505491; changing to 4902913. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8125813000] Non-monotonous DTS in output stream 1:1; previous: 4902912, current: 4505491; changing to 4902913. This may result in incorrect timestamps in the output file.
[h264 @ 0x7f8124803400] reference overflow 20 > 15 or 0 > 15
[h264 @ 0x7f8124803400] decode_slice_header error
[h264 @ 0x7f8124803400] no frame!
[mp4 @ 0x7f8124802200] Non-monotonous DTS in output stream 0:1; previous: 4902913, current: 4506515; changing to 4902914. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8125813000] Non-monotonous DTS in output stream 1:1; previous: 4902913, current: 4506515; changing to 4902914. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8124802200] Non-monotonous DTS in output stream 0:1; previous: 4902914, current: 4507539; changing to 4902915. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8125813000] Non-monotonous DTS in output stream 1:1; previous: 4902914, current: 4507539; changing to 4902915. This may result in incorrect timestamps in the output file.
# Again, this continues for quite a while. -
Decoding Video using FFMpeg for android
29 novembre 2014, par Rahul UpadhyayI tried to decode video using FFMpeg library from the sample examples available on internet, i figure it out with new version of ffmpeg,
here is the code which I called from my class file,private static native int decodeVideo(String filename);
decodeVideo(getString(R.string._sdcard_abc_3gp));now in .c file located in JNI dir,I wrote this code,
jint Java_ru_dzakhov_ffmpeg_test_MainActivity_decodeVideo(JNIEnv* env, jobject
javaThis,jstring filename) {
AVFormatContext *pFormatCtx;
int i, videoStream;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
AVFrame *pFrameRGB;
AVPacket packet;
int frameFinished;
int numBytes;
uint8_t *buffer;
// Register all formats and codecs
av_register_all();
// Open video file
const jbyte *str;
str = (*env)->GetStringUTFChars(env, filename, NULL);
if(av_open_input_file(&pFormatCtx, str, NULL, 0, NULL)!=0)
{
LOGI("Can't open file '%s'\n", str);
return 1;
}
else
{
LOGI("File is opened\n");
LOGI("File '%s', Codec %s",pFormatCtx->filename,pFormatCtx->iformat->name);
}
// Dump information about file onto standard error
LOGI("dump_format");
dump_format(pFormatCtx, 0, filename, 0);
LOGI("dump_format DONE");
// Find the first video stream
videoStream=-1;
for(i=0; inb_streams; i++)
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
//if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
{
LOGI("videoStream:: %d",videoStream);
videoStream=i;
break;
}
if(videoStream==-1)
return -1; // Didn't find a video stream
// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
LOGI("Unsupported codec!\n");
return -1; // Codec not found
}
// Open codec
if(avcodec_open(pCodecCtx, pCodec)<0){
LOGI("Codec Opened!\n");
return -1; // Could not open codec
}
// Allocate video frame
pFrame=avcodec_alloc_frame();
// Allocate an AVFrame structure
pFrameRGB=avcodec_alloc_frame();
if(pFrameRGB==NULL){
LOGI("checking --->>> pFrameRGB==NULL\n");
return -1;
}
// Determine required buffer size and allocate buffer
LOGI("Determine required buffer size and allocate buffer\n");
numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
pCodecCtx->height);
LOGI("numBytes %d",numBytes);
buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
// Assign appropriate parts of buffer to image planes in pFrameRGB
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
// of AVPicture
avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
pCodecCtx->width, pCodecCtx->height);
// Read frames and save first five frames to disk
i=0;
while(av_read_frame(pFormatCtx, &packet)>=0) {
// Is this a packet from the video stream?
if(packet.stream_index==videoStream) {
// Decode video frame
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,&packet);
//packet.data, packet.size);
// Did we get a video frame?
if(frameFinished) {
// Convert the image from its native format to RGB
/*Temporarily down
*
* img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24,
(AVPicture*)pFrame, pCodecCtx->pix_fmt, pCodecCtx->width,pCodecCtx->height);*/
// Save the frame to phone memory
LOGI("Saving Frame\n");
SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height, ++i);
LOGI("After Saving Frame\n");
}
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
}
// Free the RGB image
av_free(buffer);
av_free(pFrameRGB);
// Free the YUV frame
av_free(pFrame);
// Close the codec
avcodec_close(pCodecCtx);
// Close the video file
av_close_input_file(pFormatCtx);
return 0;
}after compiling the code i get this in log,
07-04 10:58:38.961: D/dalvikvm(1010): Trying to load lib /data/data/ru.dzakhov.ffmpeg.test/lib/libmylib.so 0x4051e878
07-04 10:58:38.971: D/dalvikvm(1010): Added shared lib /data/data/ru.dzakhov.ffmpeg.test/lib/libmylib.so 0x4051e878
07-04 10:58:38.971: D/dalvikvm(1010): No JNI_OnLoad found in /data/data/ru.dzakhov.ffmpeg.test/lib/libmylib.so 0x4051e878, skipping init
07-04 10:58:39.011: I/System.out(1010): Creating Engine
07-04 10:58:39.011: I/mylib(1010): initiated
07-04 10:58:39.011: I/System.out(1010): Decoding Video
07-04 10:58:39.011: I/System.out(1010): passing video::/sdcard/NativeMedia.ts
07-04 10:58:39.101: W/dalvikvm(231): disableGcForExternalAlloc: false
07-04 10:58:39.121: I/DEBUG(71): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-04 10:58:39.121: I/DEBUG(71): Build fingerprint: 'htc_asia_india/htc_icong/icong:2.3.3/GRI40/68450.5:user/release-keys'
07-04 10:58:39.121: I/DEBUG(71): pid: 1010, tid: 1010 >>> ru.dzakhov.ffmpeg.test <<<
07-04 10:58:39.121: I/DEBUG(71): signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 8102de90
07-04 10:58:39.121: I/DEBUG(71): r0 0000ac28 r1 40521b98 r2 40526340 r3 42157cc8
07-04 10:58:39.121: I/DEBUG(71): r4 bee7d368 r5 00000004 r6 40521b98 r7 42157c88
07-04 10:58:39.121: I/DEBUG(71): r8 bee7d348 r9 42157c80 10 42157c6c fp 42f0f04c
07-04 10:58:39.121: I/DEBUG(71): ip 8102de91 sp bee7d348 lr 80018378 pc 8102de90 cpsr a0000030
07-04 10:58:39.121: I/DEBUG(71): d0 4140000041600000 d1 3ff0000041680000
07-04 10:58:39.121: I/DEBUG(71): d2 bf80000000000000 d3 0000000000000000
07-04 10:58:39.121: I/DEBUG(71): d4 0000000000000000 d5 3ff000003f800000
07-04 10:58:39.121: I/DEBUG(71): d6 bff000003f800000 d7 4160000000000000
07-04 10:58:39.121: I/DEBUG(71): d8 0000000000000000 d9 0000000000000000
07-04 10:58:39.121: I/DEBUG(71): d10 0000000000000000 d11 0000000000000000
07-04 10:58:39.121: I/DEBUG(71): d12 0000000000000000 d13 0000000000000000
07-04 10:58:39.121: I/DEBUG(71): d14 0000000000000000 d15 0000000000000000
07-04 10:58:39.121: I/DEBUG(71): scr 20000012
07-04 10:58:39.221: I/DEBUG(71): #00 pc 0002de90 /data/data/ru.dzakhov.ffmpeg.test/lib/libmylib.so
07-04 10:58:39.221: I/DEBUG(71): #01 pc 0004f13c /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #02 pc 0001d584 /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #03 pc 00022b8c /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #04 pc 00021a80 /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #05 pc 0006060a /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #06 pc 0006828e /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #07 pc 0001d584 /system/lib/libdvm.so
07-04 10:58:39.221: I/DEBUG(71): #08 pc 00022b8c /system/lib/libdvm.so
07-04 10:58:39.231: I/DEBUG(71): #09 pc 00021a80 /system/lib/libdvm.so
07-04 10:58:39.231: I/DEBUG(71): #10 pc 0006045c /system/lib/libdvm.so
07-04 10:58:39.231: I/DEBUG(71): #11 pc 0004c430 /system/lib/libdvm.so
07-04 10:58:39.231: I/DEBUG(71): #12 pc 00037638 /system/lib/libandroid_runtime.so
07-04 10:58:39.231: I/DEBUG(71): #13 pc 00038456 /system/lib/libandroid_runtime.so
07-04 10:58:39.231: I/DEBUG(71): #14 pc 00008ca2 /system/bin/app_process
07-04 10:58:39.231: I/DEBUG(71): #15 pc 00014f24 /system/lib/libc.so
07-04 10:58:39.231: I/DEBUG(71): code around pc:
07-04 10:58:39.231: I/DEBUG(71): 8102de70 003d9cd0 00000408 0029e598 0029e5de
07-04 10:58:39.231: I/DEBUG(71): 8102de80 0029e5d8 0029e5d8 0029e5cc 0029e5c8
07-04 10:58:39.231: I/DEBUG(71): 8102de90 4ff0e92d b0994604 f0004615 6823f945
07-04 10:58:39.231: I/DEBUG(71): 8102dea0 46294620 32a4f8d3 47982200 46044f81
07-04 10:58:39.231: I/DEBUG(71): 8102deb0 a8172300 22004621 9300447f f9c0f060
07-04 10:58:39.231: I/DEBUG(71): code around lr:
07-04 10:58:39.231: I/DEBUG(71): 80018358 3497c004 3488c004 3afffff9 e2888004
07-04 10:58:39.231: I/DEBUG(71): 80018368 eafffff9 e899000c e594c008 e12fff3c
07-04 10:58:39.231: I/DEBUG(71): 80018378 e3550000 1594c00c 188c0003 e914a3f0
07-04 10:58:39.231: I/DEBUG(71): 80018388 e1a05e22 e5946004 e3a02000 e4d6c001
07-04 10:58:39.231: I/DEBUG(71): 80018398 e35c0000 0a000007 e2822001 e35c0044
07-04 10:58:39.231: I/DEBUG(71): stack:
07-04 10:58:39.231: I/DEBUG(71): bee7d308 000001b4
07-04 10:58:39.231: I/DEBUG(71): bee7d30c c0000000
07-04 10:58:39.231: I/DEBUG(71): bee7d310 80018540 /system/lib/libdvm.so
07-04 10:58:39.231: I/DEBUG(71): bee7d314 0000cf98
07-04 10:58:39.231: I/DEBUG(71): bee7d318 42157c6c
07-04 10:58:39.231: I/DEBUG(71): bee7d31c afd139d9 /system/lib/libc.so
07-04 10:58:39.231: I/DEBUG(71): bee7d320 0002de91
07-04 10:58:39.241: I/DEBUG(71): bee7d324 0000000e
07-04 10:58:39.241: I/DEBUG(71): bee7d328 80018540 /system/lib/libdvm.so
07-04 10:58:39.241: I/DEBUG(71): bee7d32c 00000070
07-04 10:58:39.241: I/DEBUG(71): bee7d330 42157c6c
07-04 10:58:39.241: I/DEBUG(71): bee7d334 00238100
07-04 10:58:39.241: I/DEBUG(71): bee7d338 00000000
07-04 10:58:39.241: I/DEBUG(71): bee7d33c 00000000
07-04 10:58:39.241: I/DEBUG(71): bee7d340 df002777
07-04 10:58:39.241: I/DEBUG(71): bee7d344 e3a070ad
07-04 10:58:39.241: I/DEBUG(71): #00 bee7d348 423692b4
07-04 10:58:39.241: I/DEBUG(71): bee7d34c 0000cf98
07-04 10:58:39.241: I/DEBUG(71): bee7d350 40521b98
07-04 10:58:39.241: I/DEBUG(71): bee7d354 8102de91 /data/data/ru.dzakhov.ffmpeg.test/lib/libmylib.so
07-04 10:58:39.241: I/DEBUG(71): bee7d358 80018540 /system/lib/libdvm.so
07-04 10:58:39.241: I/DEBUG(71): bee7d35c 0000cf98
07-04 10:58:39.241: I/DEBUG(71): bee7d360 bee7d368
07-04 10:58:39.241: I/DEBUG(71): bee7d364 800499df /system/lib/libdvm.so
07-04 10:58:39.241: I/DEBUG(71): bee7d368 42157c80
07-04 10:58:39.241: I/DEBUG(71): bee7d36c 42d58795
07-04 10:58:39.241: I/DEBUG(71): bee7d370 8102de91 /data/data/ru.dzakhov.ffmpeg.test/lib/libmylib.so
07-04 10:58:39.241: I/DEBUG(71): bee7d374 bee7d418
07-04 10:58:39.241: I/DEBUG(71): bee7d378 00016de0
07-04 10:58:39.241: I/DEBUG(71): bee7d37c 0000ac28
07-04 10:58:39.241: I/DEBUG(71): bee7d380 00000001
07-04 10:58:39.241: I/DEBUG(71): bee7d384 bee7d418
07-04 10:58:39.241: I/DEBUG(71): bee7d388 42157c80
07-04 10:58:39.241: I/DEBUG(71): bee7d38c 40521b98
07-04 10:58:39.241: I/DEBUG(71): bee7d390 423692b4
07-04 10:58:39.241: I/DEBUG(71): bee7d394 800499a1 /system/lib/libdvm.so
07-04 10:58:39.241: I/DEBUG(71): bee7d398 42157c80
07-04 10:58:39.241: I/DEBUG(71): bee7d39c 8004f13f /system/lib/libdvm.so
07-04 10:58:39.241: I/DEBUG(71): #01 bee7d3a0 00000002
07-04 10:58:39.251: I/DEBUG(71): bee7d3a4 0000000e
07-04 10:58:39.251: I/DEBUG(71): bee7d3a8 bee7d418
07-04 10:58:39.251: I/DEBUG(71): bee7d3ac 0000cf98
07-04 10:58:39.251: I/DEBUG(71): bee7d3b0 400198b8
07-04 10:58:39.251: I/DEBUG(71): bee7d3b4 42d5861c
07-04 10:58:39.251: I/DEBUG(71): bee7d3b8 42157c98
07-04 10:58:39.251: I/DEBUG(71): bee7d3bc bee7d410
07-04 10:58:39.251: I/DEBUG(71): bee7d3c0 40521b98
07-04 10:58:39.251: I/DEBUG(71): bee7d3c4 8001d588 /system/lib/libdvm.soUnable to understand what’s exact problem is there ?
Here SaveFrame function is used it looks like,void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
FILE *pFile;
char szFilename[32];
int y;
// Open file
LOGI("Opening file!");
sprintf(szFilename, "frame%d.ppm", iFrame);
pFile=fopen(szFilename, "wb");
if(pFile==NULL)
return;
// Write header
fprintf(pFile, "P6\n%d %d\n255\n", width, height);
//LOGI("width::"+width+"Height::"+height);
// Write pixel data
for(y=0; ydata[0]+y*pFrame->linesize[0], 1, width*3, pFile);
}
// Close file
fclose(pFile);
}in log I didn’t get any Log which i placed in the code !
Please help me out,
Thanks