Planet VideoLAN

Welcome on Planet VideoLAN. This page gathers the blogs and feeds of VideoLAN's developers and contributors. As such, it doesn't necessarly represent the opinion of all the developers, the VideoLAN project, ...

VLC for Android

June 29, 2016

Announcing VLC for UWP 2.0 beta

Jean-Baptiste Kempf

VLC for Windows 10 beta

If you follow this blog, after a long development period (and a lot of issues), VideoLAN is finally releasing the beta of VLC for Windows 10, numbered 2.0.0.

This beta is the first version targeting Windows 10 and running on the Universal Windows Platform, aka UWP.

Features

The Windows 10 application has all the features available on iOS and Android and a few more.

Like the classic VLC, it supports a very large number of formats, but it also has a medialibrary triaging audio and video media, a full player with subtitles, audio/video synchronisation, an audio mini-player and a network shares browser! We also support Cortana, Live Tiles, Pining and Continuum!

The only important missing feature is DVD/Bluray playback and TV tuners that are not yet possible through the UWP APIs.

And of course, it's completely open source, available under the GPLv2.0 license!

You should try it now!

Video Library

We have a medialibrary, with video management:

VideoList.small.png

and a video player with subtitles, subtitles download, chapters, audio/video sync:

VideoPlayback.small.png

We even support a PiP mode to browse your library while playing a video:

PiPView.small.png

Audio Library

We have, of course, audio management, sorted by albums,

AlbumList.small.png

artists,

ArtistsView.small.png

and you can get detailed information about artists.

Artist Biography

Dark Mode

If you live in a cave, you might prefer our Dark Theme:

Black.png

The accent color is, of course, modifiable and it will change the VLC cone color too!

Network

We support DLNA/UPnP, Windows Shares, FTP(S), SFTP, NFS protocols to discover and browse your local servers or NAS.

NetworkBrowsing.small.png

Windows 10

We support some Windows 10 specific features, like Cortana (supported in English and French), Live Tiles, Artists and Album pining to the start menu, Drag & Drop, and Continuum, if you have a Lumia 950 or Lumia 950XL

Under the hood, we use some technologies exclusive to Windows 10, like some DirectX 11.1 features for video and low-latency audio. This should give you enhanced battery life and allow smooth 4K playback.

Platforms supported

This release works now on:

  • Windows 10 desktop and tablets,
  • Windows 10 mobile,

but also, when a few remaining issues are fixed:

  • Xbox one,
  • Surface Hub,
  • Hololens.

And, in a few weeks, we will update the application to also support:

  • Windows 8.1,
  • Windows RT 8.1,
  • Windows Phone 8.1.

Important remarks

NotaBene 0: This application is NOT replacing the desktop application.

NotaBene 1: This application is a new entry on the store compared to the 2 WinRT applications, because Microsoft could not offer a simple upgrade path.

NotaBene 2: Please report bugs!

NotaBene 3: the Xbox one version should be out this summer, when the store is open to 3rd party UWP applications; the Windows 8.1/Windows Phone 8.1 version should come during the next month, if all goes as expected.

Here is a photo of the application running on the Xbox 1:

XBox.jpg

And a gif on the Hololens:

Windows10Holo.gif

You should try it now!

June 29, 2016 08:28 AM

June 22, 2016

Logging for ser2net

Rémi Duraffort

Today, I was debugging an strange issue in LAVA while trying to boot a board.

I was under the impression that the board was not receiving all the u-boot commands that LAVA was sending.

The serial connection is accessible on the network by ser2net.

I discovered that ser2net can log inputs, outputs or both to a file:

TRACEFILE:trace1:/var/log/ser2net.2000.log
2000:telnet:0:/dev/ttyUSB0:9600 tr=trace1

ser2net will print both inputs and outputs characters to /var/log/ser2net.2000.log.

Going back to my issue, the logfile was:

sseetteennvv  aauuttoollooaadd  nnoo
sseettenv initrd_high '0xffffffff'

When the characters are doubled, it means that ser2net has sent and received that character. That's what I was expected as the board is supposed to echo all characters.

However, the characters are suddenly no longer doubled: the board is not echoing. This does explain why the board was not booting.

The question remains: why is the serial line breaking after a random number of characters.

June 22, 2016 02:12 PM

June 21, 2016

Announcing VLC for Android 2.0

Jean-Baptiste Kempf

VLC for Android 2.0

After a long development period, VideoLAN is finally releasing VLC for Android 2.0.
Our last major release was 1.7.0, more than 6 months ago!

