Recherche avancée

Médias (0)

Mot : - Tags -/tags

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

Autres articles (50)

Sur d’autres sites (9112)

  • FFMPEG conversion failed at random times on live stream to youtube

    3 avril 2022, par good karma

    I am running a bash script using ubuntu server on arm64 that live streams video and audio to youtube, heres the script below

    


    FFMPEG is the lateset version available in the ubuntu repo

    


    #! /bin/bash

VBR="8000k"
FPS="24"
QUAL="superfast"

YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
KEY="****"

VIDEO_SOURCE="/mnt/disk1/test/****"

AUDIO_SOURCE="****"

ffmpeg \
    -re -f lavfi -i "movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)" \
    -thread_queue_size 512 -i "$AUDIO_SOURCE" \
    -map 0:v:0 -map 1:a:0 \
    -map_metadata:g 1:g \
    -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
    -acodec libmp3lame -ar 44100 -threads 4 -qscale:v 3 -b:a 320000 -bufsize 512k \
    -report -loglevel fatal -nostats  \
    -f flv "$YOUTUBE_URL/$KEY"


    


    The stream works fine, however after a seemingly random period of time, I get a conversion failed error

    


    first after 64 hours of streaming
second after 12 hours of streaming
third after 8 hours of streaming

    


    The server itsef is fine cpu and memory usage are extremly low and there are no spikes

    


    from what i can guess the error has something to do with libx264 judging by the error logs, although I do not really know. After some guidance on what to do try next. Here is the tail end of the ffmpeg log report

    


    [libx264 @ 0xaaab23ad3e30] frame=1351975 QP=16.89 NAL=2 Slice:P Poc:14  I:6461 P:1224 SKIP:475  size=26602 bytes
