
Recherche avancée
Autres articles (19)
-
Les statuts des instances de mutualisation
13 mars 2010, parPour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...) -
Qualité du média après traitement
21 juin 2013, parLe bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...) -
Installation en mode ferme
4 février 2011, parLe mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
C’est la méthode que nous utilisons sur cette même plateforme.
L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)
Sur d’autres sites (2593)
-
What’s new in Piwik 2.16.0 ?
In this blog post we showcase what is new in Piwik 2.16.0 and why you should upgrade your Piwik to this latest release !
Piwik 2.16.0 is currently in Release Candidate and you can already use it by following these simple instructions. Piwik 2.16.0 will be officially released in a few days.
To see the list of all 250+ changes, read the Piwik 2.16.0 changelog.
Long Term Support for Piwik 2.X
Piwik 2.16.0 is our Long Term Support version for Piwik 2. Learn more about Piwik LTS.
New : Custom Dimensions feature
With Custom Dimensions you can assign any custom data to your visitors or actions (like pages, events, …) and then visualize the reports of how many visits, conversions, pageviews, etc. there were for each Custom Dimension. They are similar to Custom Variables see the comparison of Custom Dimensions and Custom Variables.
The new Custom Dimensions plugin is available on the Piwik Marketplace.
Learn more about creating, tracking, reporting, managing, segmenting custom dimensions in the Custom Dimensions user guide.
View the list of all visitors who reached a specific goal
All Goal reports now include a link below the Goal report summary, that lets you see in one click all users that have converted any of your Goals :
Events reports : option to view all columns : min, max and avg values
By default in Actions > Events report, the columns displayed are “Total events” (Total number of events) and “Total value” (the sum of event values). It is now possible to click on the footer icon
to view more detailed columns about event values : minimum event value, maximum event value, and average event value.
Allow zoom to country in realtime visitor map
In the real time map in Piwik (which displays your users activity appearing in real time !), it is now possible to zoom on a given country :
Export all Records : new ‘all’ option in the Row limit selector
It is now possible to export all of the data in your reports directly from the user interface ! Select ‘all’ in the row limit selector before exporting your data reports :
New themes on the Marketplace !
Feel like a change of colors ? Try out the new community submitted Piwik Themes on the Marketplace ! Learn how to install a new theme in Piwik (in only a few clicks).
Let Super User view and edit segments created by other users
As a Super User of Piwik, it can be very useful to view all Custom Segments created by all users. Starting in Piwik 2.16.0 any Super User can now view all Segments for a given website in the Segment selector :
- Segments that are shared with All users will now appear below a section “Shared with you :” (a segment can be shared to all users by any admin user by selecting “This segment is visible to All Users” in the Segment editor)
- Segments that are not shared with anyone are now also visible under the section “Visible to you because you have Super User access :”
New segment ‘deviceBrand’ to segment by Device Brand
You can now segment by device brands such as Apple, Samsung, LG, Google, Nokia, Sony, Lenovo, Alcatel, etc. The complete list of device brands you can use is listed on the Segmentation developer guide.
New segment ‘actionType’ to view only particular Actions types (pagesviews, downloads, outlinks, events…)
Use the new “Action type” segment to view only particular actions such as : pageviews, contents, sitesearches, events, outlinks and downloads.
New segment : ‘actionUrl’ to view any actions that matches a given URL
Use the new “Action URL” segment to view any action that matches a given URL, whether they are Pageviews, Site searches, Contents, Downloads or Events.
New segment operators : “Starts with” and “Ends with”
The new segment operators “Starts with” and “Ends with” can come handy when creating Custom Segments, and complement well the existing segment operators : Contains, Does not contain, Equals, Not equals, Greater than or equal to, Less than or equal to.
Learn more about Segmentation in our user guides or in the Segmentation developer guide.
Making Piwik more accessible
Web accessibility refers to the inclusive practice of removing barriers that prevent interaction with, or access to applications or websites, by people with disabilities. When sites are correctly designed, developed and edited, all users have equal access to information and functionality.
In Piwik 2.16.0, and with the help of high school students from the Catalyst Academy, we have made several improvements that make Piwik more accessible :
- Menu now include the ARIA metadata (to make menus easier to navigate and use)
- Page titles and various key tooltips have been improved (to give a better context to the data)
- Keyboard access has been much improvement and Piwik is starting to be usable with the keyboard ! (this is very useful as many users are not able to use a mouse, and they should be able to view Piwik reports with the keyboard only)
- ‘Skip to main content’ link (when pressing the TAB key) now skips the cursor to the page content.
- Search bar was further improved : try it by pressing the ‘f’ key (useful to open any Piwik report or page without using the mouse)
New user preference : display times either as 24h format or AM/PM format
Users can now select whether times should be displayed in 24h format (16:20) or in AM/PM format (4:20pm)
Other admins and Super Users are not visible to users with ‘admin’ permissions anymore
Piwik 2.16.0 just became even more respectful of your privacy : any user you created and assigned an “admin” permission will not be able to view all other usernames anymore. This change was requested by many Piwik users who rightfully preferred not to disclose all usernames to any ‘admin’ user.
As a result of this change, when a user with ‘admin’ permission (admin user) wants to give additional permission to another user (target user), the admin user will now need to know the target username and enter it in the Manage Users interface :
New Config file viewer
A new menu entry Administration > Diagnostics > Config file, lets Super Users view all config values in the UI :
This new screen serves several purposes :
- help Piwik administrators discover and learn about all the possible config file settings that Piwik offers.
- let Super Users and Admins easily view any overridden config.ini.php INI setting without having to open the config file on the server.
New report ‘Personal settings > Custom Variables’ displays custom variable usage
A new report visible to Super Users lets you see how your Custom Variables slots are being used, which ones are still unused, and how many times a given custom variable name was used.
Learn more about Custom Variables.
Improvements to Heartbeat feature to accurately count time spent on the last page
The heartbeat feature which lets you accurately track how long do visitors spend on your website, has been improved in 2.16.0. If you would like to measure how long do people spend on your pages (even if they don’t interact with your website or app), then consider using the heartbeat feature. Learn more in our guide Accurately measure the time spent on each page.
New AnonymousPiwikUsageMeasurement plugin
AnonymousPiwikUsageMeasurement plugin was created for those who would like to measure how their Piwik services is being used. This plugin also sends anonymised tracking data to our demo-anonymous.piwik.org which will help us learn how your Piwik is used and how we could improve the application. Learn more about AnonymousPiwikUsageMeasurement plugin.
Show a warning when Piwik is used as a SuperUser via HTTP
It is highly recommended to use HTTPS (SSL) for your Piwik server. If you are logged in as a Super User and viewing any Administration pages, you will now see a warning notification message at the top of the screen inviting you to use HTTPS :
MySQL 5.7+ support
The awesome Piwik community has helped us identify several issues with MySQL 5.7 support and Piwik is now fully compatible with the latest MySQL version 5.7+. Piwik is officially compatible with MySQL >= 4.1 and up to Mysql 5.7 ! Piwik is also compatible with MariaDB.
Better detection of new devices and robots
Our Device Detector library can now detect many new types of devices : smart TVs, new tablets and mobile phones, and more. New bots were added to our list of bots to keep your analytics report meaningful.
Learn more : What Device Detector is able to detect, About Device Detector.
New Referrer Spammers
Every week we keep updating our community-list of referrer spammers. More than 50 new spammers were added since the last Piwik release !
Note that the list of referrer spammer is automatically updated every week in your Piwik, so you need to wait at most one week to benefit from the very latest list.
Learn more about Stopping Referrer Spam in Analytics reports.
Ability to support new SMS providers to send Scheduled Reports by text message
When you create scheduled reports in Piwik, you can specify one or several email addresses (to send reports by email) and you can also configure phone numbers (so your reports are sent to your phone via text message). So far we only support one SMS Provider “Clockwork SMS” but it is now possible for anyone to create a very simple plugin that adds a new SMS Provider to Piwik.
A new SMS Provider plugin was released on the Marketplace : FreeMobileMessaging. If you have a favorite SMS Provider, we encourage you to create a new plugin for it !
Piwik Consulting mentions
A few new mentions of Piwik Consultants were added into Piwik to let users know that they can get Professional Help, and additional services and products. For example a new widget was added to the default dashboard. If you provide your Piwik service to your own clients, maybe you would like to remove the Professional services widget and other ads, see this FAQ : How do I remove from Piwik the links to “Piwik Consultants” or to “Professional Services” ?
Stability, Reliability and Performance
Dozens of other bugs were fixed (including several Major bugs) and many small improvements are included in this release. All these changes make Piwik more stable and reliable, as well as easier to troubleshoot and maintain. We are proud to be able to offer Piwik 2.16.0 as our Long Term Support release !
If you have any feedback, questions, suggestion, or bug to report, please join our Piwik Community Forums.
We hope you will love this 2.16.0 release as much as we loved making it.
Happy Analytics !
-
"wrong sample count" When reading MP4 files using OpenCV
26 octobre 2022, par Object UnknownI want to marge some mp4 videos using OpenCV library, but when I try to read those videos using
cv::VideoCapture
, it outputs like that :