VLC for Android 2.0 is a major update to VLC for Android, that adds numerous features, notably:
support for new releases of Android, network shares browsing and playback, video playlists, subtitles downloader, pop-up video view and support for multiwindows, an optional history panel, favorite network shares and URLs, and a merge between the Android TV and Android packages.

We also offer faster decoding, using our new asynchronous hardware decoder and we've updated most of our codecs and formats support.

Video Player

Download it now!

Features

So here is an overview of the new features.

Permissions and Android N

The first good news is that we have decreased the number of dangerous permissions that VLC was using. The only permission that is now considered as dangerous is the access to media files, which is expected for a media player.

On top of that, we support the Android N runtime permissions:

Runtime Permissions

And we still support Android 2.2!

Network Browsing

One of the most requested features, since the creation of the application, was the playback of network shares and local servers in VLC. It's mostly done :)

We support DLNA/UPnP, Windows Shares, FTP(S), SFTP, NFS protocols to discover and browse your local servers or your NAS. And we also detect associated subtitles over the network!

Network Browsing

Subtitles Download

If you want to download subtitles directly from OpenSubtitles, without going to the website, it's now directly integrated in the application:

Download subtitles

Video Playlists

As we've done for audio, we support basic video playlists.

Video Playlists

Pop-up

Another often requested feature, was the popup-video view, mostly for tablets.
It's now implemented and we do support Samsung MultiWindow and LG Dual Window extensions to allow 2 applications on the same screen.

Popup Video Window

History

The history feature that was present in the 0.9.x days is also back, but can be disabled.

You can see now all the features in our menu!

Sidebar Menu

Advanced Options

We've improved the options of the video player and we simplified the landscape/portrait modes

Video Advanced options

TV

The Android TV interface has been improved and ​was merged to​ the same package as the normal Android one."

Therefore, if your device form-factor is more suited to the TV look or you just prefer it, you can select it in the preferences.

Here is the audio player on the TV:

Audio Player for Android TV

RTL and CTL

Finally, we've done a lot of work to support Right-To-Left and Complex Text Layout subtitles. As you can see here with Malayalam:

Android CTL

We also improved the interface to support RTL layouts.

Thanks

Thanks a lot for the support, hoping that you will love this release. :)

Download it now!

Video List

June 21, 2016 03:08 PM

June 20, 2016

This week in VideoLAN - 48

Jean-Baptiste Kempf

48th VideoLAN report

Another week passes by and here is a new weekly report about the VLC and VideoLAN communities!

Features

VLC

Like our previous week, most of the work was focused on stabilizing features and bug fixing. Therefore, the changelog will be quite short too. :D

A new type of module was introduced, named demux filter; they are used to filter or intercept demuxer controls commands and demuxing.
The first use case of this type of module is the ChromeCast demux filter, to show the correct playback time when using the ChromeCast, that we merged this week too.

Some work was done to support the next version of macOS: Sierra. This notably concerns the input capture plugin.
Also, on MacOS X, the interface for renderers was merged.

The 2 SPDIF modules, ac3 and dts have been merged into a single one.

In the core, we've seen fixes for UTF-8 support, media discoverers API, libVLC parsing calls memleaks, tests, buildsystem and Windows threads.

Android

On Android, we've done the same kind of bugfixing as last week, and we have released 2.0.0 RC4 and pushed it on the store.

Not many issues are remaining for the release, now.

WinRT/UWP

On WinRT, we are also in the bugfixing phase, with a lot of commits to make sure the application does not crash too much.

Indeed, we're closing to an open beta release, but the number of crashes was still too high, especially when using the application for a long time.

We also fixed the background audio support on Windows 10 Mobile phones; and reworked the thumbnailer.

The application should be opened in beta to everyone soon.

iOS

The iOS application got a few fixes, notably for remote playlists and XDCAM support and we're pushing an update named 2.7.8 this week.

That's it for this week, stay tuned!

June 20, 2016 08:19 AM

June 13, 2016

This week in VideoLAN - 47

Jean-Baptiste Kempf

47th VideoLAN report

A new week, a new weekly report about the VLC and VideoLAN communities!

Features

VLC

After an intense previous week, most of the work was focused on stabilizing features and bug fixing. Therefore, the changelog will be quite short. :D

In the core, we pushed multiple fixes for preparsing and input slaves and we added tests for those features. We also fixed issues in the media discoverer code.

On the modules side, we notably had fixes in the bluray, the oss, the adaptive streaming, the OS X video output and the UPnP modules.

Finally, we added an OpenGL provider for Windows, in order to add back the support for OpenGL visualisations, like projectM.

Android

Same story on Android, we focused on fixing issues, to prepare the release 2.0.

We pushed RC2 and RC3 on the store to fix crashes reported by the first set of devices where the application was pushed.

