Recherche avancée

Médias (91)

Autres articles (88)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (13690)

  • Web Analytics : The Quick Start Guide

    25 janvier 2024, par Erin

    You’ve spent ages carefully designing your website, crafting copy to encourage as many users as possible to purchase your product. 

    But they aren’t. And you don’t know why. 

    The good news is you don’t have to remain in the dark. Collecting and analysing web analytics lets you understand how your users behave on your site and why they aren’t converting. 

    But before you can do that, you need to know what those metrics and KPIs mean. That’s why this article is taking things back to basics. Below, we’ll show you which metrics to track, what they mean and how to choose the best web analytics platform. 

    What is web analytics ?

    Web analytics is the process of collecting, analysing and reporting website data to understand how users behave on your website. Web analytics platforms like Matomo collect this data by adding a code line to every site page. 

    Why is it important to track web analytics ?

    There are plenty of reasons you should start tracking web analytics, including the following :

    Why is it important to track web analytics?

    Analyse user behaviour

    Being able to analyse user behaviour is the most important reason to track website analytics. After all, you can’t improve your website’s conversion rate if you don’t know what users do on your site.

    A web analytics platform can show you how users move around your site, the links they click on and the forms they fill in. 

    Improve site experience

    Web analytics is a fantastic way to identify issues and find areas where your site could improve. You could look at your site’s exit pages, for example, and see why so many users leave your site when viewing one of these pages and what you can do to fix it.

    It can also teach you about your user’s preferences so you can improve the user experience in the future. Maybe they always click a certain type of button or prefer one page’s design over another. Whatever the case, you can use the data to make your site more user-friendly and increase conversions.

    Boost marketing efforts

    Web analytics is one of the best ways to understand your marketing efforts and learn how to improve them.

    A good platform can collect valuable data about your marketing campaigns, including :

    • Where users came from
    • What actions these users take on your site
    • Which traffic sources create the most conversions

    This information can help you decide which marketing campaigns send the best users to your site and generate the highest ROI. 

    Make informed decisions

    Ultimately, web analytics simplifies decision-making for your website and marketing efforts by relying on concrete data instead of guesswork.

    Rather than wonder why users aren’t adding products to their shopping cart or signing up for your newsletter, you can analyse how they behave and use that information to hypothesise how you can improve conversions. Web analytics will even give you the data to confirm whether you were right or wrong. 

    What are the key metrics you should track ?

    Getting your head around web analytics means knowing the most important metrics to track. Below are seven key metrics and how to track them using Matomo. 

    Traffic

    Traffic is the number of people visiting your website over a period of time. It is the lifeblood of your website since the more visits your site receives, the more revenue it stands to generate.

    However, simply having a high volume of visitors does not guarantee substantial revenue. To maximise your success, focus on attracting your ideal customers and generating quality traffic from those who are most likely to engage with your offerings.

    Ideally, you should be seeing an upward trend in traffic over time though. The longer your website has been published and the more quality and targeted content you create, the more traffic you should receive. 

    Matomo offers multiple ways to check your website’s traffic :

    The visits log report in Matomo is perfect if you want a granular view of your visitors.

    A screenshot of Matomo's visitor log report

    It shows you each user session and get a detailed picture of each user, including :

    • Their geographic location
    • The number of actions they took
    • How they found your site
    • The length of time they stayed
    • Their device type
    • What browser they are using
    • The keyword they used to find your site

    Traffic sources

    Traffic sources show how users access your website. They can enter via a range of traffic sources, including search engines, email and direct visits, for instance.

    Matomo has five default traffic source types :

    • Search engine – visitors from search platforms (like Google, Bing, etc.)
    • Direct traffic – individuals who directly type your website’s URL into their browser or have it bookmarked, bypassing search engines or external links
    • Websites – visits from other external sites
    • Campaigns – traffic resulting from specific marketing initiatives (like a newsletter or ad campaign, for instance)
    • Social networks  – visitors who access your website through various social media platforms (such as Facebook, LinkedIn, Instagram. etc.)

    But each of these can be broken into more granular sources. Take organic traffic from search engines, for example :

    A screenshot of Matomo's organic traffic report

    Matomo tracks visits from each search engine, showing you how many visits you had in total, how many actions those visitors took, and the average amount of time those visitors spent on your site. 

    You can even integrate Google, Bing and Yahoo search consoles to monitor keyword performance and enhance your search engine optimisation efforts.

    Pageviews

    Whenever a browser loads a page, your web analytics tool records a pageview. This term, pageview, represents the count of unique times a page on your website is loaded.

    You can track pageviews in Matomo by opening the Pages tab in the Behaviour section of the main navigation. 

    A screenshot of Matomo's page analytic sreport

    You can quickly see your site’s most visited pages in this report in Matomo. 

    Be careful of deriving too much meaning from pageviews. Just because a page has lots of views, doesn’t necessarily mean it’s quality or valuable. There are a couple of reasons for this. First, the page might be confusing, so users have to keep revisiting it to understand the content. Second, it could be the default page most visitors land on when they enter your site, like the homepage. 

    While pageviews offer insights, it’s important to dig deeper into user behaviour and other metrics to truly gauge a page’s importance and impact.

    Average time on page

    Time on page is the amount of time users spend on the page on average. You can see average time on page in Matomo’s page analytics report.

    A low time on page score isn’t necessarily a bad thing. Users will naturally spend less time on gateway pages and checkout pages. A short time spent on checkout pages, especially if users are successfully completing their transactions, indicates that the checkout process is easy and seamless.

    Conversely, a longer time on blog posts is a positive indicator. It suggests that readers are genuinely engaged with the content.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    Returning visitors

    Returning visitors measures the number of people who visit your site more than once. It can be expressed as a number or a percentage. 

    While some analytics tools only show returning visitors as a percentage, Matomo lets you learn more about each of them in the Visitor profile report. 

    A screenshot of Matomo's Visitor profile report

    This report offers a full summary of a user’s previous actions, including :

    • How many times they’ve visited your site
    • The pages they viewed on each visit
    • Where they visited from
    • The devices they used
    • How quickly pages loaded

    When people keep coming back to a website, it’s usually a positive sign and means they like the service, content or products. But, it depends on the type of website. If it’s the kind of site where people make one-off purchases, the focus might not be on getting visitors to return. For a site like this, a high number of returning visitors could indicate that the website is confusing or difficult to use. 

    It’s all about the context – different websites have different goals, and it’s important to keep this in mind when analysing your site.

    Conversions

    A conversion is when a user takes a desired action on your website. This could be :

    • Making a purchase
    • Subscribing to your newsletter
    • Signing up for a webinar

    You can track virtually any action as a conversion in Matomo by setting goals and analysing the goals report.

    A screenshot of Matomo's goal report

    As you can see in the screenshot above, Matomo shows your conversions plotted over time. You can also see your conversion rate to get a complete picture and assign a value to each conversion to calculate how much revenue each conversion generates. 

    Bounce rate

    A visitor bounces when they leave your website without taking an action or visiting another page. 

    Typically, you want bounce rate to be low because it means people are engaged with your site and more likely to convert. However, in some cases, a high bounce rate isn’t necessarily bad. It might mean that visitors found what they needed on the first page and didn’t feel the need to look further. 

    The impact of bounce rate depends on your website’s purpose and goals.

    You can view your website’s bounce rate using Matomo’s page analytics report — the same report that shows pageviews.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    Web analytics best practices

    You should follow several best practices to get the most from website analytics data. 

    Choose metrics that align with your goals

    Only some metrics your analytics platform tracks will be relevant to your business. So don’t waste time analysing all of them.

    Instead, focus on the ones that matter most to your business. A marketer for an e-commerce store, for example, might focus on conversion-related metrics like conversion rate and total number of transactions. They might also want to look at campaign-related metrics, like traffic sources and bounce rates, so they can optimise paid ad campaigns accordingly. 

    A marketer looking to improve their site’s SEO, on the other hand, will want to track SEO web analytics like bounce rate and broken links.

    Add context to your data

    Don’t take your data at face value. There could be dozens of factors that impact how visitors access and use your site — many of which are outside your control. 

    For example, you may think an update to your site has sent your conversions crashing when, in reality, a Google algorithm update has negatively impacted your search traffic.

    Adding annotations within Matomo can provide invaluable context to your data. These annotations can be used to highlight specific events, changes or external factors that might influence your website metrics.

    A screenshot of annotations list in Matomo

    By documenting significant occurrences, such as website updates, marketing campaigns or algorithm changes, you create a timeline that helps explain fluctuations in your data.

    Go further with advanced web analytics features

    It’s clear that a web analytics platform is a necessary tool to understand your website’s performance.

    However, if you want greater confidence in decision-making, quicker insights and better use of budget and resources, you need an advanced solution with behavioural analytics features like heatmaps, A/B testing and session recordings

    Most web analytics solutions don’t offer these advanced features, but Matomo does, so we’ll be showcasing Matomo’s behavioural analytics features.

    Now, if you don’t have a Matomo account, you can try it free for 21-days to see if it’s the right tool for you.

    A heatmap showing user mouse movements

    A heatmap, like the example above, makes it easy to discover where your users pay attention, which part of your site they have problems with, and how they convert. It adds a layer of qualitative data to the facts offered by your web analytics tool.

    Similarly, session recordings will offer you real-time playbacks of user interactions, helping you understand their navigation patterns, identify pain points and gain insights into the user experience.

    Then you can run experiments bu using A/B testing to compare different versions of your website or specific elements, allowing you to make informed decisions based on actual user preferences and behaviour. For instance, you can compare different headlines, images, page layouts or call-to-action buttons to see which resonates better with your audience. 

    Together, these advanced features will give you the confidence to optimise your website, improve user satisfaction and make data-driven decisions that positively impact your business.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    How to choose a web analytics tool

    A web analytics tool is the best way to track the above metrics. Choose the best one for your company by following the steps below. 

    Look for the right features

    Most popular web analytics platforms, like Google Analytics, will offer the same core features like tracking website traffic, monitoring conversions and generating reports. 

    But it’s the added features that set great tools apart. Do you need specific tools to measure the performance of your e-commerce store, for example ? What about paid ad performance, A/B testing or form analytics ?

    By understanding exactly what you need from an analytics platform, you can make an informed choice. 

    Think about data accuracy

    Data accuracy is one of the biggest issues with analytics tools. Many users block cookies or opt out of tracking, making it difficult to get a clear picture of user behaviour — and meaning that you have to think about how your user data will be collected with your chosen platform.

    Google Analytics, for instance, uses data sampling to make assumptions about traffic levels rather than relying on accurate data. This can lead to inaccurate reports and false conclusions. 

    It’s why Matomo doesn’t use data sampling and provides 100% accurate data. 

    Understand how you’ll deal with data privacy

    Data privacy is another big concern for analytics users. Several major analytics platforms aren’t compatible with regional data privacy laws like GDPR, which can impact your ability to collect data in these regions. 

    It’s why many companies trust privacy-focused analytics tools that abide by regulations without impacting your ability to collect data. Matomo is a market leader in this respect and is one of the few web analytics tools that the Centre for Data Privacy Protection in France has said is exempt from tracking consent requirements.

    Many government agencies across Europe, Asia, Africa and North America, including organisations like the United Nations and European Commission, rely on Matomo for web analytics.

    Conclusion

    Web analytics is a powerful tool that helps you better understand your users, improve your site’s performance and boost your marketing efforts. 

    If you want a platform that offers advanced features, 100% accurate data and protects your users’ privacy, then look no further than Matomo. 

    Try Matomo free for 21 days, no credit card required. 

  • How to Stream RTP (IP camera) Into React App setup

    10 novembre 2024, par sharon2469

    I am trying to transfer a live broadcast from an IP camera or any other broadcast coming from an RTP/RTSP source to my REACT application. BUT MUST BE LIVE

    


    My setup at the moment is :

    


    IP Camera -> (RTP) -> FFmpeg -> (udp) -> Server(nodeJs) -> (WebRTC) -> React app

    


    In the current situation, There is almost no delay, but there are some things here that I can't avoid and I can't understand why, and here is my question :

    


    1) First, is the SETUP even correct and this is the only way to Stream RTP video in Web app ?

    


    2) Is it possible to avoid re-encode the stream , RTP transmission necessarily comes in H.264, hence I don't really need to execute the following command :

    


        return spawn('ffmpeg', [
    '-re',                              // Read input at its native frame rate Important for live-streaming
    '-probesize', '32',                 // Set probing size to 32 bytes (32 is minimum)
    '-analyzeduration', '1000000',      // An input duration of 1 second
    '-c:v', 'h264',                     // Video codec of input video
    '-i', 'rtp://238.0.0.2:48888',      // Input stream URL
    '-map', '0:v?',                     // Select video from input stream
    '-c:v', 'libx264',                  // Video codec of output stream
    '-preset', 'ultrafast',             // Faster encoding for lower latency
    '-tune', 'zerolatency',             // Optimize for zero latency
    // '-s', '768x480',                    // Adjust the resolution (experiment with values)
    '-f', 'rtp', `rtp://127.0.0.1:${udpPort}` // Output stream URL
]);


    


    As you can se in this command I re-encode to libx264, But if I set FFMPEG a parameter '-c:v' :'copy' instead of '-c:v', 'libx264' then FFMPEG throw an error says : that it doesn't know how to encode h264 and only knows what is libx264-> Basically, I want to stop the re-encode because there is really no need for it, because the stream is already encoded to H264. Are there certain recommendations that can be made ?

    


    3) I thought about giving up the FFMPEG completely, but the RTP packets arrive at a size of 1200+ BYTES when WEBRTC is limited to up to 1280 BYTE. Is there a way to manage these sabotages without damaging the video and is it to enter this world ? I guess there is the whole story with the JITTER BUFFER here

    


    This is my server side code (THIS IS JUST A TEST CODE)

    


    import {
    MediaStreamTrack,
    randomPort,
    RTCPeerConnection,
    RTCRtpCodecParameters,
    RtpPacket,
} from 'werift'
import {Server} from "ws";
import {createSocket} from "dgram";
import {spawn} from "child_process";
import LoggerFactory from "./logger/loggerFactory";