[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9AAE9D80] co located POCs unavailable
[h264 @ 000001EB9AAE7D80] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9A128600] co located POCs unavailable
[h264 @ 000001EB9A129840] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB9AA28E40] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9A169B00] co located POCs unavailable
[h264 @ 000001EB9A16B680] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB960CD680] co located POCs unavailable
[h264 @ 000001EB960CC8C0] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9A81DDC0] co located POCs unavailable
[h264 @ 000001EB9A81B000] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB960CB200] co located POCs unavailable
[h264 @ 000001EB960CBFC0] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB99F206C0] co located POCs unavailable
[h264 @ 000001EB99F20B40] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9A81D480] co located POCs unavailable
[h264 @ 000001EB9A81B000] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9AD02C00] co located POCs unavailable
[h264 @ 000001EB9AD02300] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9A81B480] co located POCs unavailable
[h264 @ 000001EB9A81B940] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[h264 @ 000001EB9AD02780] co located POCs unavailable
[h264 @ 000001EB9AD01E40] co located POCs unavailable
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001EB96084B80] wrong sample count



and just exited with exit value 0. I want to know why it is reporting this and how to solve it please.


Heres my demo code :


#include <string>
#include <iostream>
#include <opencv2></opencv2>core/core.hpp>
#include <opencv2></opencv2>video/video.hpp>
#include <opencv2></opencv2>imgproc/imgproc.hpp>
#include <opencv2></opencv2>videoio/videoio.hpp>
#include <opencv2></opencv2>highgui/highgui.hpp>