We redesigned a bit the speed setting, as requested in our Google+ group.

WinRT

On WinRT, the focus was also on bug fixing and preparing a release. The more important bugs were on Cortana integration and metadata management.

However, we also activated the downloading of subtitles from Internet, notably the OpenSubtitles website.

We also improved the browsing of local network servers, similar to what we did to the Android port.

That's it for this week, stay tuned!

June 13, 2016 03:07 PM

June 08, 2016

This week in VideoLAN - 46

Jean-Baptiste Kempf

46th VideoLAN report

A new week, a new weekly report about the VLC and VideoLAN communities!

Vienna Meeting

This week-end was the Q2 meeting of the VideoLAN asso, hosted in Vienna, by PSPDFKit.

VideoLAN in Vienna

We gathered to fix pending issues for VLC 3.0, and we worked on the mobile apps and the VideoLAN server infrastructure. It was a great week-end!

Features

VLC

During the week-end, we released VLC 2.2.4, to fix 2 security issues, one in VLC, one in a 3rd party library! It is already released and pushed to our users.

Core and libVLC

The input core was modified to support network slaves, aka external subtitles or audio tracks, over the network. In the past, it was only working for local subtitles.
The libVLC API added for this is called libvlc_media_player_add_slave.

The core threading code was improved for recent versions of Windows: it can use futeces and generic semaphore, starting from Windows 8.

We also added the libvlc_media_player_(get|set)_role calls for libVLC, to set the media role (notification, video, audio) that are reflected to the audio output mixer. This is notably used for the PulseAudio output.

Finally, the preparser was reworked to allow interruption and have a default timeout. Applications can also now cancel their preparsing requests with libvlc_MetadataCancel.

Modules

The Qt interface received the first renderers selection dialog. You should be able to detect your ChromeCast from this interface, and stream to it. :)

The UPnP module was improved to support more type of servers, more metadata per item and the code was heavily cleaned. (The library we use is still very bad though).

The OS X interface got new HUD panels and widgets for the dark mode.

Finally, we added the first AppStream Metadata for Linux distributions, a few Qt minor changes, support for GoPro highlights chapters in MP4 and some OS X interface fixes.

Android

Nothing very exciting on Android, just the beta 1.9.13, 2.0.0-rc1 and 2.0.0-rc2 releases, pushed to the store.

For 1.9.13, we mostly focused on activating subtitles over the network, and improving the support for subtitles.

2.0.0-rc1 was mostly focused on fixing the UPnP support and 2.0.0-rc2 was minor fixes for bugs reported by several beta testers. :)

WinRT

On WinRT, we reimplemented the playlists management, and the support for playlists in the PlaybackService.

The Search page, that was hidden, is now visible again, and we support favorites for streams and servers, like the Android version.

The notifications and toasts were reworked to be less intrusive, and Cortana support was improved.

Finally, the new equalizer got a facelift.

And of course, numerous bugs were fixed, so we can have a proper release soon!

That's already quite a bit for last week, see you next!

June 08, 2016 09:42 PM

May 31, 2016

Hong Kong Open Source Conference 2016

Rémi Denis-Courmont

VLC developers will be tending a booth in cooperation with the VideoLAN foundation at the upcoming Hong Kong Open Source Conference on 24-25 June 2016. Follow the link to sign up. See you there.

May 31, 2016 02:30 PM

Condition variable with futex

Reimplementing condition variable with futex on Linux and Windows.

May 31, 2016 02:30 PM

May 29, 2016

This week in VideoLAN - 45

Jean-Baptiste Kempf

45th VideoLAN report

After a couple of very busy weeks, we're back on a normal schedule. Therefore, here is the weekly report about the VLC and VideoLAN communities!

Features

VLC

We started the week by adding the support for MPEG-2 and VC-1 hardware decoders on Android in the mediacodec module.
We also fixed some MPEG-4 regressions on this module.

Hugo fixed a few issues on the UPnP module, and mostly added the support for Windows Media Sharing servers, in this module.
We also added support for subtitles over UPnP, using the work done in the core the previous week.

The Matroska demuxer got a few fixes for some regressions, but mostly implemented the fast-seek option, that is imprecise, but faster than the normal seek. This is useful when computing thumbnails, for example.

Some changes on the libVLC parsing events were done, to simplify the handling in client applications. If you were using the not-stable-yet libVLC 3.0, beware!

Near the end of the week, the core got some important changes on threads manipulation, with the introduction of vlc_thread_self() and vlc_thread_id(). The usage of futeces was introduced in the core: see Rémi's post about it.

The MMDevice audio output on Windows now supports device change events.