//

const log = LoggerFactory.getLogger('ServerMedia')

// Websocket server -> WebRTC
const serverPort = 8888
const server = new Server({port: serverPort});
log.info(`Server Media start om port: ${serverPort}`);

// UDP server -> ffmpeg
const udpPort = 48888
const udp = createSocket("udp4");
// udp.bind(udpPort, () => {
//     udp.addMembership("238.0.0.2");
// })
udp.bind(udpPort)
log.info(`UDP port: ${udpPort}`)


const createFFmpegProcess = () => {
    log.info(`Start ffmpeg process`)
    return spawn('ffmpeg', [
        '-re',                              // Read input at its native frame rate Important for live-streaming
        '-probesize', '32',                 // Set probing size to 32 bytes (32 is minimum)
        '-analyzeduration', '1000000',      // An input duration of 1 second
        '-c:v', 'h264',                     // Video codec of input video
        '-i', 'rtp://238.0.0.2:48888',      // Input stream URL
        '-map', '0:v?',                     // Select video from input stream
        '-c:v', 'libx264',                  // Video codec of output stream
        '-preset', 'ultrafast',             // Faster encoding for lower latency
        '-tune', 'zerolatency',             // Optimize for zero latency
        // '-s', '768x480',                    // Adjust the resolution (experiment with values)
        '-f', 'rtp', `rtp://127.0.0.1:${udpPort}` // Output stream URL
    ]);

}

