Recherche avancée

Médias (3)

Mot : - Tags -/image

Autres articles (63)

Sur d’autres sites (6905)

  • How to visualize matplotlib animation in Jupyter notebook

    23 avril 2020, par anonymous13

    I am trying to create a racing bar chart similar to the one in the link (https://towardsdatascience.com/bar-chart-race-in-python-with-matplotlib-8e687a5c8a41). 
However I am unable to see the animation in my Jupyter notebook

    



    code

    



    import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib.animation as animation
from IPython.display import HTML

df = pd.read_csv('https://gist.githubusercontent.com/johnburnmurdoch/4199dbe55095c3e13de8d5b2e5e5307a/raw/fa018b25c24b7b5f47fd0568937ff6c04e384786/city_populations', 
                 usecols=['name', 'group', 'year', 'value'])

current_year = 2018
dff = (df[df['year'].eq(current_year)]
       .sort_values(by='value', ascending=True)
       .head(10))

colors = dict(zip(
    ['India', 'Europe', 'Asia', 'Latin America',
     'Middle East', 'North America', 'Africa'],
    ['#adb0ff', '#ffb3ff', '#90d595', '#e48381',
     '#aafbff', '#f7bb5f', '#eafb50']
))
group_lk = df.set_index('name')['group'].to_dict()


fig, ax = plt.subplots(figsize=(15, 8))
def draw_barchart(year):
    dff = df[df['year'].eq(year)].sort_values(by='value', ascending=True).tail(10)
    ax.clear()
    ax.barh(dff['name'], dff['value'], color=[colors[group_lk[x]] for x in dff['name']])
    dx = dff['value'].max() / 200
    for i, (value, name) in enumerate(zip(dff['value'], dff['name'])):
        ax.text(value-dx, i,     name,           size=14, weight=600, ha='right', va='bottom')
        ax.text(value-dx, i-.25, group_lk[name], size=10, color='#444444', ha='right', va='baseline')
        ax.text(value+dx, i,     f'{value:,.0f}',  size=14, ha='left',  va='center')
    # ... polished styles
    ax.text(1, 0.4, year, transform=ax.transAxes, color='#777777', size=46, ha='right', weight=800)
    ax.text(0, 1.06, 'Population (thousands)', transform=ax.transAxes, size=12, color='#777777')
    ax.xaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,.0f}'))
    ax.xaxis.set_ticks_position('top')
    ax.tick_params(axis='x', colors='#777777', labelsize=12)
    ax.set_yticks([])
    ax.margins(0, 0.01)
    ax.grid(which='major', axis='x', linestyle='-')
    ax.set_axisbelow(True)
    ax.text(0, 1.12, 'The most populous cities in the world from 1500 to 2018',
            transform=ax.transAxes, size=24, weight=600, ha='left')
    ax.text(1, 0, 'by @pratapvardhan; credit @jburnmurdoch', transform=ax.transAxes, ha='right',
            color='#777777', bbox=dict(facecolor='white', alpha=0.8, edgecolor='white'))
    plt.box(False)

draw_barchart(2018)

import matplotlib.animation as animation
from IPython.display import HTML
fig, ax = plt.subplots(figsize=(15, 8))
animator = animation.FuncAnimation(fig, draw_barchart, frames=range(1968, 2019))
HTML(animator.to_jshtml()) 



    



    Below is what I tried using and the errors

    



    HTML(animator.to_jshtml())  <-- Static output with buttons unable to visualize animation
plt.rcParams["animation.html"] = "jshtml"  <- no error and output
HTML(animator.to_html5_video())  <---Requested MovieWriter (ffmpeg) not available 



    



    Note I have FFmpeg installed in my system.
Can you help me with the issue

    


  • ffmpeg set watermark using java

    20 mai 2020, par SynixQueen

    I want to add a watermark( like .png) to a video.