The Windows 64bits build will now have high-entropy ASLR activated, which should reduce the possibility of exploitation of security issues.

On Windows, we also fixed the raising issue of the Qt tooltip that we had with Qt5, the 2.2.3 DirectDraw regression and a small D3D improvement when handling large pictures.

Finally, a few H264 annex-B parsing issues were fixed and the video headers were modified to support, in the future, VR videos (nothing working yet).

Android

On the Android side, we're going on fixing issues for the 2.0.0 release.

This week, we:

  • improved the subtitles downloader, to activate it from within the player, and for any video,
  • improved the interface for scanning, the browsing and the video player animations,
  • improved the audio player on Android TV,
  • improved the speed of MKV thumbnails,
  • fixed a few remaining small issues.

All this was pushed in the update 1.9.12 on the play store. Hopefully, the 2.0.0 release will come this week. :)

WinRT / UWP

As last week, the WinRT port has been very busy again, with almost 100 commits.

As for Android, we're focusing on preparing the release, and fixing the biggest bugs people have reported.

On the libVLC backend, we fixed a few performance issues, we added more codecs support, and we improved the UPnP and SMB browsing.

On the interface side, we improved the thumbnailing and parsing process, we fixed numerous bugs that happened when resizing (and Windows 10 Mobile look) and we fixed a few crashes.

We also improved the settings and activated the access to the equalizer.

Hopefully, we'll be able to open the beta to the public soon.

That's all for this week! See you next!

May 29, 2016 09:54 PM

May 23, 2016

These weeks in VideoLAN - 44

Jean-Baptiste Kempf

44th VideoLAN weekly report

Once again, unfortunately, the report skipped a week :(

But this report, the 44th report, is quite important for 2 reasons:

  • it's been over one year I've started those reports, since the first one was published on May 10th, last year;
  • and this post is the 300th blogpost on this very blog!

This also mean I skipped 8 weekly reports, and did dual-reports for those weeks, which is not too bad, compared to what I hoped to achieve...

So, without waiting any further, here is the report about what happened in the last 2 weeks in the VideoLAN and VLC development community! It was a couple of busy weeks!

Features and changes

VLC

The week started by some work on the supported MIME-types for the .desktop file for VLC on Linux, by a Debian developer, which cleaned and merged all our different mimetypes support correctly.

Then, a very large patchset for seeking in the MKV (matroska) files was merged. It rewrites most of the seeking support and builds an index when playing the file. This new code fixes quite a few bugs we had on the matroska support.

We added support for subtitles over the network, with a set of functions named libvlc_media_slaves_add, libvlc_media_slaves_get (and related).
At the same time, we now auto-detect subtitles in networking shares; this is currently tested on SMB and UPnP.

We've had improvements on the Qt main window resizing, and on the playlist model.

The work on DVB scan was continued, notably to support device limits.

Another batch for ChromeCast was merged, mostly focusing on seeking and stopping the stream. We're still missing a few bits, though :)

And finally, we improved again our adaptive streaming support, our Blurays menus support, added support for vorbis and flac inside MP4, improved WMV metadata and prepared support for streaming output on Android.

VLC core for WinRT

The VLC engine has seen many changes for WinRT, in the last few weeks, mostly to merge the existing patches we had pending.

The 3rd party libraries (contribs) were updated and patched to correctly compile for the WinRT/UWP version.
At the same time, we merged numerous patches for the core, the modules and the buildsystem.

We improved quite a bit the Direct3D11 output, both for desktop and the WinRT version. We notably fixed the green line issue and added support for more hardware decoders on Windows Phone/RT.
We also accelerated the chroma conversions when using hardware decoding.

Finally, the WinRT audio module now supports volume changes. This was forbidden in Windows 8 apps, but is allowed in Windows 10.

Android

As we're approaching the 2.0.0 release, the Android port was quite calm.

We pushed 2 beta releases on the store: 1.9.10 and 1.9.11 to fix minor issues, mostly to fix subtitles regression and improve the thumbnails look.

We then added support for the network subtitles and subtitles downloading for network media.

This will be in the next release, that should come soon.

iOS

We released VLC 2.7.7 for iOS and 1.0.6 for AppleTV, to fix minor issues, update the software decoders, and activate AC3 and E-AC3 decoding on 64bit device and the Apple TV.

Since then, there were fixes for onedrive support, for subtitles over FTP and for SPDIF pass-through support.

WinRT / UWP

The WinRT port was extremely busy, these past two weeks.

Indeed, we are preparing a beta version named 1.9.0, that would prepare for the first true UWP version, that will be named 2.0.0.

We've added most of the features that you usually see on the Android and iOS versions of VLC, notably UPnP and network shares browsing, support for HTTPS and adaptive streaming, better hardware decoding, dialogs support, as many codecs as the desktop version, and so on.
Moreover, the engine use the runtime 12.0_app instead of the 11.0 one we used on the WinRT version.

On the UI side, we now support correctly Windows 10 integration, with Cortana, drag and drop, tablet mode and a lot of fixes so that the application looks responsive enough on all the devices, from mobile to the Xbox 1. We polished this UI and fixed a few important regressions, notably on the playback and the thumbnailer.

The application is currently in private beta mode, so that the biggest issues are fixed before opening it up. :)