let ffmpegProcess = createFFmpegProcess();


const attachFFmpegListeners = () => {
    // Capture standard output and print it
    ffmpegProcess.stdout.on('data', (data) => {
        log.info(`FFMPEG process stdout: ${data}`);
    });

    // Capture standard error and print it
    ffmpegProcess.stderr.on('data', (data) => {
        console.error(`ffmpeg stderr: ${data}`);
    });

    // Listen for the exit event
    ffmpegProcess.on('exit', (code, signal) => {
        if (code !== null) {
            log.info(`ffmpeg process exited with code ${code}`);
        } else if (signal !== null) {
            log.info(`ffmpeg process killed with signal ${signal}`);
        }
    });
};


attachFFmpegListeners();


server.on("connection", async (socket) => {
    const payloadType = 96; // It is a numerical value that is assigned to each codec in the SDP offer/answer exchange -> for H264
    // Create a peer connection with the codec parameters set in advance.
    const pc = new RTCPeerConnection({
        codecs: {
            audio: [],
            video: [
                new RTCRtpCodecParameters({
                    mimeType: "video/H264",
                    clockRate: 90000, // 90000 is the default value for H264
                    payloadType: payloadType,
                }),
            ],
        },
    });

    const track = new MediaStreamTrack({kind: "video"});


    udp.on("message", (data) => {
        console.log(data)
        const rtp = RtpPacket.deSerialize(data);
        rtp.header.payloadType = payloadType;
        track.writeRtp(rtp);
    });

    udp.on("error", (err) => {
        console.log(err)

    });

    udp.on("close", () => {
        console.log("close")
    });

    pc.addTransceiver(track, {direction: "sendonly"});

    await pc.setLocalDescription(await pc.createOffer());
    const sdp = JSON.stringify(pc.localDescription);
    socket.send(sdp);

    socket.on("message", (data: any) => {
        if (data.toString() === 'resetFFMPEG') {
            ffmpegProcess.kill('SIGINT');
            log.info(`FFMPEG process killed`)
            setTimeout(() => {
                ffmpegProcess = createFFmpegProcess();
                attachFFmpegListeners();
            }, 5000)
        } else {
            pc.setRemoteDescription(JSON.parse(data));
        }
    });
});


    


    And this fronted :

    


    &#xA;&#xA;&#xA;    &#xA;    &#xA;    <code class="echappe-js">&lt;script&amp;#xA;            crossorigin&amp;#xA;            src=&quot;https://unpkg.com/react@16/umd/react.development.js&quot;&amp;#xA;    &gt;&lt;/script&gt;&#xA;    &lt;script&amp;#xA;            crossorigin&amp;#xA;            src=&quot;https://unpkg.com/react-dom@16/umd/react-dom.development.js&quot;&amp;#xA;    &gt;&lt;/script&gt;&#xA;    &lt;script&amp;#xA;            crossorigin&amp;#xA;            src=&quot;https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js&quot;&amp;#xA;    &gt;&lt;/script&gt;&#xA;    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/babel-regenerator-runtime@6.5.0/runtime.min.js&quot;&gt;&lt;/script&gt;&#xA;&#xA;&#xA;
    &#xA;

    &#xA;

    &#xA;&lt;script type=&quot;text/babel&quot;&gt;&amp;#xA;    let rtc;&amp;#xA;&amp;#xA;    const App = () =&gt; {&amp;#xA;        const [log, setLog] = React.useState([]);&amp;#xA;        const videoRef = React.useRef();&amp;#xA;        const socket = new WebSocket(&quot;ws://localhost:8888&quot;);&amp;#xA;        const [peer, setPeer] = React.useState(null); // Add state to keep track of the peer connection&amp;#xA;&amp;#xA;        React.useEffect(() =&gt; {&amp;#xA;            (async () =&gt; {&amp;#xA;                await new Promise((r) =&gt; (socket.onopen = r));&amp;#xA;                console.log(&quot;open websocket&quot;);&amp;#xA;&amp;#xA;                const handleOffer = async (offer) =&gt; {&amp;#xA;                    console.log(&quot;new offer&quot;, offer.sdp);&amp;#xA;&amp;#xA;                    const updatedPeer = new RTCPeerConnection({&amp;#xA;                        iceServers: [],&amp;#xA;                        sdpSemantics: &quot;unified-plan&quot;,&amp;#xA;                    });&amp;#xA;&amp;#xA;                    updatedPeer.onicecandidate = ({ candidate }) =&gt; {&amp;#xA;                        if (!candidate) {&amp;#xA;                            const sdp = JSON.stringify(updatedPeer.localDescription);&amp;#xA;                            console.log(sdp);&amp;#xA;                            socket.send(sdp);&amp;#xA;                        }&amp;#xA;                    };&amp;#xA;&amp;#xA;                    updatedPeer.oniceconnectionstatechange = () =&gt; {&amp;#xA;                        console.log(&amp;#xA;                            &quot;oniceconnectionstatechange&quot;,&amp;#xA;                            updatedPeer.iceConnectionState&amp;#xA;                        );&amp;#xA;                    };&amp;#xA;&amp;#xA;                    updatedPeer.ontrack = (e) =&gt; {&amp;#xA;                        console.log(&quot;ontrack&quot;, e);&amp;#xA;                        videoRef.current.srcObject = e.streams[0];&amp;#xA;                    };&amp;#xA;&amp;#xA;                    await updatedPeer.setRemoteDescription(offer);&amp;#xA;                    const answer = await updatedPeer.createAnswer();&amp;#xA;                    await updatedPeer.setLocalDescription(answer);&amp;#xA;&amp;#xA;                    setPeer(updatedPeer);&amp;#xA;                };&amp;#xA;&amp;#xA;                socket.onmessage = (ev) =&gt; {&amp;#xA;                    const data = JSON.parse(ev.data);&amp;#xA;                    if (data.type === &quot;offer&quot;) {&amp;#xA;                        handleOffer(data);&amp;#xA;                    } else if (data.type === &quot;resetFFMPEG&quot;) {&amp;#xA;                        // Handle the resetFFMPEG message&amp;#xA;                        console.log(&quot;FFmpeg reset requested&quot;);&amp;#xA;                    }&amp;#xA;                };&amp;#xA;            })();&amp;#xA;        }, []); // Added socket as a dependency to the useEffect hook&amp;#xA;&amp;#xA;        const sendRequestToResetFFmpeg = () =&gt; {&amp;#xA;            socket.send(&quot;resetFFMPEG&quot;);&amp;#xA;        };&amp;#xA;&amp;#xA;        return (&amp;#xA;            &lt;div&gt;&amp;#xA;                Video: &amp;#xA;                &lt;video ref={videoRef} autoPlay muted /&gt;&amp;#xA;                &lt;button onClick={() =&gt; sendRequestToResetFFmpeg()}&gt;Reset FFMPEG&lt;/button&gt;&amp;#xA;            &lt;/div&gt;&amp;#xA;        );&amp;#xA;    };&amp;#xA;&amp;#xA;    ReactDOM.render(&lt;App /&gt;, document.getElementById(&quot;app1&quot;));&amp;#xA;&lt;/script&gt;&#xA;&#xA;&#xA;

    &#xA;

  • Problems with outputting stream format as RTMP via FFmpeg C-API

    9 janvier 2024, par dongrixinyu

    I am using FFmpeg's C API to push video streams rtmp://.... into an SRS server.
    &#xA;The input stream is an MP4 file named juren-30s.mp4.
    &#xA;The output stream is also an MP4 file named juren-30s-5.mp4.

    &#xA;

    My piece of code (see further down) works fine when used in the following steps :
    &#xA;mp4 -> demux -> decode -> rgb images -> encode -> mux -> mp4.

    &#xA;

    Problem :

    &#xA;

    When I changed the output stream to an online RTMP url named rtmp://ip:port/live/stream_nb_23 (just an example, you can change it according to your server and rules.)

    &#xA;

    result : This code would be corrupted mp4 -> rtmp(flv).

    &#xA;

    What I've tried :

    &#xA;

    Changing the output format
    &#xA;I changed the output format param to become flv when I initialized the avformat_alloc_output_context2. But this didn't help.

    &#xA;

    Debugging the output
    &#xA;When I executed ffprobe rtmp://ip:port/live/xxxxxxx, I got the following errors and did not know why :

    &#xA;

    [h264 @ 0x55a925e3ba80] luma_log2_weight_denom 12 is out of range&#xA;[h264 @ 0x55a925e3ba80] Missing reference picture, default is 2&#xA;[h264 @ 0x55a925e3ba80] concealing 8003 DC, 8003 AC, 8003 MV errors in P frame&#xA;[h264 @ 0x55a925e3ba80] QP 4294966938 out of range&#xA;[h264 @ 0x55a925e3ba80] decode_slice_header error&#xA;[h264 @ 0x55a925e3ba80] no frame!&#xA;[h264 @ 0x55a925e3ba80] luma_log2_weight_denom 21 is out of range&#xA;[h264 @ 0x55a925e3ba80] luma_log2_weight_denom 10 is out of range&#xA;[h264 @ 0x55a925e3ba80] chroma_log2_weight_denom 12 is out of range&#xA;[h264 @ 0x55a925e3ba80] Missing reference picture, default is 0&#xA;[h264 @ 0x55a925e3ba80] decode_slice_header error&#xA;[h264 @ 0x55a925e3ba80] QP 4294967066 out of range&#xA;[h264 @ 0x55a925e3ba80] decode_slice_header error&#xA;[h264 @ 0x55a925e3ba80] no frame!&#xA;[h264 @ 0x55a925e3ba80] QP 341 out of range&#xA;[h264 @ 0x55a925e3ba80] decode_slice_header error&#xA;

    &#xA;

    I am confused about the difference between MP4 and RTMP of how to use FFmpeg C-API to produce a correct output stream format.

    &#xA;

    Besides, I also wanna learn how to convert video and audio streams into other formats using FFmpeg C-api, such as flv, ts, rtsp, etc.

    &#xA;

    Code to reproduce the problem :

    &#xA;

    &#xA;

    So how to make this code output to RTMP without getting issue of an unplayable video ?

    &#xA;

    #include &#xA;#include "libavformat/avformat.h"&#xA;int main()&#xA;{&#xA;    int ret = 0; int err;&#xA;&#xA;    //Open input file&#xA;    char filename[] = "juren-30s.mp4";&#xA;    AVFormatContext *fmt_ctx = avformat_alloc_context();&#xA;    if (!fmt_ctx) {&#xA;        printf("error code %d \n",AVERROR(ENOMEM));&#xA;        return ENOMEM;&#xA;    }&#xA;    if((err = avformat_open_input(&amp;fmt_ctx, filename,NULL,NULL)) &lt; 0){&#xA;        printf("can not open file %d \n",err);&#xA;        return err;&#xA;    }&#xA;&#xA;    //Open the decoder&#xA;    AVCodecContext *avctx = avcodec_alloc_context3(NULL);&#xA;    ret = avcodec_parameters_to_context(avctx, fmt_ctx->streams[0]->codecpar);&#xA;    if (ret &lt; 0){&#xA;        printf("error code %d \n",ret);&#xA;        return ret;&#xA;    }&#xA;    AVCodec *codec = avcodec_find_decoder(avctx->codec_id);&#xA;    if ((ret = avcodec_open2(avctx, codec, NULL)) &lt; 0) {&#xA;        printf("open codec faile %d \n",ret);&#xA;        return ret;&#xA;    }&#xA;&#xA;    //Open the output file container&#xA;    char filename_out[] = "juren-30s-5.mp4";&#xA;    AVFormatContext *fmt_ctx_out = NULL;&#xA;    err = avformat_alloc_output_context2(&amp;fmt_ctx_out, NULL, NULL, filename_out);&#xA;    if (!fmt_ctx_out) {&#xA;        printf("error code %d \n",AVERROR(ENOMEM));&#xA;        return ENOMEM;&#xA;    }&#xA;    //Add all the way to the container context&#xA;    AVStream *st = avformat_new_stream(fmt_ctx_out, NULL);&#xA;    st->time_base = fmt_ctx->streams[0]->time_base;&#xA;&#xA;    AVCodecContext *enc_ctx = NULL;&#xA;    &#xA;    AVPacket *pt = av_packet_alloc();&#xA;    AVFrame *frame = av_frame_alloc();&#xA;    AVPacket *pkt_out = av_packet_alloc();&#xA;&#xA;    int frame_num = 0; int read_end = 0;&#xA;    &#xA;    for(;;){&#xA;        if( 1 == read_end ){ break;}&#xA;&#xA;        ret = av_read_frame(fmt_ctx, pkt);&#xA;        //Skip and do not process audio packets&#xA;        if( 1 == pkt->stream_index ){&#xA;            av_packet_unref(pt);&#xA;            continue;&#xA;        }&#xA;&#xA;        if ( AVERROR_EOF == ret) {&#xA;            //After reading the file, the data and size of pkt should be null at this time&#xA;            avcodec_send_packet(avctx, NULL);&#xA;        }else {&#xA;            if( 0 != ret){&#xA;                printf("read error code %d \n",ret);&#xA;                return ENOMEM;&#xA;            }else{&#xA;                retry:&#xA;                if (avcodec_send_packet(avctx, pkt) == AVERROR(EAGAIN)) {&#xA;                    printf("Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");&#xA;                    //Here you can consider sleeping for 0.1 seconds and returning EAGAIN. This is usually because there is a bug in ffmpeg&#x27;s internal API.&#xA;                    goto retry;&#xA;                }&#xA;                //Release the encoded data in pkt&#xA;                av_packet_unref(pt);&#xA;            }&#xA;&#xA;        }&#xA;&#xA;        //The loop keeps reading data from the decoder until there is no more data to read.&#xA;        for(;;){&#xA;            //Read AVFrame&#xA;            ret = avcodec_receive_frame(avctx, frame);&#xA;            /* Release the YUV data in the frame,&#xA;             * Since av_frame_unref is called in the avcodec_receive_frame function, the following code can be commented.&#xA;             * So we don&#x27;t need to manually unref this AVFrame&#xA;             * */&#xA;            //off_frame_unref(frame);&#xA;&#xA;            if( AVERROR(EAGAIN) == ret ){&#xA;                //Prompt EAGAIN means the decoder needs more AVPackets&#xA;                //Jump out of the first layer of for and let the decoder get more AVPackets&#xA;                break;&#xA;            }else if( AVERROR_EOF == ret ){&#xA;                /* The prompt AVERROR_EOF means that an AVPacket with both data and size NULL has been sent to the decoder before.&#xA;                 * Sending NULL AVPacket prompts the decoder to flush out all cached frames.&#xA;                 * Usually a NULL AVPacket is sent only after reading the input file, or when another video stream needs to be decoded with an existing decoder.&#xA;                 *&#xA;                 * */&#xA;&#xA;                /* Send null AVFrame to the encoder and let the encoder flush out the remaining data.&#xA;                 * */&#xA;                ret = avcodec_send_frame(enc_ctx, NULL);&#xA;                for(;;){&#xA;                    ret = avcodec_receive_packet(enc_ctx, pkt_out);&#xA;                    //It is impossible to return EAGAIN here, if there is any, exit directly.&#xA;                    if (ret == AVERROR(EAGAIN)){&#xA;                        printf("avcodec_receive_packet error code %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;                    &#xA;                    if ( AVERROR_EOF == ret ){ break; }&#xA;                    &#xA;                    //Encode the AVPacket, print some information first, and then write it to the file.&#xA;                    printf("pkt_out size : %d \n",pkt_out->size);&#xA;                    //Set the stream_index of AVPacket so that you know which stream it is.&#xA;                    pkt_out->stream_index = st->index;&#xA;                    //Convert the time base of AVPacket to the time base of the output stream.&#xA;                    pkt_out->pts = av_rescale_q_rnd(pkt_out->pts, fmt_ctx->streams[0]->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;                    pkt_out->dts = av_rescale_q_rnd(pkt_out->dts, fmt_ctx->streams[0]->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;                    pkt_out->duration = av_rescale_q_rnd(pkt_out->duration, fmt_ctx->streams[0]->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;&#xA;&#xA;                    ret = av_interleaved_write_frame(fmt_ctx_out, pkt_out);&#xA;                    if (ret &lt; 0) {&#xA;                        printf("av_interleaved_write_frame faile %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;                    av_packet_unref(pt_out);&#xA;                }&#xA;                av_write_trailer(fmt_ctx_out);&#xA;                //Jump out of the second layer of for, the file has been decoded.&#xA;                read_end = 1;&#xA;                break;&#xA;            }else if( ret >= 0 ){&#xA;                //Only when a frame is decoded can the encoder be initialized.&#xA;                if( NULL == enc_ctx ){&#xA;                    //Open the encoder and set encoding information.&#xA;                    AVCodec *encode = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;                    enc_ctx = avcodec_alloc_context3(encode);&#xA;                    enc_ctx->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;                    enc_ctx->bit_rate = 400000;&#xA;                    enc_ctx->framerate = avctx->framerate;&#xA;                    enc_ctx->gop_size = 30;&#xA;                    enc_ctx->max_b_frames = 10;&#xA;                    enc_ctx->profile = FF_PROFILE_H264_MAIN;&#xA;                   &#xA;                    /*&#xA;                     * In fact, the following information is also available in the container. You can also open the encoder directly in the container at the beginning.&#xA;                     * I took these encoder parameters from AVFrame because the difference in the container is final.&#xA;                     * Because the AVFrame you decoded may go through a filter, the information will be transformed after the filter, but this article does not use filters.&#xA;                     */&#xA;                     &#xA;                    //The time base of the encoder should be the time base of AVFrame, because AVFrame is the input. The time base of AVFrame is the time base of the stream.&#xA;                    enc_ctx->time_base = fmt_ctx->streams[0]->time_base;&#xA;                    enc_ctx->width = fmt_ctx->streams[0]->codecpar->width;&#xA;                    enc_ctx->height = fmt_ctx->streams[0]->codecpar->height;&#xA;                    enc_ctx->sample_aspect_ratio = st->sample_aspect_ratio = frame->sample_aspect_ratio;&#xA;                    enc_ctx->pix_fmt = frame->format;&#xA;                    enc_ctx->color_range            = frame->color_range;&#xA;                    enc_ctx->color_primaries        = frame->color_primaries;&#xA;                    enc_ctx->color_trc              = frame->color_trc;&#xA;                    enc_ctx->colorspace             = frame->colorspace;&#xA;                    enc_ctx->chroma_sample_location = frame->chroma_location;&#xA;&#xA;                    /* Note that the value of this field_order is different for different videos. I have written it here.&#xA;                     * Because the video in this article is AV_FIELD_PROGRESSIVE&#xA;                     * The production environment needs to process different videos&#xA;                     */&#xA;                    enc_ctx->field_order = AV_FIELD_PROGRESSIVE;&#xA;&#xA;                    /* Now we need to copy the encoder parameters to the stream. When decoding, assign parameters from the stream to the decoder.&#xA;                     * Now let’s do it in reverse.&#xA;                     * */&#xA;                    ret = avcodec_parameters_from_context(st->codecpar,enc_ctx);&#xA;                    if (ret &lt; 0){&#xA;                        printf("error code %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;                    if ((ret = avcodec_open2(enc_ctx, encode, NULL)) &lt; 0) {&#xA;                        printf("open codec faile %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;&#xA;                    //Formally open the output file&#xA;                    if ((ret = avio_open2(&amp;fmt_ctx_out->pb, filename_out, AVIO_FLAG_WRITE,&amp;fmt_ctx_out->interrupt_callback,NULL)) &lt; 0) {&#xA;                        printf("avio_open2 fail %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;&#xA;                    //Write the file header first.&#xA;                    ret = avformat_write_header(fmt_ctx_out,NULL);&#xA;                    if (ret &lt; 0) {&#xA;                        printf("avformat_write_header fail %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;&#xA;                }&#xA;&#xA;                //Send AVFrame to the encoder, and then continuously read AVPacket&#xA;                ret = avcodec_send_frame(enc_ctx, frame);&#xA;                if (ret &lt; 0) {&#xA;                    printf("avcodec_send_frame fail %d \n",ret);&#xA;                    return ret;&#xA;                }&#xA;                for(;;){&#xA;                    ret = avcodec_receive_packet(enc_ctx, pkt_out);&#xA;                    if (ret == AVERROR(EAGAIN)){ break; }&#xA;                    &#xA;                    if (ret &lt; 0){&#xA;                    printf("avcodec_receive_packet fail %d \n",ret);&#xA;                    return ret;&#xA;                    }&#xA;                    &#xA;                    //Encode the AVPacket, print some information first, and then write it to the file.&#xA;                    printf("pkt_out size : %d \n",pkt_out->size);&#xA;&#xA;                    //Set the stream_index of AVPacket so that you know which stream it is.&#xA;                    pkt_out->stream_index = st->index;&#xA;                    &#xA;                    //Convert the time base of AVPacket to the time base of the output stream.&#xA;                    pkt_out->pts = av_rescale_q_rnd(pkt_out->pts, fmt_ctx->streams[0]->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;                    pkt_out->dts = av_rescale_q_rnd(pkt_out->dts, fmt_ctx->streams[0]->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;                    pkt_out->duration = av_rescale_q_rnd(pkt_out->duration, fmt_ctx->streams[0]->time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;&#xA;                    ret = av_interleaved_write_frame(fmt_ctx_out, pkt_out);&#xA;                    if (ret &lt; 0) {&#xA;                        printf("av_interleaved_write_frame faile %d \n",ret);&#xA;                        return ret;&#xA;                    }&#xA;                    av_packet_unref(pt_out);&#xA;                }&#xA;&#xA;            }&#xA;            else{ printf("other fail \n"); return ret;}&#xA;        }&#xA;    }&#xA;    &#xA;    av_frame_free(&amp;frame); av_packet_free(&amp;pt); av_packet_free(&amp;pkt_out);&#xA;    &#xA;    //Close the encoder and decoder.&#xA;    avcodec_close(avctx); avcodec_close(enc_ctx);&#xA;&#xA;    //Release container memory.&#xA;    avformat_free_context(fmt_ctx);&#xA;&#xA;    //Must adjust avio_closep, otherwise the data may not be written in, it will be 0kb&#xA;    avio_closep(&amp;fmt_ctx_out->pb);&#xA;    avformat_free_context(fmt_ctx_out);&#xA;    printf("done \n");&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    This problem has haunted over my head for about three weeks. I still have no idea where the key bug exists. Really appreciate it if any FFmpeg expert could help me.

    &#xA;