This is the way for the command line :

    



    


    ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=1500:1000" output.mp4

    


    



    found >here<

    &#xA;&#xA;

    my Implementation so fairs like that :

    &#xA;&#xA;

    FFmpegResult result = FFmpeg.atPath(Setup.getBin())&#xA;            .addInput(UrlInput.fromPath(inFile.toPath()))&#xA;            .addInput(UrlInput.fromPath(picture.toPath())&#xA;                    .setDuration(10, TimeUnit.SECONDS))         // set duration time&#xA;            .setComplexFilter(FilterGraph.of(&#xA;                    Filter.withName("overlay")&#xA;                    .addArgument("20","20")&#xA;                    .addOutputLink("lowerright")&#xA;            ))&#xA;            .addOutput(UrlOutput.toPath(output.toPath()))&#xA;            .execute();&#xA;

    &#xA;&#xA;

    at the point .setComplexFilter I am unsure I cannot find any sources to get this right atm &#xA;like here >FFmegDokumentation<

    &#xA;&#xA;

    any ideas ?

    &#xA;

  • VLC - standard output 'dst=-' stopped working

    2 juin 2020, par gdogg371

    Using VLC 3 I had the following command working perfectly a few months back :

    &#xA;&#xA;

    "G:\VLC\vlc" --ffmpeg-hw --avcodec-hw=any dshow:// :dshow-vdev="Video (00 Pro Capture HDMI 4K&#x2B;)" :dshow-adev="Audio (2- 00 Pro Capture HDMI 4K&#x2B;)" :dshow-threads=8 :dshow-aspect-ratio=16\:9 :dshow-size="3840x2160" :dshow-pixel_format=yuv444p16le :dshow-tune=film :dshow-preset=lossless :dshow-profile=main10 show-vcodec=hevc_nvenc :dshow-fps=50 :dshow-crf=0 :dshow-acodec=mp4a :dshow-stereo-mode=5 :dshow-force-surround-sound=0 :dshow-ab=128 :dshow-samplerate=44100 :no-dshow-config :live-caching=300 --sout "#transcode{venc=ffmpeg,vcodec=mp2v,threads=8,aspect=16:9,width=3840,height=2160,fps=50,acodec=a52,ab=1500,channels=6,samplerate=48000,soverlay}:standard{access=file,dst=-,mux=ts}"&#xA;

    &#xA;&#xA;

    ...however dst=- suddenly seems to be causing a problem. I get the following error :

    &#xA;&#xA;

    -- logger module started --&#xA;main: Running vlc with the default interface. Use &#x27;cvlc&#x27; to use vlc without interface.&#xA;file error: write error: Bad file descriptor&#xA;stream_out_standard error: no suitable sout access module for `file/ts://-&#x27;&#xA;main error: stream chain failed for `transcode{venc=ffmpeg,vcodec=mp2v,threads=8,aspect=16:9,width=3840,height=2160,fps=50,acodec=a52,ab=1500,channels=6,samplerate=48000,soverlay}:standard{access=file,dst=-,mux=ts}&#x27;&#xA;main error: cannot start stream output instance, aborting&#xA;file error: write error: Bad file descriptor&#xA;stream_out_standard error: no suitable sout access module for `file/ts://-&#x27;&#xA;main error: stream chain failed for `transcode{venc=ffmpeg,vcodec=mp2v,threads=8,aspect=16:9,width=3840,height=2160,fps=50,acodec=a52,ab=1500,channels=6,samplerate=48000,soverlay}:standard{access=file,dst=-,mux=ts}&#x27;&#xA;main error: cannot start stream output instance, aborting&#xA;-- logger module stopped --&#xA;

    &#xA;&#xA;

    Previous behaviour observed was that VLC would open and start streaming. The purpose of this exercise is to pipe the VLC output into a PVR called NPVR.

    &#xA;&#xA;

    I have tried uninstalling VLC and downloading a fresh install, but I still have the same issue. Any ideas ?

    &#xA;