libbluray

We released a new version of libbluray, numbered 0.9.3

This release:

  • adds a bd_open_files() function, deprecating old global file system hooks;
  • adds flags for on-disc menu support to DISC_INFO,
  • improves Java building and Linux integration
  • enable UDF/ISO support by default,
  • improves BDJ_EVENT_CHAPTER, main title detection,
  • improve BD-J compability, and fixes numerous bugs on BD-J,
  • improves libaacs and libmmbd detection.
  • fixes a large number of bugs too long to describe here :)

That's all for those weeks! See you soon!

May 23, 2016 05:49 PM

May 13, 2016

Static analysis for Python

Rémi Duraffort

I've always been a big fan of static analysis. While I was working with C and C++, I was scanning my code with:

For a longer list of static analyzers for each language, look at wikipedia

As I'm now mostly programming in Python (I'm working on LAVA), I had a closer look at the available static analyzers for this language.

I haven't found any static analyzer for Python as powerful as the one available for C or /C++. However the ones listed in this article must be used on your Python code. That's the bare minimum.

PEP

The first tool to run on any Python source code would be pep8. You can also give a try to pep256.

pep8 is a simple tool that only check for coding style. Python does advice the use of a standardize code style: PEP8. It's recommended to use the same coding style in order to keep a common style among the Python community.

However, you can obviously configure pep8 to match your coding style.

def main():
  print("Hello" + " World")

if __name__ == "__main__":
    main()

If you run pep8 on this file you will get:

pep8 code.py
code.py:2:3: E111 indentation is not a multiple of four

Pylint

Pylint is more of a static analyzer than pep8 as it actually check for some Python common errors. For instance, on this example:

def append(data=[]):
    data.append(1)
    return data

print(append())
[1]
print(append())
[1, 1]
print(append())
[1, 1, 1]

This is usually not what your are expecting. Pylint will warn you:

pylint code.py
No config file found, using default configuration
************* Module code
C:  1, 0: Missing module docstring (missing-docstring)
W:  1, 0: Dangerous default value [] as argument (dangerous-default-value)
C:  1, 0: Missing function docstring (missing-docstring)
[...]
Global evaluation
-----------------
Your code has been rated at 0.00/10

As you can see, Pylint is rating the source code (and show the evolution of this rate).

Vulture

Vulture is specialized in dead code elimination. Due to the dynamic nature of Python, such task is not as easy as it is with C. So don't expect any tool to find all dead code.

def append(data=[]):
    data.append(1)
    return data

def unused():
    for i in range(0, 10):
        append()

def main():
    append()

if __name__ == '__main__':
    main()

Running vulture will give:

vulture code.py
code.py:5: Unused function 'unused'
code.py:6: Unused variable 'i'

Pychecker

Another useful tool: Pychecker does provide some interesting information. However, it only works with Python2.

code.py:2: Modifying parameter (data) with a default value may have unexpected consequences
code.py:6: Local variable (i) not used

Prospector

I discovered prospector some weeks ago and that's now the only one I'm using. In fact, it uses all the other static analyzers (dodgy, pep257, pep8, pyflakes, pylint, vulture, pyroma, frosted) and provides a nice report.

Messages
========

code.py
  Line: 1
    pylint: dangerous-default-value / Dangerous default value [] as argument
  Line: 6
    pylint: unused-variable / Unused variable 'i' (col 8)



Check Information
=================
         Started: 2016-05-13 17:29:31.466860
        Finished: 2016-05-13 17:29:31.553182
      Time Taken: 0.09 seconds
       Formatter: grouped
        Profiles: default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings
      Strictness: None
  Libraries Used: 
       Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
  Messages Found: 2

My advice would be to run prospector regularly to track common mistakes. It does sometime found real bugs.

May 13, 2016 04:12 PM

May 09, 2016

This week in VideoLAN - 43

Jean-Baptiste Kempf

43rd VideoLAN weekly reports

After my 42nd report last week, and some nice encouragements, here is another weekly report about VideoLAN and VLC development.

