Recherche avancée

Médias (91)

Autres articles (49)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
    Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...)

  • 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 autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (7974)

  • B2B Marketing Attribution Guide : How to Master It in 2024

    21 mai 2024, par Erin

    The last thing you want is to invest your advertising dollars in channels, campaigns and ads that don’t work. But B2B marketing attribution — figuring out which marketing efforts drive revenue — is far from easy.

    With longer sales funnels and multiple people from the same company involved in the same sales process, B2B (business-to-business) is a different ballgame from B2C (business-to-consumer) marketing.

    In this guide, we break down what B2B marketing attribution is, how it’s different, which tools you can use to set it up and the best practices.

    What is B2B marketing attribution ?

    Marketing attribution in B2B companies is about figuring out where your high-value leads come from — nailing down long customer journeys across many different touchpoints.

    Illustration of attributing a multi-person customer journey

    The goal is to determine which campaigns and content contributed to various parts of the customer journey. It’s a complex process that needs a reliable, privacy-focused web analytics tool and a CRM that integrates with it.

    This process significantly differs from traditional marketing attribution, where you focus more on short sales cycles from individual customers. With multiple contributing decision makers, B2B attribution requires more robust systems.

    What makes marketing attribution different for B2B ?

    The key differences between B2B and B2C marketing attribution are a longer sales funnel and more people involved in the sales process.

    The B2B sales funnel is significantly longer and more complex

    The typical B2C sales funnel is often broken down into four simple stages :

    1. Awareness : when a prospect first finds out about your product or brand
    2. Interest : where a prospect starts to learn about the benefits of your product
    3. Desire : when a prospect understands that they need your product
    4. Action : the actual process of closing the sale

    Even the most simplified B2B sales funnel includes several key stages.

    5 stages of the B2B customer journey.

    Here’s a brief overview of each :

    1. Awareness : Buyers recognise they have a problem and start looking for solutions. Stand out with blog posts, social media updates, ebooks and whitepapers.
    2. Consideration : Buyers are aware of your company and are comparing options. Provide product demos, webinars and case studies to address their concerns and build trust.
    3. Conversion : Buyers have chosen your product or company. Offer live demos, customer service, case studies and testimonials to finalise the purchase.
    4. Loyalty : Buyers have made a purchase and are now customers. Nurture relationships with thank you emails, follow-ups, how-tos, reward programs and surveys to encourage repeat business.
    5. Advocacy : Loyal customers become advocates, promoting your brand to others. Encourage this with surveys, testimonial requests and a referral program.

    A longer sales cycle typically involves not only more touchpoints but also extended decision-making processes.

    More teams are involved in the marketing and sales process

    The last differentiation in B2B attribution is the number of people involved. Instead of clear-cut sales and marketing teams, revenue teams are becoming more common.

    They include all go-to-market teams like sales, marketing, customer success and customer support. In B2B sales, long-term customer relationships can be incredibly valuable. As such, the focus shifts away from new customer acquisition alone.

    For example, you can also track and optimise your onboarding process. Marketing gets involved in post-sale efforts to boost loyalty. Sales reps follow up with customer success to get new sales angles and insights. Customer support insights drive future product development.

    Everyone works together to meet high-level company goals.

    The next section will explore how to set up an attribution system.

    How to find the right mix of B2B marketing attribution tools

    For most B2B marketing teams, the main struggle with attribution is not with the strategy but with creating a reliable system that gives them the data points they need to implement that strategy.

    We’ll outline one approach you can take to achieve this without a million-dollar budget or internal data science team.

    Use website analytics to track touchpoints

    The first thing you want to do is install a reliable website analytics solution on your website. 

    Once you’ve got your analytics in place, use campaign tracking parameters to track touchpoints from external campaigns like email newsletters, social media ads, review sites (like Capterra) and third-party partner campaigns.

    This way, you get a clear picture of which sources are driving traffic and conversions, helping you improve your marketing strategies.

    With analytics installed, you can track the referring sources of visits, engagement and conversion events. A robust solution like Matomo tracks everything from traffic sources, marketing attribution and visitor counts to behavioural analytics, like clicks, scrolling patterns and form interactions on your site.

    Marketing attribution will give you a cohesive view of which traffic sources and campaigns drive conversions and revenue over long periods. With Matomo’s marketing attribution feature, you can even use different marketing attribution models to compare results :

    Matomo comparing linear, first click, and last click attribution models in the marketing attribution dashboard

    For example, in a single report, you can compare the last interaction, first interaction and linear (three common marketing attribution models). 

    In total, Matomo has 6 available attribution models to choose from :

    1. First interaction
    2. Last interaction
    3. Last non-direct 
    4. Linear
    5. Position based
    6. Time decay 

    These additional attribution models are crucial for B2B sites. While other web analytics solutions often limit to last-click attribution, this model isn’t optimal for B2B with extended sales cycles.

    Try Matomo for Free

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

    No credit card required

    Use a CRM to integrate customer data from multiple sources

    Use your CRM software to integrate customer data from multiple sources. This will give you the ability to get meaningful B2B marketing insights. For example, you can get company-level insights so you can view conversion information by company, not just by person.

    Done effectively, you can close the loop back to analytics data by integrating data from multiple teams and platforms. 

    Implement self-reported attribution

    To further enhance the data, add qualifying questions in the lead signup process to create a hybrid attribution model. This is also known as self-reported attribution.

    Example of self-reported attribution

    Your web analytics platform won’t always be able to track the source of certain visits — for instance, “dark social” or peer-to-peer sharing, where links are shared privately and are not easily traceable by analytics tools.

    Doing self-reported attribution is crucial for getting a holistic image of your customer journey. 

    However, self-reported attribution isn’t foolproof ; users may click randomly or inaccurately recall where they first heard about you. So it’s essential to blend this data with your analytics to gain a more accurate understanding.

    Best practices for handling B2B prospect data in a privacy-sensitive world 

    Lastly, it’s important to respect your prospects’ privacy and comply with privacy regulations when conducting B2B marketing attribution.

    Privacy regulations and their enforcement are rapidly gaining momentum around the globe. Meta recently received a record GDPR fine of €1.2 billion for insufficient privacy measures when handling user data by the Irish Data Protection Agency.

    If you don’t want to risk major fines (or customers feeling betrayed), you shouldn’t follow in the same footsteps.

    Switch to a privacy-friendly web analytics

    Instead of using a controversial solution like Google Analytics, use a privacy-friendly web analytics solution like Matomo, Fathom or Plausible. 

    These alternatives not only ensure compliance with regulations like GDPR but also provide peace of mind amid the uncertain relationship between Google and GDPR. Google Analytics has faced bans in recent years, raising concerns about the future of the solution.

    While organisations governed by GDPR can currently use Google Analytics, there’s no guarantee of its continued availability.

    Make the switch to privacy-friendly web analytics to avoid potential fines and disruptive rulings that could force you to change platforms urgently. Such disruptions can be catastrophic for marketing teams heavily reliant on web analytics for tracking campaigns, business goals and marketing efforts.

    Improve your B2B marketing attribution with Matomo

    Matomo’s privacy-by-design architecture makes it the perfect analytics platform for the modern B2B marketer. Matomo enables you to meet even the strictest privacy regulations.

    At the same time, through campaign tracking URLs, marketing attribution, integrations and our API, you can track the results of various marketing channels and campaigns effectively. We help you understand the impact of each dollar of your marketing budget. 

    If you want a competitive edge over other B2B companies, try Matomo for free for 21 days. No credit card required.

  • FFMPEG error submitting a packet to the muxer

    27 juillet 2024, par Badgio10177

    I am attempting to stream video frames to a RTSP server using FFMPEG. I instantiate an ffmpeg pipeline in c++. There are times when the process works perfectly and other times I get the error Error submitting a packet to the muxer : Broken pipe. Error muxing a packet. What uis strange is that there are times when the stream works and times when it does not which leads me to believe that the FFMPEG parameters that I set are not necessarily incorrect.

    


    I am using a mex function within MATLAB to take in a frame and stream it.

    


    // Global variables&#xA;FILE* openPipeLine = NULL;&#xA;&#xA;void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], int frameWidth, int frameHeight)&#xA;{&#xA;&#xA;    Ptr<mat> inputFrame = ocvMxArrayToImage_uint8(prhs[0], true);&#xA;    Mat processedFrame = *inputFrame;&#xA;&#xA;    // Check if FFMPEG process has been started&#xA;    if (!openPipeLine)&#xA;    {&#xA;        openPipeLine = _popen("ffmpeg -report -f rawvideo -r 10 -video_size 1280x720 -pixel_format bgr24 -i pipe: -vcodec libx264 -pix_fmt yuv420p -f rtsp rtsp://localhost:8554/mystream 2> log.txt", "wb");&#xA;&#xA;    }&#xA;&#xA;    // Write the frame data to the pipeline&#xA;    fwrite(processedFrame.data, 1, frameWidth * frameHeight * 3, openPipeLine);&#xA;    mexAtExit(exitFcn);&#xA;}&#xA;</mat>

    &#xA;

    Below is the full report from the ffmpeg process. Do my operating system variables change from time to time which cause the stream to work at times and break at others ? I am using Windows 10.

    &#xA;

    Log level: 48&#xA;Command line:&#xA;ffmpeg -report -f rawvideo -r 10 -video_size 1280x720 -pixel_format bgr24 -i pipe: -vcodec libx264 -pix_fmt yuv420p -f rtsp rtsp://localhost:8554/mystream&#xA;&#xA;  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)&#xA;  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-lib  libavutil      58. 16.101 / 58. 16.101&#xA;  libavcodec     60. 23.100 / 60. 23.100&#xA;  libavformat    60. 10.100 / 60. 10.100&#xA;  libavdevice    60.  2.101 / 60.  2.101&#xA;  libavfilter     9. 11.100 /  9. 11.100&#xA;  libswscale      7.  3.100 /  7.  3.100&#xA;  libswresample   4. 11.100 /  4. 11.100&#xA;  libpostproc    57.  2.100 / 57.  2.100&#xA;Splitting the commandline.&#xA;&#xA;Successfully parsed a group of options.&#xA;Opening an input file: pipe:.&#xA;[rawvideo @ 00000182dba5efc0] Opening &#x27;pipe:&#x27; for reading&#xA;[pipe @ 00000182dba611c0] Setting default whitelist &#x27;crypto,data&#x27;&#xA;[rawvideo @ 00000182dba5efc0] Before avformat_find_stream_info() pos: 0 bytes read:65536 seeks:0 nb_streams:1&#xA;[rawvideo @ 00000182dba5efc0] All info found&#xA;[rawvideo @ 00000182dba5efc0] After avformat_find_stream_info() pos: 2764800 bytes read:2764800 seeks:0 frames:1&#xA;Input #0, rawvideo, from &#x27;pipe:&#x27;:&#xA;  Duration: N/A, start: 0.000000, bitrate: 221184 kb/s&#xA;  Stream #0:0, 1, 1/10: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, 221184 kb/s, 10 tbr, 10 tbn&#xA;Successfully opened the file.&#xA;Parsing a group of options: output url rtsp://192.168.0.2:8554/mystream.&#xA;Applying option vcodec (force video codec (&#x27;copy&#x27; to copy stream)) with argument libx264.&#xA;Applying option pix_fmt (set pixel format) with argument yuv420p.&#xA;Applying option f (force format) with argument rtsp.&#xA;Successfully parsed a group of options.&#xA;Opening an output file: rtsp://192.168.0.2:8554/mystream.&#xA;[out#0/rtsp @ 00000182dba72c00] No explicit maps, mapping streams automatically...&#xA;[vost#0:0/libx264 @ 00000182dba75cc0] Created video stream from input stream 0:0&#xA;Successfully opened the file.&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))&#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;detected 16 logical cores&#xA;[graph 0 input from stream 0:0 @ 00000182dba86180] Setting &#x27;video_size&#x27; to value &#x27;1280x720&#x27;&#xA;[graph 0 input from stream 0:0 @ 00000182dba86180] Setting &#x27;pix_fmt&#x27; to value &#x27;3&#x27;&#xA;[graph 0 input from stream 0:0 @ 00000182dba86180] Setting &#x27;time_base&#x27; to value &#x27;1/10&#x27;&#xA;[graph 0 input from stream 0:0 @ 00000182dba86180] Setting &#x27;pixel_aspect&#x27; to value &#x27;0/1&#x27;&#xA;[graph 0 input from stream 0:0 @ 00000182dba86180] Setting &#x27;frame_rate&#x27; to value &#x27;10/1&#x27;&#xA;[graph 0 input from stream 0:0 @ 00000182dba86180] w:1280 h:720 pixfmt:bgr24 tb:1/10 fr:10/1 sar:0/1&#xA;[format @ 00000182dba86540] Setting &#x27;pix_fmts&#x27; to value &#x27;yuv420p&#x27;&#xA;[auto_scale_0 @ 00000182dba869c0] w:iw h:ih flags:&#x27;&#x27; interl:0&#xA;[format @ 00000182dba86540] auto-inserting filter &#x27;auto_scale_0&#x27; between the filter &#x27;Parsed_null_0&#x27; and the filter &#x27;format&#x27;&#xA;[AVFilterGraph @ 00000182dba49040] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed&#xA;[auto_scale_0 @ 00000182dba869c0] w:1280 h:720 fmt:bgr24 sar:0/1 -> w:1280 h:720 fmt:yuv420p sar:0/1 flags:0x00000004&#xA;[libx264 @ 00000182dba76080] using mv_range_thread = 24&#xA;[libx264 @ 00000182dba76080] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512&#xA;[libx264 @ 00000182dba76080] profile High, level 3.1, 4:2:0, 8-bit&#xA;[libx264 @ 00000182dba76080] 264 - core 164 r3107 a8b68eb - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;[tcp @ 00000182dc5ce480] No default whitelist set&#xA;[tcp @ 00000182dc5ce480] Original list of addresses:&#xA;[tcp @ 00000182dc5ce480] Address 192.168.0.2 port 8554&#xA;[tcp @ 00000182dc5ce480] Interleaved list of addresses:&#xA;[tcp @ 00000182dc5ce480] Address 192.168.0.2 port 8554&#xA;[tcp @ 00000182dc5ce480] Starting connection attempt to 192.168.0.2 port 8554&#xA;[tcp @ 00000182dc5ce480] Successfully connected to 192.168.0.2 port 8554&#xA;[rtsp @ 00000182dba72d00] SDP:&#xA;v=0&#xA;&#xA;o=- 0 0 IN IP4 127.0.0.1&#xA;&#xA;s=No Name&#xA;&#xA;c=IN IP4 192.168.0.2&#xA;&#xA;t=0 0&#xA;&#xA;a=tool:libavformat 60.10.100&#xA;&#xA;m=video 0 RTP/AVP 96&#xA;&#xA;a=rtpmap:96 H264/90000&#xA;&#xA;a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAH6zZQFAFuhAAAAMAEAAAAwFA8YMZYA==,aOvjyyLA; profile-level-id=64001F&#xA;&#xA;a=control:streamid=0&#xA;&#xA;&#xA;[rtp @ 00000182dc5cd040] No default whitelist set&#xA;[udp @ 00000182dba4b140] No default whitelist set&#xA;[udp @ 00000182dba4b140] end receive buffer size reported is 393216&#xA;[udp @ 00000182dc9bf040] No default whitelist set&#xA;[udp @ 00000182dc9bf040] end receive buffer size reported is 393216&#xA;Output #0, rtsp, to &#x27;rtsp://192.168.0.2:8554/mystream&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf60.10.100&#xA;  Stream #0:0, 0, 1/90000: Video: h264, yuv420p(tv, progressive), 1280x720, q=2-31, 10 fps, 90k tbn&#xA;    Metadata:&#xA;      encoder         : Lavc60.23.100 libx264&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;frame=    0 fps=0.0 q=0.0 size=       0kB time=N/A bitrate=N/A speed=N/A    &#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;frame=    0 fps=0.0 q=0.0 size=       0kB time=N/A bitrate=N/A speed=N/A    &#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;frame=    0 fps=0.0 q=0.0 size=       0kB time=N/A bitrate=N/A speed=N/A    &#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840   &#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;[libx264 @ 00000182dba76080] frame=   0 QP=21.34 NAL=3 Slice:I Poc:0   I:3600 P:0    SKIP:0    size=135901 bytes&#xA;frame=    0 fps=0.0 q=25.0 size=       0kB time=-00:00:00.20 bitrate=  -0.0kbits/s speed=N/A    &#xA;[vost#0:0/libx264 @ 00000182dba75cc0] Error submitting a packet to the muxer: Broken pipe&#xA;[out#0/rtsp @ 00000182dba72c00] Error muxing a packet&#xA;[out#0/rtsp @ 00000182dba72c00] Terminating muxer thread&#xA;[rawvideo @ 00000182dba72700] PACKET SIZE: 2764800, STRIDE: 3840&#xA;[libx264 @ 00000182dba76080] frame=   1 QP=18.29 NAL=2 Slice:P Poc:2   I:2662 P:866  SKIP:72   size=54835 bytes&#xA;frame=    1 fps=0.0 q=25.0 size=N/A time=-00:00:00.10 bitrate=N/A speed=N/A    &#xA;No more output streams to write to, finishing.&#xA;&#xA;Conversion failed!&#xA;&#xA;

    &#xA;

  • Using PyAV to encode mono audio to file, params match docs, but still causes Errno 22

    20 février 2023, par andrew8088

    While trying to use PyAV to encode live mono audio from a microphone to a compressed audio stream (using mp2 or flac as encoder), the program kept raising an exception ValueError: [Errno 22] Invalid argument.

    &#xA;

    To remove the live microphone source as a cause of the problem, and to make the problematic code easier for others to run/test, I have removed the mic source and now just generate a pure tone as a sequence of input buffers.

    &#xA;

    All attempts to figure out the missing or mismatched or incorrect argument have just resulted in seeing documentation and examples that are the same as my code.

    &#xA;

    I would like to know from someone who has used PyAV successfully for mono audio what the correct method and parameters are for encoding mono frames into the mono stream.

    &#xA;

    The package used is av 10.0.0 installed with&#xA;pip3 install av --no-binary av&#xA;so it uses my package-manager provided ffmpeg library, which is version 4.2.7.

    &#xA;

    The problematic python code is :

    &#xA;

    #!/usr/bin/env python3&#xA;# -*- coding: utf-8 -*-&#xA;"""&#xA;Recreating an error 22 when encoding sound with PyAV.&#xA;&#xA;Created on Sun Feb 19 08:10:29 2023&#xA;@author: andrewm&#xA;"""&#xA;import typing&#xA;import sys&#xA;import math&#xA;import fractions&#xA;&#xA;import av&#xA;from av import AudioFrame&#xA;&#xA;""" Ensure some PyAudio constants are still defined without changing &#xA;    the PyAudio recording callback function and without depending &#xA;    on PyAudio simply for reproducing the PyAV bug [Errno 22] thrown in &#xA;    File "av/filter/context.pyx", line 89, in av.filter.context.FilterContext.push&#xA;"""&#xA;class PA_Stub():&#xA;    paContinue = True&#xA;    paComplete= False&#xA;&#xA;pyaudio = PA_Stub()&#xA;&#xA;&#xA;"""Generate pure tone at given frequency with amplitude 0...1.0 at &#xA;   sampling frewuency fs and beginning at phase offset &#x27;phase&#x27;.&#xA;   Returns the new phase after the sinusoid has cycled over the &#xA;   sampling window length.&#xA;"""&#xA;def generate_tone(&#xA;        freq:int, phase:float, amp:float, fs, samp_fmt, buffer:bytearray&#xA;) -> float:&#xA;    assert samp_fmt == "s16", "Only s16 supported atm"&#xA;    samp_size_bytes = 2&#xA;    n_samples = int(len(buffer)/samp_size_bytes)&#xA;    window = [int(0) for i in range(n_samples)]&#xA;    theta = phase&#xA;    phase_inc = 2*math.pi * freq / fs&#xA;    for i in range(n_samples):&#xA;        v = amp * math.sin(theta)&#xA;        theta &#x2B;= phase_inc&#xA;        s = int((2**15-1)*v)&#xA;        window[i] = s&#xA;    for sample_i in range(len(window)):&#xA;        byte_i = sample_i * samp_size_bytes&#xA;        enc = window[sample_i].to_bytes(&#xA;                2, byteorder=sys.byteorder, signed=True&#xA;        )&#xA;        buffer[byte_i] = enc[0]&#xA;        buffer[byte_i&#x2B;1] = enc[1]&#xA;    return theta&#xA;&#xA;&#xA;channels = 1&#xA;fs = 44100  # Record at 44100 samples per second&#xA;fft_size_samps = 256&#xA;chunk_samps = fft_size_samps * 10  # Record in chunks that are multiples of fft windows.&#xA;&#xA;# print(f"fft_size_samps={fft_size_samps}\nchunk_samps={chunk_samps}")&#xA;&#xA;seconds = 3.0&#xA;out_filename = "testoutput.wav"&#xA;&#xA;# Store data in chunks for 3 seconds&#xA;sample_limit = int(fs * seconds)&#xA;sample_len = 0&#xA;frames = []  # Initialize array to store frames&#xA;&#xA;ffmpeg_codec_name = &#x27;mp2&#x27;  # flac, mp3, or libvorbis make same error.&#xA;&#xA;sample_size_bytes = 2&#xA;buffer = bytearray(int(chunk_samps*sample_size_bytes))&#xA;chunkperiod = chunk_samps / fs&#xA;total_chunks = int(math.ceil(seconds / chunkperiod))&#xA;phase = 0.0&#xA;&#xA;### uncomment if you want to see the synthetic data being used as a mic input.&#xA;# with open("test.raw","wb") as raw_out:&#xA;#     for ci in range(total_chunks):&#xA;#         phase = generate_tone(2600, phase, 0.8, fs, "s16", buffer)&#xA;#         raw_out.write(buffer)&#xA;# print("finished gen test")&#xA;# sys.exit(0)&#xA;# #---- &#xA;&#xA;# Using mp2 or mkv as the container format gets the same error.&#xA;with av.open(out_filename&#x2B;&#x27;.mp2&#x27;, "w", format="mp2") as output_con:&#xA;    output_con.metadata["title"] = "My title"&#xA;    output_con.metadata["key"] = "value"&#xA;    channel_layout = "mono"&#xA;    sample_fmt = "s16p"&#xA;&#xA;    ostream = output_con.add_stream(ffmpeg_codec_name, fs, layout=channel_layout)&#xA;    assert ostream is not None, "No stream!"&#xA;    cctx = ostream.codec_context&#xA;    cctx.sample_rate = fs&#xA;    cctx.time_base = fractions.Fraction(numerator=1,denominator=fs)&#xA;    cctx.format = sample_fmt&#xA;    cctx.channels = channels&#xA;    cctx.layout = channel_layout&#xA;    print(cctx, f"layout#{cctx.channel_layout}")&#xA;    &#xA;    # Define PyAudio-style callback for recording plus PyAV transcoding.&#xA;    def rec_callback(in_data, frame_count, time_info, status):&#xA;        global sample_len&#xA;        global ostream&#xA;        frames.append(in_data)&#xA;        nsamples = int(len(in_data) / (channels*sample_size_bytes))&#xA;        &#xA;        frame = AudioFrame(format=sample_fmt, layout=channel_layout, samples=nsamples)&#xA;        frame.sample_rate = fs&#xA;        frame.time_base = fractions.Fraction(numerator=1,denominator=fs)&#xA;        frame.pts = sample_len&#xA;        frame.planes[0].update(in_data)&#xA;        print(frame, len(in_data))&#xA;        &#xA;        for out_packet in ostream.encode(frame):&#xA;            output_con.mux(out_packet)&#xA;        for out_packet in ostream.encode(None):&#xA;            output_con.mux(out_packet)&#xA;        &#xA;        sample_len &#x2B;= nsamples&#xA;        retflag = pyaudio.paContinue if sample_lencode>

    &#xA;

    If you uncomment the RAW output part you will find the generated data can be imported as PCM s16 Mono 44100Hz into Audacity and plays the expected tone, so the generated audio data does not seem to be the problem.

    &#xA;

    The normal program console output up until the exception is :

    &#xA;

    mp2 at 0x7f8e38202cf0> layout#4&#xA;Beginning&#xA; 5120&#xA;. 5120&#xA;

    &#xA;

    The stack trace is :

    &#xA;

    Traceback (most recent call last):&#xA;&#xA;  File "Dev/multichan_recording/av_encode.py", line 147, in <module>&#xA;    ret_data, ret_flag = rec_callback(buffer, ci, {}, 1)&#xA;&#xA;  File "Dev/multichan_recording/av_encode.py", line 121, in rec_callback&#xA;    for out_packet in ostream.encode(frame):&#xA;&#xA;  File "av/stream.pyx", line 153, in av.stream.Stream.encode&#xA;&#xA;  File "av/codec/context.pyx", line 484, in av.codec.context.CodecContext.encode&#xA;&#xA;  File "av/audio/codeccontext.pyx", line 42, in av.audio.codeccontext.AudioCodecContext._prepare_frames_for_encode&#xA;&#xA;  File "av/audio/resampler.pyx", line 101, in av.audio.resampler.AudioResampler.resample&#xA;&#xA;  File "av/filter/graph.pyx", line 211, in av.filter.graph.Graph.push&#xA;&#xA;  File "av/filter/context.pyx", line 89, in av.filter.context.FilterContext.push&#xA;&#xA;  File "av/error.pyx", line 336, in av.error.err_check&#xA;&#xA;ValueError: [Errno 22] Invalid argument&#xA;&#xA;</module>

    &#xA;

    edit : It's interesting that the error happens on the 2nd AudioFrame, as apparently the first one was encoded okay, because they are given the same attribute values aside from the Presentation Time Stamp (pts), but leaving this out and letting PyAV/ffmpeg generate the PTS by itself does not fix the error, so an incorrect PTS does not seem the cause.

    &#xA;

    After a brief glance in av/filter/context.pyx the exception must come from a bad return value from res = lib.av_buffersrc_write_frame(self.ptr, frame.ptr)
    &#xA;Trying to dig into av_buffersrc_write_frame from the ffmpeg source it is not clear what could be causing this error. The only obvious one is a mismatch between channel layouts, but my code is setting the layout the same in the Stream and the Frame. That problem had been found by an old question pyav - cannot save stream as mono and their answer (that one parameter required is undocumented) is the only reason the code now has the layout='mono' argument when making the stream.

    &#xA;

    The program output shows layout #4 is being used, and from https://github.com/FFmpeg/FFmpeg/blob/release/4.2/libavutil/channel_layout.h you can see this is the value for symbol AV_CH_FRONT_CENTER which is the only channel in the MONO layout.

    &#xA;

    The mismatch is surely some other object property or an undocumented parameter requirement.

    &#xA;

    How do you encode mono audio to a compressed stream with PyAV ?

    &#xA;