int main()
{
 cv::Mat frame;
 cv::VideoCapture vcap;
 for (int i = 1; i <= 60; i++)
 {
 if (!vcap.open("G:\\Users\\15819\\Desktop\\Demo\\demo (" + std::to_string(i) + ").mp4"))
 {
 std::cout << "Failed to Open File: demo (" << i << ").mp4" << std::endl;
 continue;
 }
 while (!vcap.read(frame))
 cv::imshow("video", frame);
 }
 return 0;
}
</iostream></string>


I installed the
OpenCV
andFFmpeg
library usingvcpkg
, here's the library information (displayed byvcpkg list
command) :

ffmpeg:x64-windows 4.4.1#21 a library to decode, encode, transcode, mux, dem...
ffmpeg:x86-windows 4.4.1#21 a library to decode, encode, transcode, mux, dem...
ffmpeg[avcodec]:x64-windows Build the avcodec library
ffmpeg[avcodec]:x86-windows Build the avcodec library
ffmpeg[avdevice]:x64-windows Build the avdevice library
ffmpeg[avdevice]:x86-windows Build the avdevice library
ffmpeg[avfilter]:x64-windows Build the avfilter library
ffmpeg[avfilter]:x86-windows Build the avfilter library
ffmpeg[avformat]:x64-windows Build the avformat library
ffmpeg[avformat]:x86-windows Build the avformat library
ffmpeg[openh264]:x64-windows H.264 de/encoding via openh264
ffmpeg[openh264]:x86-windows H.264 de/encoding via openh264
ffmpeg[swresample]:x64-windows Build the swresample library
ffmpeg[swresample]:x86-windows Build the swresample library
ffmpeg[swscale]:x64-windows Build the swscale library
ffmpeg[swscale]:x86-windows Build the swscale library
opencv4:x64-windows 4.6.0#6 computer vision library
opencv4:x86-windows 4.6.0#6 computer vision library
opencv4[default-features]:x64-windows Platform-dependent default features
opencv4[default-features]:x86-windows Platform-dependent default features
opencv4[dnn]:x64-windows Enable dnn module
opencv4[dnn]:x86-windows Enable dnn module
opencv4[ffmpeg]:x64-windows ffmpeg support for opencv
opencv4[ffmpeg]:x86-windows ffmpeg support for opencv
opencv4[jpeg]:x64-windows JPEG support for opencv
opencv4[jpeg]:x86-windows JPEG support for opencv
opencv4[png]:x64-windows PNG support for opencv
opencv4[png]:x86-windows PNG support for opencv
opencv4[qt]:x64-windows Qt GUI support for opencv
opencv4[qt]:x86-windows Qt GUI support for opencv
opencv4[quirc]:x64-windows Enable QR code module
opencv4[quirc]:x86-windows Enable QR code module
opencv4[tiff]:x64-windows TIFF support for opencv
opencv4[tiff]:x86-windows TIFF support for opencv
opencv4[webp]:x64-windows WebP support for opencv
opencv4[webp]:x86-windows WebP support for opencv
opencv:x64-windows 4.6.0 Computer vision library
opencv:x86-windows 4.6.0 Computer vision library
opencv[default-features]:x64-windows Platform-dependent default features
opencv[default-features]:x86-windows Platform-dependent default features
opencv[dnn]:x64-windows Enable dnn module
opencv[dnn]:x86-windows Enable dnn module
opencv[jpeg]:x64-windows JPEG support for opencv
opencv[jpeg]:x86-windows JPEG support for opencv
opencv[png]:x64-windows PNG support for opencv
opencv[png]:x86-windows PNG support for opencv
opencv[quirc]:x64-windows Enable QR code module
opencv[quirc]:x86-windows Enable QR code module
opencv[tiff]:x64-windows TIFF support for opencv
opencv[tiff]:x86-windows TIFF support for opencv
opencv[webp]:x64-windows WebP support for opencv
opencv[webp]:x86-windows WebP support for opencv