I was far from a computer last week, so here are 2 weeks in one.

Features

VLC

Renderers

The previous week, we started to introduce the concept of renderers in VLC.
Those are distant devices displaying audio and/or video, instead of playing it locally. The usual device people know are ChromeCasts, UPnP/DLNA renderers, AirPlay, WiDi or DIAL devices.

A new type of VLC module was introduced: renderer discovery. Like Service Discovery, they can find those renderers devices on the network, using one of the discovery protocols.

The renderer discovery capability was implemented in our mDNS module.

The Chromecast code was heavily reworked at the same time, and after 4/5 redesigns, we're almost happy with the code :)

The interface is still missing, but it should come soon!

Other features

The S/PDIF passthrough was implemented in the WASAPI module for Windows. This is important, as this module will be the default, starting in 3.0, for most Windows users.

The work on DVB scanning is still going on. We had numerous patches this week on this topic.

Our mDNS module now supports IPv6 and our MKV demuxer started to get a heavy lifting.

We also had fixes for the TS demuxer and muxer, the libVLC headers, the VideoToolbox decoder, Hurd compilation and improvements on the Direct3D11 video output!

Android

The Android port got 2 more beta releases for 2.0.0: 1.9.9 and 1.9.10.

We added numerous fixes, notably in the popup video view, the binder, keyboard and pad management, title display and the video view.

And of course, improvements for the subtitles download feature.

Hopefully, we will push the release soon.

WinRT

If you follow Thomas on Twitter, you will know that the WinRT port has been quite busy lately.

Cortana is now integrated in the application, so you can ask VLC to launch an album or the last video viewed.

Drag and Drop should now work almost everywhere, and you can drop just a subtitle on a playing video, if you want.

The Stream and the File dialogs have been relifted; the Settings dialog in the same way.

The mini-player and the command bar controller have been merged, together, if you have a Windows Preview build.

On the backend, some work was done on the thumbnailer, and the music and video libraries have been merged into one single library.

Some video information is now pulled from TheMovieDB.

Finally, some work was done to adapt the interface to Windows 10 Mobile.

Soon a release? :)

iOS/tvOS

On AppleTV, search was implemented for local servers browsing.

And we also got support for repeat on the AppleTV application.

We should get updates on those 2 applications soon, on the App Store.

That's all for those 2 weeks, see you soon!

May 09, 2016 09:59 PM

May 03, 2016

type() vs isinstance()

Rémi Duraffort

When running pylint on your Python source code, you might encounter this message:

Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)

This message will be raised for this kind of code:

d = dict()
if type(d) == dict:
    print("d is a dict")

The code is valid but pylint does prefer the use of isinstance(). Why is it preferable to use one instead of the other?

Duck Typing

The short answer is: this code is unidiomatic. In fact, it does not make use of Duck typing.

In duck typing, an object's suitability is determined by the presence of certain methods and properties (with appropriate meaning), rather than the actual type of the object

In Python, it's preferable to use Duck Typing rather than inspecting the type of an object.

class User(object):
    def __init__(self, firstname):
        self.firstname = firstname

    @property
    def name(self):
        return self.firstname

class Animal(object):
    pass

class Fox(Animal):
    name = "Fox"

class Bear(Animal):
    name = "Bear"

# Use the .name attribute (or property) regardless of the type
for a in [User("John"), Fox(), Bear()]:
    print(a.name)

Inheritance

The second reason not to use type() is the lack of support for inheritance.

class MyDict(dict):
    """A normal dict, that is always created with an "initial" key"""
    def __init__(self):
        self["initial"] = "some data"

d = MyDict()
type(d) == dict    # False
type(d) == MyDict  # True

d = dict()
type(d) == dict    # True
type(d) == MyDict  # False

The MyDict class has all the properties of a dict, without any new methods. It will behave exactly like a dictionary. But type() will not return the expected result.

Using isinstance() is preferable in this case because it will give the expected result:

d = Mydict()
isinstance(d, MyDict)  # True
isinstance(d, dict)    # True

d = dict()
isinstance(d, MyDict)  # False
isinstance(d, dict)    # True

As a conclusion, try to avoid (as much as possible) the use of type or isinstance and prefer Duck Typing.

More information on StackOverflow

May 03, 2016 03:00 PM

April 24, 2016

This week in VideoLAN - 42

Jean-Baptiste Kempf

42nd week of VideoLAN reports

After a very busy week last week, here is another weekly report about VideoLAN and VLC development.

42

I'm surprised we're already at 42 and I haven't stopped doing it!

Sometimes, I'm not sure it's really useful, since I don't see many comments...

