Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (31)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately 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 (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (7755)

  • Matomo vs WP-Statistics – which web analytics plugin suits you best ?

    2 avril 2020, par Joselyn Khor — Analytics Tips, Plugins

    Due to the endless choices, you may be wondering which web analytics plugin (GA, Slimstat or WP-Statistics) to choose from on the WordPress directory. If the choice is between WP-Statistics and Matomo for WordPress, we’ve got you covered. Have a look at which could be the best option for you. Our team tested the WP-Statistics plugin to see how it compares. It’s hard not to be biased, but we’ll try our best to give you a fair assessment.

    The main considerations in this article : 

    General overview

    What’s Matomo Analytics for WordPress ?

    Matomo for WordPress is a free, privacy-friendly web analytics plugin that lets you understand website visitors and how they behave on your site. With comprehensive insights, you get the opportunity to increase conversions, and the know-how to improve your website. 

    It lets you undertake essential analysis by tracking information, such as, where visitors are coming from, what your most popular pages are, and how visitors are using your site.

    In addition to the fundamentals, the tool also allows for advanced tracking and analysis with features that give you a full understanding of behavioural patterns and website performance. This enables you to optimise your WordPress website to increase sales or engagement.

    It offers a complete analytics package with the bonuses of 100% data ownership, no data sampling, and GDPR compliance. 

    What’s WP-Statistics ?

    WP-Statistics is currently the most used self-hosted WordPress statistics plugin. It provides reports that let you analyse who your visitors are, where they’re coming from, and to an extent what they’re doing on your website.

    Like Matomo for WordPress, it gives you an understanding of your audience which helps you make decisions on how to improve your website for more conversions. 

    As it’s self-hosted on your own WordPress servers it can be seen as a privacy-friendly choice with a few tweaks (more on this below).

    Like Matomo for WordPress, it gives you an understanding of your audience which helps you make decisions on how to improve your website for more conversions. 

    General comparison

    Let’s compare the installation process and the dashboards that get installed in your WordPress.

    Installation

    Both Matomo and WP-Statistics are installed directly in your WordPress so you’ll be able to see your analytics reports right in your WordPress dashboard. You can install them both straight from the WordPress Directory.

    The installation process for both plugins is beginner-friendly. You simply need to find them on the WordPress directory, click on ‘Install Now’, and tracking should start immediately in your WordPress dashboard.

    Dashboard

    For the main Matomo platform you’ll see :

    • Visitors – Overview, Visits Log, Real-time, Real-time Map, Locations, Devices, Software, Times, User IDs, Custom Variables, User Type
    • Behaviour – Pages, Entry Pages, Exit Pages, Page titles, Site Search, Outlinks, Downloads, Events, Contents, Engagement, Transitions, Users Flow, Top Paths, Page Author, Page Location, Page Type, Crawling errors
    • Acquisition – Overview, All Channels, Search Engine & Keywords, Websites, Social Networks, Campaigns, Campaign URL Builder, Crawling overview
    • Ecommerce – Overview, Ecommerce Log, Products, Sales, Multi Attribution
    • Goals – Overview, Multi Attribution, Choose Goals, Manage Goals
    • These may be worded differently from WP-Statistics, but they show you all the information you need to know about your traffic, pages, etc.
    Previous
    Next

    In the dashboard for WP-Statistics you’ll see :

    • Overview, Hits, Online, Referrers, Search Words, Search Engines, Pages, Visitors, Categories, Tags, Authors, Browsers, Top Visitors Today
    • These are the only things you can see in the dashboard. So you can’t click into them for a drop down section to get deeper insights. 
    •  
    WP-Statistics dashboard

    Key similarities between Matomo and WP-Statistics

    • Free to use
    • Self-hosted – All data collected is stored only within your own servers, no third parties have rights over your data, and logs or report data will never be sent to other servers. 
    • Beginner-friendly – Both offer simple reporting for people who are very much beginners and only want basic insights. With Matomo the advantage is also that you can get more details should you ever want/need to.

    Key differences between Matomo and WP-Statistics

    The main differences fall in these categories : features, privacy, documentation/support, security, active development, extensibility, price and ads.

    Features : 

    WP-Statistics – On a fundamental level, WP-Statistics is focused on simplicity and the basics. There are fewer reports than Matomo and they function on a level that suits beginners who are interested in seeing only the numbers of visitors on the website, and how often each page is viewed. 

    Matomo – provides an interface with similar simplicity. However, there is also a more feature-rich and more comprehensive user interface available. In addition to the basics, Matomo offers features like Goals, Ecommerce, in the free version which show a deeper level of insight. WP Statistics does not let you track essentials like Goals or Ecommerce.

    Privacy : 

    WP-Statistics – One of the concerns we wish to raise here is for data privacy. There doesn’t appear to be an opt-out option in WP-Statistics, which could be problematic for some privacy laws such as GDPR. There’s also no documentation on this.

    We were a bit concerned to see that WP-Statistics didn’t have IP anonymization enabled by default. Considering the IP address is personal data, it means you are not compliant with privacy laws such as the GDPR when you use this plugin unless you tweak the settings. They mentioned : “In previous versions, there was an option called Hash IP. When Hash IP was activated, the IP addresses wouldn’t be stored in the database, but instead, a unique hash would be used. In this new version, an option has been added to store IPs anonymously. This option is active by default.” However, when we installed this and tested it on multiple WordPress installations, this option was not active by default. 

    Matomo – has more measures in place to ensure privacy is respected, such as, opt-outs. Due to the stringent privacy features in place, Matomo is well equipped to ensure GDPR compliance. Matomo has an abundance of user guides and FAQs you can follow to configure your platform to fully comply with GDPR. There’s even an 12-step compliant checklist. The most compelling proof is that the leading voice on GDPR – The European Commission uses Matomo Analytics. 

    Documentation/Support : 

    WP-Statistics – has little documentation, FAQs, and no support.

    Matomo – has thousands of FAQs and user guides, as well as a dedicated support team and forum you can turn to for help. Should you ever run into any issue, this might be something important to consider.

    The contrast in support between WP-Statistics and Matomo for WordPress :

    statistics for wordpress
    WP-Statistics support
    wordpress statistics
    Matomo Analytics support

    Security :

    Matomo takes protecting your data very seriously. We have a security bounty programme giving security researchers money should they find any security issues. Matomo also performs a security review for every new release. We couldn’t find anything similar in WP-Statistics.

    Active development : 

    WP Statistics – doesn’t seem to have active development. The last change in this plugin was over three months ago (source : https://github.com/wp-statistics/wp-statistics/commits/master) and in general, only 10 people really contributed to it (source : https://github.com/wp-statistics/wp-statistics/graphs/contributors, the graphs shows little contributor activity.) 

    Matomo – has been built by hundreds of contributors (source : https://github.com/matomo-org/matomo/graphs/contributors), and is actively maintained by multiple developers including developers who work on this full time. This means you can rest assured that Matomo will be there for you in the future, it will receive regular improvements.

    Extensibility :

    WP-Statistics – have a section on their website offering customisation but for a price. 

    Matomo – should you want any changes and have some developer knowledge or some developers at hand, you can completely customise and extend Matomo for free. There are also one hundred additional plugins available for Matomo for free. 

    Price :

    The main WordPress plugins ‘WP Statistics‘ and ‘Matomo Analytics – Ethical Stats. Powerful Insights.‘ are both free.

    WP Statistics and Matomo also sell paid add-ons. However, WP-Statistics’ paid add-ons are ones already integrated in Matomo for free. These basic features are provided as the development team believe they’re necessities to a fully functional analytics platform. 

    Ads :

    WP Statistics shows you ads, whereas Matomo doesn’t.

    Three most notable feature category comparisons

    Both Matomo and WP-Statistics have basic tracking categories in the WP dashboard. In addition, Matomo has feature categories that can be expanded e.g. when clicked, Visitors drops down to reveal 11 more features. 

    We’ll compare three feature categories : Visitors, Behaviour, and Acquisitions.

    1. Visitors (WP-Statistics) vs Visitors (Matomo)

    Let’s dive into how each analytics platform provides insight into the visitors feature category.

    WP-Statistics

    WP-Statistics visitors

    WP-Statistics – We can see WP-Statistics gives you bare bones tracking capabilities so you don’t get a really detailed picture of your visitors. It allows you to monitor users currently online in real-time, which is useful to look at the most recent activity on your site. WP-Statistics doesn’t offer a dropdown section to see more about your visitor’s behavioural patterns. There is no Visitors category in WP-Statistics, just individual features in the dashboard but we can group three options together to compare with Matomo’s Visitors category, these are : Online, Browsers, Top Visitors Today.

    Matomo

    WordPress analytics visitors
    WordPress analytics visit log

    Comparison

    Matomo – In comparison, Matomo has a Visitors category with a dropdown list that lets you drill deeper into what your visitors are doing. It lets you evaluate every action an individual user has taken on your website which is compiled into a full historical profile. Matomo gives an in-depth view. E.g. you can look at individual visit logs, locations, and devices.

    This lets you see what the life-time journey of an active user looks like, or perhaps you want to see what a profile looks like for a user who comes back time-and-time again without ever purchasing ; there is no better way to gain insights to these journeys and this is why the Visitor Profiles feature is so widely used by Matomo users.

    2. Pages tracking (WP-Statistics) vs Behaviour (Matomo)

    For this comparison, WP-Statistics has a few features that can be combined to compare with Matomo’s Behaviour category. 

    WP-Statistics

    WP-Statistics pages

    The Pages section in WP-Statistics gives a basic look at your most popular pages so you know which pages get more visits and those which aren’t performing. This helps with content improvement. You can also see other features in this Behaviour category like Browsers and Hits – these also provide basic stats to help you get a general sense of visitor behaviour. 

    Matomo

    Analytics for WordPress behaviours

    Comparison :

    Matomo on the other hand has stats that go into greater detail. The features under the Behaviour section of the tool let you draw actionable conclusions e.g. seeing that a page has a higher exit rate than it’s supposed to, so you optimise that page to prevent people leaving and help them progress through your website. 

    Not only can you see popular pages, you can look at : which page people viewed first when they visited your website ; which page they left from ; what people search for on your site ; and see how people are flowing through pages. Most importantly you can see how each of these reports perform over time so you can improve engagement and conversions on your website.

    3. Referrers (WP-Statistics) vs Acquisition (Matomo)

    For this comparison, WP-Statistics has a few features that can be combined to compare with Matomo’s Acquisition category. 

    WP-Statistics

    WP-Statistics gives you Referrers, Search Words, and Search Engines. Which give a basic understanding of the channels that work best for you. This is helpful to know where to focus more of your attention.

    Matomo

    WordPress analytics acquisition

    Comparison :

    With Matomo you see multiple layers of stats to understand how your acquisition channels are performing. So you can see tables of data that drill into visits, downloads, bounce rate, and newsletter sign ups. For example seeing that Facebook is the channel bringing in the most visitors to your site. This gives you a better sense of which acquisition strategy is working for your site. 

    Who suits WP-Statistics

    This is a great starter pack for people who want a lightweight, functional statistics plugin that gives you a basic overview of website hits and visitors. It’s very easy to use, so it’s great for beginners and those who want simple tracking. If you have basic goals for your website or blog’s success then WP-Statistics is enough for you to get numbers on visitors, page views, and hits, but won’t be suitable for a larger-scale business or organisation. 

    It’s suited for hobby websites, blogs, and freelancers who want simple, effective stats tracking, who don’t need detailed insights on site performance or tracking. 

    Who suits Matomo

    Matomo can be used for the same basic reporting, but has the capability for you to go deeper into more advanced reporting in a different UI if you need it. It’s an option that can work for a wider range of users – from beginners to analysts. There are features to suit all skill levels. This complete suite of features makes it a more comprehensive tool, as you can get more out of it. Ideal not only for bloggers and beginners, but also powerful enough to suit businesses, privacy-respecting organisations, and those who would benefit from conversion optimisation features. 

    You can draw insights from all stages of the customer journey – you’ll track behavioural patterns as soon as visitors enter your site, to their progression through your site, and ultimately to conversion and exit. It’s also an ethical choice because you get 100% data ownership. 

    If you’d like to look deeper into your data then Matomo would also be suitable for you. Matomo’s UI is lean, very easy to learn and shouldn’t overwhelm users in the way another tool like Google Analytics might do. If you think Matomo suits you best, you can install it for free now.

    Advantages of using Matomo

    Truly privacy-respecting

    There’s no messing about when it comes to privacy. As a lot of users are based in Europe, Matomo adheres to the strictest privacy laws and can be counted on as a privacy-respecting tool that’s used by many government entities. Needing to comply with major privacy laws (GDPR) in Europe means Matomo can proudly ensure users are making the ethical choice.

    GDPR compliance

    You mitigate the risks of getting caught out and fined for breaching GDPR regulations. There’s a complete list of documentation, guides, information, and tools to make sure you’re on the right side of GDPR. 

    All-rounder

    Matomo gives you a clearer picture of your visitors which helps you make better decisions for your website overall. The support and documentation is thorough which means you get more out of your Matomo experience.

    Conclusion

    Both tools will do you justice in terms of fundamental reporting, but Matomo Analytics will outshine if you want a greater understanding of your website and want to carry out deeper levels of analysis.

    You can draw useful insights with WP-Statistics so it has to be said that they are doing something right with an entry-level offering. The simplicity is great, but you won’t really get more than a basic idea of how your site is performing.

    On the flipside, this simplicity could also be a double-edged sword for WP-Statistics in that it’s too simplistic to draw actionable insights. If you’re wanting to know anything that could increase sales, conversions or subscribers – then you wouldn’t really get the reports to do so. 

    WP-Statistics also falls short when it comes to updates and support. So a major difference can be seen in support, active development, ads, security, documentation, which many people may think about until they’re in trouble and find they need these resources. Matomo offers support, continuous product development, and extensive documentation. There are also no ads, making it more enjoyable to use.

    One thing we’d like to raise awareness about is WP-Statistics’ claims of being privacy-respecting without much documentation to back up those claims. There is a lack of privacy features which could put some website owners at risk of non-compliance. Just be sure to check that you’ve carried out the steps to comply with the privacy laws in your country.

    Matomo makes it clear that privacy is essential as is compliance to privacy laws like GDPR. The strength also lies in the peace of mind you get from a tool that’s used by global privacy leaders such as the European Commission. 

  • FFmpeg - Audio encoding produces extra noise over audio

    17 mai 2020, par user3208915

    I am trying to use FFmpeg to take a video (MP4 in this case) and copy it as another MP4. This is so that I can get the hang of decoding/encoding a video and go on to doing other things in that process. My code basically takes a video file, decodes the video and audio streams, and encodes the video and audio streams to an output video file.

    



    As of now, my code only works for the video stream of the input file. The video part of the output file is exactly the same as the video part of the input file. However, the audio part is not. The audio part of the output contains the original audio, but with noise over it. Think of it as someone screaming into their mic or when audio gets too loud for a speaker to handle.

    



    The way I'm handling the decoding/encoding process for the video and audio streams is the same, except with a difference in AVCodecContext settings (video —> frame_rate, width, height, etc. ; audio —> sample_rate, channels, etc.).

    



    This is currently the code that I'm working with :

    



    The Video struct :

    



    typedef struct Video {
    AVFormatContext* inputContext;
    AVFormatContext* outputContext;
    AVCodec* videoCodec;
    AVCodec* audioCodec;
    AVStream* inputStream;
    AVStream* outputStream;
    AVCodecContext* videoCodecContext_I; // Input
    AVCodecContext* audioCodecContext_I; // Input
    AVCodecContext* videoCodecContext_O; // Output
    AVCodecContext* audioCodecContext_O; // Output
    int videoStream; // Video stream index
    int audioStream; // Audio stream index
} Video;


    



    The main code that handles the encoding/decoding (I've only included the audio side since the video side is the same) :

    



    int openVideo(Video* video, char* filename, char* outputFile) {
    video->inputContext = avformat_alloc_context();
    if (!video->inputContext) {
        printf("[ERROR] Failed to allocate input format context\n");
        return -1;
    }
    if (avformat_open_input(&(video->inputContext), filename, NULL, NULL) < 0) {
        printf("[ERROR] Could not open the input file\n");
        return -1;
    }

    if (avformat_find_stream_info(video->inputContext, NULL) < 0) {
        printf("[ERROR] Failed to retrieve input stream info\n");
        return -1;
    }
    avformat_alloc_output_context2(&(video->outputContext), NULL, NULL, outputFile);
    if (!video->outputContext) {
        printf("[ERROR] Failed to create output context\n");
        return -1;
    }
    printf("[OPEN] Video %s opened\n", filename);
    return 0;
}

int prepareStreamInfo(AVCodecContext** codecContext, AVCodec** codec, AVStream* stream) {
    *codec = avcodec_find_decoder(stream->codecpar->codec_id);
    if (!*codec) {
        printf("[ERROR] Failed to find input codec\n");
        return -1;
    }
    *codecContext = avcodec_alloc_context3(*codec);
    if (!codecContext) {
        printf("[ERROR] Failed to allocate memory for input codec context\n");
        return -1;
    }
    if (avcodec_parameters_to_context(*codecContext, stream->codecpar) < 0) {
        printf("[ERROR] Failed to fill input codec context\n");
        return -1;
    }
    if (avcodec_open2(*codecContext, *codec, NULL) < 0) {
        printf("[ERROR] Failed to open input codec\n");
        return -1;
    }
    return 0;
}

int findStreams(Video* video, char* filename, char* outputFile) {
    if (openVideo(video, filename, outputFile) < 0) {
        printf("[ERROR] Video %s failed to open\n", filename);
        return -1;
    }
    for (int i = 0; i < video->inputContext->nb_streams; i++) {
        video->inputStream = video->inputContext->streams[i];
        if (video->inputContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
            video->videoStream = i;
            if (prepareStreamInfo(&(video->videoCodecContext_I), &(video->videoCodec), video->inputStream) < 0) {
                printf("[ERROR] Could not prepare video stream information\n");
                return -1;video->outputStream->time_base = video->audioCodecContext_O->time_base;
            }
        } else if (video->inputContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
            video->audioStream = i;
            if (prepareStreamInfo(&(video->audioCodecContext_I), &(video->audioCodec), video->inputStream) < 0) {
                printf("[ERROR] Could not prepare audio stream information\n");
                return -1;
            }
        }
        video->outputStream = avformat_new_stream(video->outputContext, NULL);
        if (!video->outputStream) {
            printf("[ERROR] Failed allocating output stream\n");
            return -1;
        }
        if (avcodec_parameters_copy(video->outputStream->codecpar, video->inputStream->codecpar) < 0) {
            printf("[ERROR] Failed to copy codec parameters\n");
            return -1;
        }
    }
    if (video->videoStream == -1) {
        printf("[ERROR] Video stream for %s not found\n", filename);
        return -1;
    }
    if (video->audioStream == -1) {
        printf("[ERROR] Audio stream for %s not found\n", filename);
        return -1;
    }
    if (!(video->outputContext->oformat->flags & AVFMT_NOFILE)) {
    if (avio_open(&(video->outputContext->pb), outputFile, AVIO_FLAG_WRITE) < 0) {
      printf("Could not open output file %s", outputFile);
      return -1;
    }
  }
    return 0;
}

int prepareAudioOutStream(Video* video) {
    video->audioCodec = avcodec_find_encoder_by_name("mp2");
    if (!video->audioCodec) {
        printf("[ERROR] Failed to find audio output codec\n");
        return -1;
    }
    video->audioCodecContext_O = avcodec_alloc_context3(video->audioCodec);
    if (!video->audioCodecContext_O) {
        printf("[ERROR] Failed to allocate memory for audio output codec context\n");
        return -1;
    }
    // Quite possibly the issue
    video->audioCodecContext_O->channels = video->audioCodecContext_I->channels;
    video->audioCodecContext_O->channel_layout = av_get_default_channel_layout(video->audioCodecContext_O->channels);
    video->audioCodecContext_O->sample_rate = video->audioCodecContext_I->sample_rate;
    video->audioCodecContext_O->sample_fmt = video->audioCodec->sample_fmts[0];
    video->audioCodecContext_O->bit_rate = video->audioCodecContext_I->bit_rate;
    video->audioCodecContext_O->time_base = video->audioCodecContext_I->time_base;
    video->audioCodecContext_O->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
    if (avcodec_open2(video->audioCodecContext_O, video->audioCodec, NULL) < 0) {
        printf("[ERROR] Failed to open audio output codec\n");
        return -1;
    }
    if (avcodec_parameters_from_context(getAudioStream(video)->codecpar, video->audioCodecContext_O) < 0) {
        printf("[ERROR] Failed to fill audio stream\n");
        return -1;
    }
    return 0;
}

int decodeAudio(Video* video, AVPacket* packet, AVFrame* frame) {
    int response = avcodec_send_packet(video->audioCodecContext_I, packet);
    if (response < 0) {
        printf("[ERROR] Failed to send audio packet to decoder\n");
        return response;
    }
    while (response >= 0) {
        response = avcodec_receive_frame(video->audioCodecContext_I, frame);
        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {
            break;
        } else if (response < 0) {
            printf("[ERROR] Failed to receive audio frame from decoder\n");
            return response;
        }
        if (response >= 0) {
            // Do stuff and encode
            if (encodeAudio(video, frame) < 0) {
                printf("[ERROR] Failed to encode new audio\n");
                return -1;
            }
        }
        av_frame_unref(frame);
    }
    return 0;
}

int encodeAudio(Video* video, AVFrame* frame) {
    AVPacket* packet = av_packet_alloc();
    if (!packet) {
        printf("[ERROR] Could not allocate memory for audio output packet\n");
        return -1;
    }
    int response = avcodec_send_frame(video->audioCodecContext_O, frame);
    if (response < 0) {
        printf("[ERROR] Failed to send audio frame for encoding\n");
        return response;
    }
    while (response >= 0) {
        response = avcodec_receive_packet(video->audioCodecContext_O, packet);
        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {
            break;
        } else if (response < 0) {
            printf("[ERROR] Failed to receive audio packet from encoder\n");
            return response;
        }
        packet->stream_index = video->audioStream;
        video->inputStream = getAudioStream(video);
        video->outputStream = video->outputContext->streams[packet->stream_index];
        packet->pts = av_rescale_q_rnd(packet->pts, video->inputStream->time_base, video->outputStream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
        packet->dts = av_rescale_q_rnd(packet->dts, video->inputStream->time_base, video->outputStream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
        packet->duration = av_rescale_q(packet->duration, video->inputStream->time_base, video->outputStream->time_base);
        packet->pos = -1;
        //av_packet_rescale_ts(packet, video->inputStream->time_base, video->outputStream->time_base);

        response = av_interleaved_write_frame(video->outputContext, packet);
        if (response < 0) {
            printf("[ERROR] Failed to write audio packet\n");
            break;
        }
    }
    av_packet_unref(packet);
    av_packet_free(&packet);
    return 0;
}

int readFrames(Video* video, AVPacket* packet, AVFrame* frame) {
    if (!packet) {
        printf("[ERROR] Packet not allocated to be read\n");
        return -1;
    }
    if (!frame) {
        printf("[ERROR] Frame not allocated to be read\n");
        return -1;
    }
    if (prepareVideoOutStream(video) < 0) {
        printf("[ERROR] Failed to prepare output video stream\n");
        return -1;
    }
    if (prepareAudioOutStream(video) < 0) {
        printf("[ERROR] Failed to prepare output audio stream\n");
        return -1;
    }
    int frameNum = 0;
    while (av_read_frame(video->inputContext, packet) >= 0) {
        printf("[READ] Reading frame %i\n", frameNum);
        if (packet->stream_index == video->videoStream) {
            if (decodeVideo(video, packet, frame) < 0) {
                printf("[ERROR] Failed to decode and encode video\n");
                return -1;
            }
        } else if (packet->stream_index == video->audioStream) {
            if (decodeAudio(video, packet, frame) < 0) {
                printf("[ERROR] Failed to decode and encode audio\n");
                return -1;
            }
        }
        av_packet_unref(packet);
        frameNum++;
    }
    // Flush encoder
    encodeVideo(video, NULL);
    encodeAudio(video, NULL);
    av_write_trailer(video->outputContext);
    return 0;
}


    



    My main method that runs all the functions :

    



    int main(int argc, char* argv[]) {
    Video* video = (Video*)malloc(sizeof(Video));
    initVideo(video);
    if (findStreams(video, argv[1], argv[2]) < 0) {
        printf("[ERROR] Could not find streams\n");
        return -1;
    }

    AVDictionary* dic = NULL;
    if (avformat_write_header(video->outputContext, &dic) < 0) {
        printf("[ERROR] Error while writing header to output file\n");
        return -1;
    }
    AVFrame* frame = av_frame_alloc();
    AVPacket* packet = av_packet_alloc();
    if (readFrames(video, packet, frame) < 0) {
        printf("[ERROR] Failed to read and write new video\n");
        return -1;
    }
    freeVideo(video); // Frees all codecs and contexts and the video
    return 0;
}


    



    I tried to lay out my code so that it can be read from top to bottom without needing to scroll up.

    



    I realize that when copying a video, I can just pass the AVPacket to write to the output file, but I wanted to be able to work with the AVFrame in the future, so I wrote it this way. I have a feeling that the issue with the way my audio is behaving is because of the audio output AVCodecContext from the prepareAudioOutStream() function.

    



    Reading the FFmpeg documentation has proved to be of little help with this issue as well as other online sources. I must be missing something (or have something unneeded) so anything that would point me in the right direction would be helpful.

    



    Thank you.

    


  • Add subtitles to multiple files at once

    20 mai 2020, par Paul Filipenco

    I have a folder with episodes called ep and a folder with subtitles called sub
    
Each episode has corresponding subtitles and i need to bulk add them with ffmpeg.

    



    I've read that i can add subtitles with the following command :

    



    ffmpeg -i video.avi -vf "ass=subtitle.ass" out.avi


    



    But that only does it one file at a time.
    
Is there a bulk variant ?

    



    Some useful info :
    
ls ep prints

    



    <series> - Ep<episode number="number">.mkv&#xA;</episode></series>

    &#xA;&#xA;

    ls sub prints

    &#xA;&#xA;

    <series> - Ep<episode number="number">.ass&#xA;</episode></series>

    &#xA;