av_interleaved_write_frame(): Broken pipe
No more output streams to write to, finishing.
[libx264 @ 0xaaab23ad3e30] frame=1351976 QP=17.90 NAL=2 Slice:B Poc:10  I:2395 P:3322 SKIP:2443 size=20127 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351977 QP=17.89 NAL=0 Slice:B Poc:12  I:1848 P:3235 SKIP:3077 size=17313 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351978 QP=15.65 NAL=2 Slice:P Poc:22  I:6458 P:1171 SKIP:531  size=26073 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351979 QP=17.19 NAL=2 Slice:B Poc:18  I:2766 P:3514 SKIP:1880 size=19633 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351980 QP=18.35 NAL=0 Slice:B Poc:16  I:1233 P:2876 SKIP:4051 size=11769 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351981 QP=17.28 NAL=0 Slice:B Poc:20  I:822  P:3197 SKIP:4141 size=10699 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351982 QP=17.08 NAL=2 Slice:P Poc:30  I:6351 P:1443 SKIP:366  size=29120 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351983 QP=17.29 NAL=2 Slice:B Poc:26  I:2060 P:4211 SKIP:1889 size=18465 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351984 QP=18.00 NAL=0 Slice:B Poc:24  I:472  P:3225 SKIP:4463 size=8893 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351985 QP=17.98 NAL=0 Slice:B Poc:28  I:1339 P:3681 SKIP:3140 size=13378 bytes
[libx264 @ 0xaaab23ad3e30] frame=1351986 QP=15.57 NAL=2 Slice:P Poc:32  I:6270 P:1584 SKIP:306  size=33703 bytes
av_interleaved_write_frame(): Broken pipe
[libmp3lame @ 0xaaab23ac06f0] Trying to remove 47 more samples than there are in the queue
[flv @ 0xaaab23ad2ff0] Failed to update header with correct duration.
[flv @ 0xaaab23ad2ff0] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/****: Broken pipe
frame=1351987 fps= 24 q=22.0 Lsize=37296521kB time=15:38:52.22 bitrate=5423.8kbits/s dup=0 drop=56332 speed=   1x    
video:35035969kB audio:2200479kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.161329%
Input file #0 (movie=filename=/mnt/disk1/test/****.mp4:loop=0, setpts=N/(FRAME_RATE*TB)):
  Input stream #0:0 (video): 1408319 packets read (4380435417600 bytes); 1408319 frames decoded; 
  Total: 1408319 packets (4380435417600 bytes) demuxed
Input file #1 (https://****.mp3):
  Input stream #1:0 (audio): 2156470 packets read (901316441 bytes); 2156470 frames decoded (2484253440 samples); 
  Total: 2156470 packets (901316441 bytes) demuxed
Output file #0 (rtmp://a.rtmp.youtube.com/live2/****):
  Output stream #0:0 (video): 1351987 frames encoded; 1351976 packets muxed (35876832486 bytes); 
  Output stream #0:1 (audio): 2156470 frames encoded (2484253440 samples); 2156469 packets muxed (2253290057 bytes); 
  Total: 3508445 packets (38130122543 bytes) muxed
3564789 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0xaaab23ac4ef0] Statistics: 0 seeks, 3823215 writeouts
[rtmp @ 0xaaab23dab6a0] UnPublishing stream...
[rtmp @ 0xaaab23dab6a0] Deleting stream...
[libx264 @ 0xaaab23ad3e30] frame I:53166 Avg QP:16.31  size: 39514
[libx264 @ 0xaaab23ad3e30] frame P:500115 Avg QP:17.79  size: 32831
[libx264 @ 0xaaab23ad3e30] frame B:798706 Avg QP:19.67  size: 21732
[libx264 @ 0xaaab23ad3e30] consecutive B-frames: 13.9% 15.2% 20.2% 50.7%
[libx264 @ 0xaaab23ad3e30] mb I  I16..4: 45.9% 44.7%  9.4%
[libx264 @ 0xaaab23ad3e30] mb P  I16..4: 40.6% 37.1%  2.2%  P16..4: 16.5%  0.0%  0.0%  0.0%  0.0%    skip: 3.7%
[libx264 @ 0xaaab23ad3e30] mb B  I16..4: 16.3% 16.2%  0.2%  B16..8: 25.0%  0.0%  0.0%  direct:19.7%  skip:22.5%  L0:48.7% L1:48.4% BI: 2.9%
[libx264 @ 0xaaab23ad3e30] 8x8 transform intra:47.5% inter:31.9%
[libx264 @ 0xaaab23ad3e30] coded y,uvDC,uvAC intra: 15.8% 78.7% 25.0% inter: 2.0% 60.3% 1.8%
[libx264 @ 0xaaab23ad3e30] i16 v,h,dc,p: 50% 20%  9% 21%
[libx264 @ 0xaaab23ad3e30] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 16% 31%  4%  7%  5%  5%  6%  6%
[libx264 @ 0xaaab23ad3e30] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 20% 33%  2%  2%  2%  1%  2%  2%
[libx264 @ 0xaaab23ad3e30] i8c dc,h,v,p: 29% 18% 18% 35%
[libx264 @ 0xaaab23ad3e30] Weighted P-Frames: Y:3.0% UV:2.2%
[libx264 @ 0xaaab23ad3e30] kb/s:5095.01
[AVIOContext @ 0xaaab22460eb0] Statistics: 42281852862 bytes read, 2731 seeks
[AVIOContext @ 0xaaab23ac4de0] Statistics: 901390389 bytes read, 0 seeks
Conversion failed!


    


  • ffplay cannot play more than one song

    5 février 2020, par Bernie gach

    i have taken ffplay.c file from http://ffmpeg.org/doxygen/trunk/ffplay_8c-source.html and re edited it to a cpp file to embed in my win32 gui application . i have made the following changes to it.

    1. made the int main function into a local function as follows, i can pass the HWND to embedd the player
    void Ffplay::play_song(string file, HWND parent, bool* successfull)
    {
       int flags;
       VideoState* is;
       input_filename = file;
       /* register all codecs, demux and protocols */
    #if CONFIG_AVDEVICE
       avdevice_register_all();
    #endif
       //avformat_network_init();
       //check whether the filename is valid
       if (input_filename.empty())
       {
           logger.log(logger.LEVEL_ERROR, "filename %s is not valid\n", file);
           return;
       }
       if (display_disable)
       {
           video_disable = 1;
       }
       flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
       if (audio_disable)
           flags &= ~SDL_INIT_AUDIO;
       else
       {
           /* Try to work around an occasional ALSA buffer underflow issue when the
            * period size is NPOT due to ALSA resampling by forcing the buffer size. */
           if (!SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE"))
               SDL_setenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE", "1", 1);
       }
       if (display_disable)
           flags &= ~SDL_INIT_VIDEO;
       SDL_SetMainReady();
       if (SDL_Init(flags))
       {
           logger.log(logger.LEVEL_ERROR, "Could not initialize SDL - %s\n", SDL_GetError());
           logger.log(logger.LEVEL_ERROR, "(Did you set the DISPLAY variable?)\n");
           return;
       }
       //Initialize optional fields of a packet with default values.
       //Note, this does not touch the data and size members, which have to be initialized separately.
       av_init_packet(&flush_pkt);
       flush_pkt.data = (uint8_t*)&flush_pkt;

       if (!display_disable)
       {
           int flags = SDL_WINDOW_HIDDEN;
           if (alwaysontop)
    #if SDL_VERSION_ATLEAST(2,0,5)
               flags |= SDL_WINDOW_ALWAYS_ON_TOP;
    #else
               logger.log(logger.LEVEL_INFO, "SDL version doesn't support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
    #endif
           if (borderless)
               flags |= SDL_WINDOW_BORDERLESS;
           else
               flags |= SDL_WINDOW_RESIZABLE;
           SDL_InitSubSystem(flags);
           ShowWindow(parent, true);
           //window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);
           window = SDL_CreateWindowFrom(parent);
           SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
           if (window) {
               renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
               if (!renderer)
               {
                   logger.log(logger.LEVEL_ERROR, "Failed to initialize a hardware accelerated renderer: %s\n", SDL_GetError());
                   renderer = SDL_CreateRenderer(window, -1, 0);
               }
               if (renderer)
               {
                   if (!SDL_GetRendererInfo(renderer, &renderer_info))
                   {
                       logger.log(logger.LEVEL_INFO, "Initialized %s renderer.\n", renderer_info.name);
                   }
               }
           }
           if (!window || !renderer || !renderer_info.num_texture_formats)
           {
               logger.log(logger.LEVEL_ERROR, "Failed to create window or renderer: %s\n", SDL_GetError());
               return;
           }
       }

       is = stream_open(input_filename.c_str(), file_iformat);
       if (!is)
       {
           logger.log(logger.LEVEL_ERROR, "Failed to initialize VideoState!\n");
           return;
       }
       //the song is playing now
       *successfull = true;
       event_loop(is);
       //the song has quit;
       *successfull = false;
    }
    1. changed the callback functions as the static ones couldn’t be used by c++ eg,
    void Ffplay::static_sdl_audio_callback(void* opaque, Uint8* stream, int len)
    {
       static_cast(opaque)->sdl_audio_callback(opaque, stream, len);
    }

    closing doesn’t change from the main file to close the audio and sdl framework

    void Ffplay::do_exit(VideoState* is)
    {
       abort = true;
       if(is)
       {
           stream_close(is);
       }
       if (renderer)
           SDL_DestroyRenderer(renderer);
       if (window)
            SDL_DestroyWindow(window);
    #if CONFIG_AVFILTER
       av_freep(&vfilters_list);
    #endif
       avformat_network_deinit();
       SDL_Quit();

    }

    i call the functions as follows from main gui

    ft=std::async(launch::async, &Menu::play_song, this, songs_to_play.at(0));

    the menu::play_song function is :

    void Menu::play_song(wstring song_path)
    {
       ready_to_play_song = false;
       OutputDebugString(L"\nbefore song\n");
       using std::future;
       using std::async;
       using std::launch;

       string input{ song_path.begin(),song_path.end() };
       Ffplay ffplay;
       ffplay.play_song(input, h_sdl_window, &song_opened);

       OutputDebugString(L"\nafter song\n");
       ready_to_play_song = true;
    }

    THE PROBLEM is i can only play one song . if i call the menu::play_song function again the sound is missing and the video/art cover is occasionally missing also. it seems some resources are not been released or something like that.

    i have localised the proble to this function

    int Ffplay::packet_queue_get(PacketQueue* q, AVPacket* pkt, int block, int* serial)
    {

       MyAVPacketList* pkt1;
       int ret;
       int count=0;
       SDL_LockMutex(q->mutex);

       for (;;)
       {


           if (q->abort_request)
           {
               ret = -1;
               break;
           }

           pkt1 = q->first_pkt;
           if (pkt1) {
               q->first_pkt = pkt1->next;
               if (!q->first_pkt)
                   q->last_pkt = NULL;
               q->nb_packets--;
               q->size -= pkt1->pkt.size + sizeof(*pkt1);
               q->duration -= pkt1->pkt.duration;
               *pkt = pkt1->pkt;
               if (serial)
                   *serial = pkt1->serial;
               av_free(pkt1);
               ret = 1;
               break;
           }
           else if (!block) {
               ret = 0;
               break;
           }
           else
           {
               logger.log(logger.LEVEL_INFO, "packet_queue before");
               SDL_CondWait(q->cond, q->mutex);
               logger.log(logger.LEVEL_INFO, "packet_queue after");

           }
       }
       SDL_UnlockMutex(q->mutex);
       return ret;
    }

    the call to SDL_CondWait(q->cond, q->mutex); never returns

  • Google Analytics 4 (GA4) vs Universal Analytics (UA)

    24 janvier 2022, par Erin — Analytics Tips

    March 2022 Update : It’s official ! Google announced that Universal Analytics will no longer process any new data as of 1 July 2023. Google is now pushing Universal Analytics users to switch to the latest version of GA – Google Analytics 4. 

    Currently, Google Analytics 4 is unable to accept historical data from Universal Analytics. Users need to take action before July 2022, to ensure they have 12 months of data built up before the sunset of Universal Analytics

    So how do Universal Analytics and Google Analytics 4 compare ? And what alternative options do you have ? Let’s dive in. 

    In this blog, we’ll cover :

    What is Google Analytics 4 ? 

    In October 2020, Google launched Google Analytics 4, a completely redesigned analytics platform. This follows on from the previous version known as Universal Analytics (or UA).

    Amongst its touted benefits, GA4 promises a completely new way to model data and even the ability to predict future revenue. 

    However, the reception of GA4 has been largely negative. In fact, some users from the digital marketing community have said that GA4 is awful, unusable and so bad it can bring you to tears.

    Gill Andrews via Twitter

    Google Analytics 4 vs Universal Analytics

    There are some pretty big differences between Google Analytics 4 and Universal Analytics but for this blog, we’ll cover the top three.

    1. Redesigned user interface (UI)

    GA4 features a completely redesigned UI to Universal Analytics’ popular interface. This dramatic change has left many users in confusion and fuelled some users to declare that “most of the time you are going round in circles to find what you’re looking for.”

    Google Analytics 4 missing features
    Mike Huggard via Twitter

    2. Event-based tracking

    Google Analytics 4 also brings with it a new data model which is purely event-based. This event-based model moves away from the typical “pageview” metric that underpins Universal Analytics.

    3. Machine learning insights

    Google Analytics 4 promises to “predict the future behavior of your users” with their machine-learning-powered predictive metrics. This feature can “use shared aggregated and anonymous data to improve model quality”. Sounds powerful, right ?

    Unfortunately, it only works if at least 1,000 returning users triggered the relevant predictive condition over a seven-day period. Also, if the model isn’t sustained over a “period of time” then it won’t work. And according to Google, if “the model quality for your property falls below the minimum threshold, then Analytics will stop updating the corresponding predictions”.

    This means GA4’s machine learning insights probably won’t work for the majority of analytics users.

    Ultimately, GA4 is just not ready to replace Google’s Universal Analytics for most users. There are too many missing features.

    What’s missing in Google Analytics 4 ?

    Quite a lot. Even though it offers a completely new approach to analytics, there are a lot of key features and functions missing in GA4.

    Behavior Flow

    The Behavior Flow report in Universal Analytics helps to visualise the path users take from one page or Event to the next. It’s extremely useful when you’re looking for quick and clear insight. But it no longer exists in Google Analytics 4, and instead, two new overcomplicated reports have been introduced to replace it – funnel exploration report and path exploration report.

    The decision to remove this critical report will leave many users feeling disappointed and frustrated. 

    Limitations on custom dimensions

    You can create custom dimensions in Google Analytics 4 to capture advanced information. For example, if a user reads a blog post you can supplement that data with custom dimensions like author name or blog post length. But, you can only use up to 50, and for some that will make functionality like this almost pointless.

    Machine learning (ML) limitations

    Google Analytics 4 promises powerful ML insights to predict the likelihood of users converting based on their behaviors. The problem ? You need 1,000 returning users in one week. For most small-medium businesses this just isn’t possible.

    And if you do get this level of traffic in a week, there’s another hurdle. According to Google, if “the model quality for your property falls below the minimum threshold, then GA will stop updating the corresponding predictions.” To add insult to injury Google suggests that this might make all ML insights unavailable. But they can’t say for certain… 

    Views

    One cornerstone of Universal Analytics is the ability to configure views. Views allow you to set certain analytics environments for testing or cleaning up data by filtering out internal traffic, for example. 

    Views are great for quickly and easily filtering data. Preset views that contain just the information you want to see are the ideal analytics setup for smaller businesses, casual users, and do-it-yourself marketing departments.

    Via Reddit

    There are a few workarounds but they’re “messy [,] annoying and clunky,” says a disenfranchised Redditor.

    Another helpful Reddit user stumbled upon an unhelpful statement from Google. Google says that they “do not offer [the views] feature in Google Analytics 4 but are planning similar functionality in the future.” There’s no specific date yet though.

    Bounce rate

    Those that rely on bounce rate to understand their site’s performance will be disappointed to find out that bounce rate is also not available in GA4. Instead, Google is pushing a new metric known as “Engagement Rate”. With this metric, Google now uses their own formula to establish if a visitor is engaged with a site.

    Lack of integration

    Currently, GA4 isn’t ready to integrate with many core digital marketing tools and doesn’t accept non-Google data imports. This makes it difficult for users to analyse ROI and ROAS for campaigns measured in other tools. 

    Content Grouping

    Yet another key feature that Google has done away with is Content Grouping. However, as with some of the other missing features in GA4, there is a workaround, but it’s not simple for casual users to implement. In order to keep using Content Grouping, you’ll need to create event-scoped custom dimensions.

    Annotations 

    A key feature of Universal Analytics is the ability to add custom Annotations in views. Annotations are useful for marking dates that site changes were made for analysis in the future. However, Google has removed the Annotations feature and offered no alternative or workaround.

    Historical data imports are not available

    The new approach to data modelling in GA4 adds new functionality that UA can’t match. However, it also means that you can’t import historical UA data into GA4. 

    Google’s suggestion for this one ? Keep running UA with GA4 and duplicate events for your GA4 property. Now you will have two different implementations running alongside each other and doing slightly different things. Which doesn’t sound like a particularly streamlined solution, and adds another level of complexity.

    Should you switch to Google Analytics 4 ?

    So the burning question is, should you switch from Universal Analytics to Google Analytics 4 ? It really depends on whether you have the available resources and if you believe this tool is still right for your organisation. At the time of writing, GA4 is not ready for day-to-day use in most organisations.

    If you’re a casual user or someone looking for quick, clear insights then you will likely struggle with the switch to GA4. It appears that the new Google Analytics 4 has been designed for enterprise-scale businesses with large internal teams of analysts.

    Google Analytics 4 UX changes
    Micah Fisher-Kirshner via Twitter

    Unfortunately, for most casual users, business owners and do-it-yourself marketers there are complex workarounds and time-consuming implementations to handle. Ultimately, it’s up to you to decide if the effort to migrate and relearn GA is worth it.

    Right now is the best time to draw the line and make a decision to either switch to GA4 or look for a better alternative to Google Analytics.

    Google Analytics alternative

    Matomo is one of the best Google Analytics alternatives offering an easy to use design with enhanced insights on our Cloud, On-Premise and on Matomo for WordPress solutions. 

    Google Analytics 4 Switch to Matomo
    Mark Samber via Twitter

    Matomo is an open-source analytics solution that provides a comprehensive, user-friendly and compliance-focused alternative to both Google Analytics 4 and Universal Analytics.

    The key benefits of using Matomo include :

    Plus, unlike GA4, Matomo will accept your historical data from UA so you don’t have to start all over again. Check out our 7 step guide to migrating from Google Analytics to find out how.

    Getting started with Matomo is easy. Check out our live demo and start your free 21-day trial. No credit card required.

    In addition to the limitations and complexities of GA4, there are many other significant drawbacks to using Google Analytics.

    Google’s data ethics are a growing concern of many and it is often discussed in the mainstream media. In addition, GA is not GDPR compliant by default and has resulted in 200k+ data protection cases against websites using GA.

    What’s more, the data that Google Analytics actually provides its end-users is extrapolated from samples. GA’s data sampling model means that once you’ve collected a certain amount of data Google Analytics will make educated guesses rather than use up its server space collecting your actual data. 

    The reasons to switch from Google Analytics are rising each day. 

    Wrap up

    The now required update to GA4 will add new layers of complexity, which will leave many casual web analytics users and marketers wondering if there’s a better way. Luckily there is. Get clear insights quickly and easily with Matomo – start your 21-day free trial now.