But lately, some people who don't comment on this blog told me, in real life, that I should continue, so here is a new report.

Features

VLC

Once again, we started the week with fixes for the WinRT/UWP build.

We got numerous small fixes for the Qt interface, notably for resizing issues of the main interface and in the preferences.

Marvin improved the Mac OS interface status-bar icon look and behavior.

François continued his work on the DVB scanning, notably splitting in a better way the DVB access from the TS demuxer module, which is a cleaner design.

VLC has also now gained the ability to auto-rotate the JPEG photos using the EXIF data.

Finally, a vlc_close function was introduced to be able to use posix_close instead of close when available.

Android

This week, we published version 1.9.8 of VLC for Android, adding notably subtitles download for local files, and media information on the Android TV version.
In this version, we pushed numerous fixes too, notably for repeat, metadata, resuming files and popup video support.

Then, the bindings for the keyboard and remote was changed too: left/right arrows seek, down arrow shows the controller, up arrow show the advanced options and center play/pause.

We also fixed numerous issues with RTL languages and layouts; and improved the code with more databinding.

iOS

On Tuesday, we pushed VLC 2.7.5 for iOS and VLC 1.0.4 for tvOS. Those release are mostly targeting improvements in SMB shares browsing.

Since then, we've readied VLC 2.7.6/1.0.5, focusing on improving the shares browsing, Dropbox, TouchID and the video filters.

WinRT

On WinRT, the week was quite busy.

We improved the speed and reliability of the libVLC core, notably so that we can use more features of the UWP platform and so we can have a stable 64bit build.

We also improved the interface, based on people's feedback on our screenshots, notably for the settings and the global navigation.

The video player was also re-themed and you can have PiP when browsing the application, if a video is still playing.

That's quite a bit for this week! Thanks a lot and see you next!

April 24, 2016 09:51 PM

April 19, 2016

Migrating from Python2 to Python3

Rémi Duraffort

Porting code from Python 2 to Python 3 is made easier by using 2to3. This application will find patterns that should be changed to keep the same behavior in Python 2 and 3.

However, 2to3 is sometime too conservative, trying to keep the exact same semantic.

For instance, dictionaries functions .items(), .keys() and .values() now (as in Python 3) return a view and not a list.

d = {'foo' : 'bar', 'bla': 'blo'}
keys = d.keys()
type(keys)
<type list>

While in Python 3

d = {'foo' : 'bar', 'bla': 'blo'}
keys = d.keys()
type(keys)
<class dict_keys>

If you run 2to3 on this snippet, you will get:

d = {'foo' : 'bar', 'bla': 'blo'}
keys = list(d.keys())
type(keys)
<type list>

This change guarantee that the semantic is exactly the same. However this change is often unneeded. In fact, the dict_keys class implement __iter__, __contains__ and __len__.

We can use the dict_keys in a for loop:

d = {1: 'one', 2: 'two', 3: 'three'}
for k in d.keys():
    print(k)
1
2
3

We can also check that a given key exists in the dictionary:

d = {1: 'one', 2: 'two', 3: 'three'}
if 2 in d.keys():
    print("Found")
found

While maintaining the same semantic, transforming the class into a list can waste many CPU cycles.

April 19, 2016 10:00 AM

This week in VideoLAN - 41

Jean-Baptiste Kempf

41st week of VideoLAN reports

Another week, another weekly report about VideoLAN and VLC development.

Features

VLC

We started the week with fixes to build libVLC for WinRT.

Then, after the work from last week, the DVB scanning was improved again, notably to manage timeouts; and the DTV module was fixed accordingly.

The input core was also simplified, removing muteces, reducing the number of functions to create an input, and fixing some preparsing issues (and adding the related tests). One now should just use input_item_AddOptions and the aliases named input_item_New* instead of the input_item_NewWithType or input_item_NewWithTypeExt functions.

libVLC users can now use libvlc_media_get_parsed_status and the new libvlc_MediaParsedStatus event to monitor the item preparsing.

We've had playback fixes for MPEG-SL AAC streams inside TS (#16809), we now support playback of forced subtitles in MP4 (#16803) and support RTP Reception Hint Tracks inside MP4.

We've extended our AVI muxer to support the A-law and μ-law codecs.

Finally, we improved the bluray, SMB, keystore and Qt modules.

Colorimetry

During the week-end, a small team went to Helsinki to work on the colorimetry support for VLC.

As we're moving to UltraHD (4K), the videos are shifting to new, wider, colorspaces. In the past, we just ignored the small differences and took the sane defaults.

It's not possible to do that anymore with the Rec.2020 and the new HDR colorspaces.

Therefore, during the week-end, we laid out the base to support those colorspaces inside the core.