Other Environments :


OS: Windows 11 x64 Professional Workstation
IDE: Visual Studio 2022
Project C++ Standard: C++14
Project Platform: x64 Release



-
value of got_picture_ptr is always 0. when use avcodec_decode_video2()
4 septembre 2014, par user3867261I’m using visual studio 2013 professional.
below code is simple decode tutorial using ffmpeg.
///> Include FFMpeg
extern "C" {
#include <libavformat></libavformat>avformat.h>
}
///> Library Link On Windows System
#pragma comment( lib, "avformat.lib" )
#pragma comment( lib, "avutil.lib" )
#pragma comment( lib, "avcodec.lib" )
static void write_ascii_frame(const char *szFileName, const AVFrame *pVframe);
int main(void)
{
const char *szFilePath = "C:\\singlo\\example.avi";
///> Initialize libavformat and register all the muxers, demuxers and protocols.
av_register_all();
///> Do global initialization of network components.
avformat_network_init();
int ret;
AVFormatContext *pFmtCtx = NULL;
///> Open an input stream and read the header.
ret = avformat_open_input( &pFmtCtx, szFilePath, NULL, NULL );
if( ret != 0 ) {
av_log( NULL, AV_LOG_ERROR, "File [%s] Open Fail (ret: %d)\n", ret );
exit( -1 );
}
av_log( NULL, AV_LOG_INFO, "File [%s] Open Success\n", szFilePath );
av_log( NULL, AV_LOG_INFO, "Format: %s\n", pFmtCtx->iformat->name );
///> Read packets of a media file to get stream information.
ret = avformat_find_stream_info( pFmtCtx, NULL );
if( ret < 0 ) {
av_log( NULL, AV_LOG_ERROR, "Fail to get Stream Information\n" );
exit( -1 );
}
av_log( NULL, AV_LOG_INFO, "Get Stream Information Success\n" );
///> Find Video Stream
int nVSI = -1;
int nASI = -1;
int i;
for( i = 0 ; i < pFmtCtx->nb_streams ; i++ ) {
if( nVSI < 0 && pFmtCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ) {
nVSI = i;
}
else if( nASI < 0 && pFmtCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO ) {
nASI = i;
}
}
if( nVSI < 0 && nASI < 0 ) {
av_log( NULL, AV_LOG_ERROR, "No Video & Audio Streams were Found\n");
exit( -1 );
}
///> Find Video Decoder
AVCodec *pVideoCodec = avcodec_find_decoder( pFmtCtx->streams[nVSI]->codec->codec_id );
if( pVideoCodec == NULL ) {
av_log( NULL, AV_LOG_ERROR, "No Video Decoder was Found\n" );
exit( -1 );
}
///> Initialize Codec Context as Decoder
if( avcodec_open2( pFmtCtx->streams[nVSI]->codec, pVideoCodec, NULL ) < 0 ) {
av_log( NULL, AV_LOG_ERROR, "Fail to Initialize Decoder\n" );
exit( -1 );
}
///> Find Audio Decoder
AVCodec *pAudioCodec = avcodec_find_decoder( pFmtCtx->streams[nASI]->codec->codec_id );
if( pAudioCodec == NULL ) {
av_log( NULL, AV_LOG_ERROR, "No Audio Decoder was Found\n" );
exit( -1 );
}
///> Initialize Codec Context as Decoder
if( avcodec_open2( pFmtCtx->streams[nASI]->codec, pAudioCodec, NULL ) < 0 ) {
av_log( NULL, AV_LOG_ERROR, "Fail to Initialize Decoder\n" );
exit( -1 );
}
AVCodecContext *pVCtx = pFmtCtx->streams[nVSI]->codec;
AVCodecContext *pACtx = pFmtCtx->streams[nASI]->codec;
AVPacket pkt;
AVFrame* pVFrame, *pAFrame;
int bGotPicture = 0; // flag for video decoding
int bGotSound = 0; // flag for audio decoding
int bPrint = 0; // ë¹ëì¤ ì²« ì¥ë©´ë§ íì¼ë¡ ë¨ê¸°ê¸° ìí ìì flag ìëë¤
pVFrame = avcodec_alloc_frame();
pAFrame = avcodec_alloc_frame();
while( av_read_frame( pFmtCtx, &pkt ) >= 0 ) {
///> Decoding
if( pkt.stream_index == nVSI ) {
if( avcodec_decode_video2( pVCtx, pVFrame, &bGotPicture, &pkt ) >= 0 ) {
///////////////////////problem here/////////////////////////////////////////////
if( bGotPicture ) {
///> Ready to Render Image
av_log( NULL, AV_LOG_INFO, "Got Picture\n" );
if( !bPrint ) {
write_ascii_frame( "output.txt", pVFrame );
bPrint = 1;
}
}
}
// else ( < 0 ) : Decoding Error
}
else if( pkt.stream_index == nASI ) {
if( avcodec_decode_audio4( pACtx, pAFrame, &bGotSound, &pkt ) >= 0 ) {
if( bGotSound ) {
///> Ready to Render Sound
av_log( NULL, AV_LOG_INFO, "Got Sound\n" );
}
}
// else ( < 0 ) : Decoding Error
}
///> Free the packet that was allocated by av_read_frame
av_free_packet( &pkt );
}
av_free( pVFrame );
av_free( pAFrame );
///> Close an opened input AVFormatContext.
avformat_close_input( &pFmtCtx );
///> Undo the initialization done by avformat_network_init.
avformat_network_deinit();
return 0;
}
static void write_ascii_frame(const char *szFileName, const AVFrame *frame)
{
int x, y;
uint8_t *p0, *p;
const char arrAsciis[] = " .-+#";
FILE* fp = fopen( szFileName, "w" );
if( fp ) {
/* Trivial ASCII grayscale display. */
p0 = frame->data[0];
for (y = 0; y < frame->height; y++) {
p = p0;
for (x = 0; x < frame->width; x++)
putc( arrAsciis[*(p++) / 52], fp );
putc( '\n', fp );
p0 += frame->linesize[0];
}
fflush(fp);
fclose(fp);
}
}there is a problem in below part
if( avcodec_decode_video2( pVCtx, pVFrame, &bGotPicture, &pkt ) >= 0 ) {
///////////////////////problem here/////////////////////////////////////////////
if( bGotPicture ) {
///> Ready to Render Image
av_log( NULL, AV_LOG_INFO, "Got Picture\n" );
if( !bPrint ) {
write_ascii_frame( "output.txt", pVFrame );
bPrint = 1;
}
}
}the value of bGotPicture is always 0.. So i can’t decode video
plz help me.
where do problem occurs from ? in video ? in my code ?