Android

On Android, we started by fixing the navigation with the keyboards and keypads, for the classic android version.

We also added a next and a previous button in the video player, when playing a video playlist.

Then, we added support for subtitles download, from internet subtitle databases.

Finally, we fixed a few bugs, notably on focus and and metadata.

All those changes will be pushed on the store in the version 1.9.8.

iOS

This week, we pushed VLC 2.7.4 for iOS and VLC 1.0.3 for tvOS.

The tvOS release adds notably S/PDIF pass-through and support for finding subtitles over network shares.

The iOS release adds:

  • 3D Touch Quick actions
  • "play all" features for OneDrive and network shares
  • finding subtitles over network shares,
  • stability improvements for SMB shares,
  • numerous fixes notably for video filters, downloads and interface issues.

WinRT

The WinRT code was quite active last week.

A lot of work is not visible, but is done on the libVLC backend, so that the VLC/WinRT code is closer to the Win32 code. We expect that to give us quite a boost in performances.

Another large part of the work on the interface is also not very visible, but is done to improving the medialibrary code, and clean the split between interface and the backend. This should reduce the number of crashes we are seeing.

Finally, last week, we've spent time on the design and look of the application. Here is a screenshot of the current code. AlbumsLight.png

x264

Last week, just before the NAB show, we pushed some new code in the x264 codebase.

The most visible changes are:

  • SSE2 and AVX optimizations for dct, notably for 4:2:2 encoding
  • SSSE3 and AVX2 optimizations for mbtree fixed point conversions
  • improvements pf the b-adapt 1 algorithm, giving better quality without changing the speed,
  • improvements for Windows and Visual Studio compatibility

libbluray

The work on libbluray this week was mostly going on improving the BD-J menus.

This work was visible in the javax.tv namespace, but also in general where many errors were denoted to warnings, and should improve compatibility with more disks.

Finally, there is now a seek event for BD-J.

We'll have a release soon with all these improvements.

That's quite a bit for this week! Thanks a lot and see you next!

April 19, 2016 09:32 AM

April 11, 2016

These weeks in VideoLAN - 40

Jean-Baptiste Kempf

40th report about VideoLAN reports

It's been a few weeks without reports. I'm sorry, I was traveling a bit across the Ocean, and life caught up with me, a bit too much...

And of course, the VideoLAN community has been busy during that time, so a lot happened, and catching up is even harder. So, this report is probably more summarized than usual, please excuse me for that.

Features

VLC

The weeks started by fixing the Windows green lines regressions for 2.2.3 and 3.0.0 that could happen with the Direct3D9 module but also when deinterlacing the content.

The time bar of our Qt module got fixed (some clicks could be on the wrong time, compared to the tooltip), and it got more precise for seeking.

The Jack audio output can now have fixed names for inputs and outputs. This should be easier to reuse, after a VLC restart.

The libVLC has now a libvlc_navigate_popup call to open pop-up menus with BD-J disks.

Quite a bit of fixes and improvements got into the ChromeCast module, notably to clean the code, and to make it closer to the expected behavior.
No, it's not ready yet for primetime, since it's not exposed in the interface.

The Daala module is now independent from the Ogg demuxing library.

Finally, we got a large rework of the DVB scanning code, mostly for Linux, though.

And, as usual, we merged numerous fixes and this week they were mostly on Android Mediacodec, MP4 seeking, TS regressions, MKV ALBUM metadata support, code cleanup and adding more tests to the codebase.

Android

In the last 3 weeks, we published 3 different beta versions: 1.9.5, 1.9.6 and 1.9.7 were published on the Android Store.

Those beta versions are still focusing on stability and feedback from our users.

However, 1.9.7 added support for a popup-video window, so you can float your video above every other application, like this:

Popup Video Window

At the same time, we also added support for Samsung and LG split windows.

WinRT and iOS

The other mobile ports, iOS and WinRT got each a few improvements.

On WinRT, the biggest changes were on the handling of translations, using the new translations framework. The rest were minor fixes for stability.

On iOS, numerous fixes got merged for Cloud drives support and we got 2 releases in the pipe, waiting for reviews:
2.7.4 is the next iOS release, 1.0.3, the next tvOS release.

Those builds should arrive soon in your devices.

libbluray

The libbluray project received a few improvements too.

The number of locks were reduced, the AACS integration was enhanced, and a few fixes on chapters were merged.

However, the biggest changes were in the implementation of some javax.tv. classes, that were missing, notably on the javax.tv.util namespace; but other part of this namespace were improved to support more bluray menus.

That's almost all for those weeks, see you next!

April 11, 2016 10:59 PM