
Recherche avancée
Autres articles (39)
-
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...) -
Publier sur MédiaSpip
13 juin 2013Puis-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 -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)
Sur d’autres sites (8096)
-
Data Privacy Regulations : Essential Knowledge for Global Business
6 mars, par Daniel CroughIf you run a website that collects visitors’ data, you might be violating privacy regulations somewhere in the world. At last count, over 160 countries have privacy laws — and your customers in those countries know about them.
A recent survey found that 53% of people who answered know about privacy rules in their country and want to follow them. This is up from 46% two years ago. Furthermore, customers increasingly want to buy from businesses they can trust with their data.
That’s why businesses must take data privacy seriously. In this article, we’ll first examine data privacy rules, why we need them, and how they are enforced worldwide. Finally, we’ll explore strategies to ensure compliance and tools that can help.
What are data privacy regulations ?
Let’s first consider data privacy. What is it ? The short answer is individuals’ ability to control their personal information. That’s why we need laws and rules to let people decide how their data is collected, used, and shared. Crucially, the laws empower individuals to withdraw permission to use their data anytime.
The UNCTAD reports that only 13 countries had data protection laws or rules before the 2000s. Many existed before businesses could offer online services, so they needed updating. Today, 162 national laws protect data privacy, half of which emerged in the last decade.
Why is this regulation necessary ?
There are many reasons, but the impetus comes from consumers who want their governments to protect their data from exploitation. They understand that participating in the digital economy means sharing personal information like email addresses and telephone numbers, but they want to minimise the risks of doing so.
Data privacy regulation is essential for :
- Protecting personal information from exploitation with transparent rules and guidelines on handling it securely.
- Implementing adequate security measures to prevent data breaches.
- Enforcing accountability for how data is collected, stored and processed.
- Giving consumers control over their data.
- Controlling the flow of data across international borders in a way that fully complies with the regulations.
- Penalising companies that violate privacy laws.
Isn’t it just needless red tape ?
Data breaches in recent years have been one of the biggest instigators of the increase in data privacy regulations. A list of the top ten data breaches illustrates the point.
# Company Location Year # of Records Data Type 1 Yahoo Global 2013 3B user account information 2 Aadhaar India 2018 1.1B citizens’ ID/biometric data 2 Alibaba China 2019 1.1B users’ personal data 4 LinkedIn Global 2021 700M users’ personal data 5 Sina Weibo China 2020 538M users’ personal data 6 Facebook Global 2019 533M users’ personal data 7 Marriott Int’l Global 2018 500M customers’ personal data 8 Yahoo Global 2014 500M user account information 9 Adult Friend Finder Global 2016 412.2M user account information 10 MySpace USA 2013 360M user account information And that’s just the tip of the iceberg. Between November 2005 and November 2015, the US-based Identity Theft Resource Center counted 5,754 data breaches that exposed 856,548,312 records, mainly in that country.
It’s no wonder that citizens worldwide want organisations they share their personal data with to protect that data as if it were their own. More specifically, they want their governments to :
- Protect their consumer rights
- Prevent identity theft and other consumer fraud
- Build trust between consumers and businesses
- Improve cybersecurity measures
- Promote ethical business practices
- Uphold international standards
Organisations using personal data in their operations want to minimise financial and reputational risk. That’s common sense, especially when external attacks cause 68% of data breaches.
The terminology of data privacy
With 162 national laws already in place, the legal space surrounding data privacy grows more complex every day. Michalsons has a list of different privacy laws and regulations in force in significant markets around the world.
Fortunately, there’s plenty of commonality for two reasons : first, all countries want to solve the same problem ; second, those drafting the legislation have adopted much of what other countries have already developed. As a result, the terminology remains almost the same, even when the language changes.
These are the core concepts at play :
Term Definition Access and control Consumers can access, review, edit and delete their data Data protection Organisations must protect data from being stolen or compromised Consumer consent Consumers can grant and withdraw or refuse access to their data Deletion Consumers can request to have their data erased Data breach When the security of data has been compromised Data governance The management of data within an organisation Double opt-in Two-factor authentication to add a layer of confirmation GDPR Governing data privacy in Europe since 2016 Personally identifiable information (PII) Data used to identify, locate, or contact an individual Pseudonymisation Replace personal identifiers with artificial identifiers or pseudonyms Publicly available information Data from official sources, without restrictions on access or use Rectification Consumers can request to have errors in their data corrected Overview of current data privacy legislation
Over three-quarters of the world has formulated and rolled out data privacy legislation — or is currently doing so. Here’s a breakdown of the laws and regulations you can expect to find in most significant markets worldwide.
Europe
Thoughts of protecting data privacy first occurred in Europe when the German government became concerned about automated data processing in 1970. A few years later, Sweden was the first country to enact a law requiring permits for processing personal data, establishing the first data protection authority.
General Data Protection Regulation (GDPR)
Sweden’s efforts triggered a succession of European laws and regulations that culminated in the European Union (EU) GDPR, enacted in 2016 and enforced from 25 May 2018. It’s a detailed and comprehensive privacy law that safeguards the personal data and privacy of EU citizens.
The main objectives of GDPR are :
- Strengthening the privacy rights of individuals by empowering them to control their data.
- Establishing a uniform data framework for data privacy across the EU.
- Improving transparency and accountability by mandating businesses to handle personal data responsibly and fully disclose how they use it.
- Extending the regulation’s reach to organisations external to the EU that collect, store and process the data of EU residents.
- Requiring organisations to conduct Protection Impact Assessments (PIAs) for “high-risk” projects.
ePrivacy Regulation on Privacy and Electronic Communications (PECR)
The second pillar of the EU’s strategy to regulate the personal data of its citizens is the ePrivacy Regulation on Privacy and Electronic Communications (EU PECR). Together with the GDPR, it will comprise data protection law in the union. This regulation applies to :
- Providers of messaging services like WhatsApp, Facebook and Skype
- Website owners
- Owners of apps that have electronic communication components
- Commercial direct marketers
- Political parties sending promotional messages electronically
- Telecommunications companies
- ISPs and WiFi connection providers
The EU PECR was intended to commence with GDPR on 25 May 2018. That didn’t happen, and as of January 2025, it was in the process of being redrafted.
EU Data Act
One class of data isn’t covered by GDPR or PECR : internet product-generated data. The EU Data Act provides the regulatory framework to govern this data, and it applies to manufacturers, suppliers, and users of IoT devices or related services.
The intention is to facilitate data sharing, use, and reuse and to facilitate organisations’ switching to a different cloud service provider. The EU Data Act entered into force on 11 January 2024 and is applicable from September 2025.
GDPR UK
Before Brexit, the EU GDPR was in force in the UK. After Brexit in 2020, the UK opted to retain the regulations as UK GDPR but asserted independence to keep the framework under review. It’s part of a wider package of reform to the data protection environment that includes the Data Protection Act 2018 and the UK PECR.
In the USA
The primary federal law regarding data privacy in the US is the Privacy Act of 1974, which has been in revision for some time. However, rather than wait for the outcome of that process, many business sectors and states have implemented their own measures.
Sector-specific data protection laws
This sectoral approach to data protection relies on a combination of legislation, regulation and self-regulation rather than governmental control. Since the mid-1990s, the country has allowed the private sector to lead on data protection, resulting in ad hoc legislation arising when circumstances require it. Examples include the Video Privacy Protection Act of 1988, the Cable Television Protection and Competition Act of 1992 and the Fair Credit Reporting Act.
California Consumer Privacy Act (CCPA)
California was the first state to act when federal privacy law development stalled. In 2018, it enacted the California Consumer Privacy Act (CCPA) to protect and enforce Californians’ rights regarding the privacy of their personal information. It came into force in 2020.
California Privacy Act (CPRA)
In November of that same year, California voters approved the California Privacy Rights Act (CPRA). Billed as the strongest consumer privacy law ever enacted in the US, CPRA works with CCPA and adds the best elements of laws and regulations in other jurisdictions (Europe, Japan, Israel, New Zealand, Canada, etc.) into California’s personal data protection regime.
Virginia Consumer Data Protection Act (CDPA)
In March 2021, Virginia became the next US state to implement privacy legislation. The Virginia Consumer Data Protection Act (VCDPA), which is also informed by global legislative developments, tries to strike a balance between consumer privacy protections and business interests. It governs how businesses collect, use, and share consumer data.
Colorado Privacy Act (CPA)
Developed around the same time as VCDPA, the Colorado Privacy Act (CPA) was informed by that law and GDPR and CCPA. Signed into law in July 2021, the CPA gives Colorado residents more control over their data and establishes guidelines for businesses on handling the data.
Other states generally
Soon after, additional states followed suit and, similar to Colorado, examined existing legislation to inform the development of their own data privacy laws and regulations. At the time of writing, the states with data privacy laws at various stages of development were Connecticut, Florida, Indiana, Iowa, Montana, New York, Oregon, Tennessee, Texas, and Utah.
By the time you read this article, more states may be doing it, and the efforts of some may have led to laws and regulations coming into force. If you’re already doing business or planning to do business in the US, you should do your own research on the home states of your customers.
Globally
Beyond Europe and the US, other countries are also implementing privacy regulations. Some were well ahead of the trend. For example, Chile’s Law on the Protection of Private Life was put on the books in 1999, while Mauritius enacted its first Data Protection Act in 2004 — a second one came along in 2017 to replace it.
Canada
The regulatory landscape around data privacy in Canada is as complicated as it is in the US. At a federal government level, there are two laws : The Privacy Act for public sector institutions and the Personal Information Protection and Electronic Documents Act (PIPEDA) for the private sector.
PIPEDA is the one to consider here. Like all other data privacy policies, it provides a framework for organisations handling consumers’ personal data in Canada. Although not quite up to GDPR standard, there are moves afoot to close that gap.
The Digital Charter Implementation Act, 2022 (aka Bill C-27) is proposed legislation introduced by federal agencies in June 2022. It’s intended to align Canada’s privacy framework with global standards, such as GDPR, and address emerging digital economy challenges. It may or may not have been finalised when you read this.
At the provincial level, three of Canada’s provinces—Alberta, British Columbia, and Quebec—have introduced laws and regulations of their own. Their rationale was similar to that of Bill C-27, so they may become redundant if and when that bill passes.
Japan
Until recently, Japan’s Act on the Protection of Personal Information (APPI) was considered by many to be the most comprehensive data protection law in Asia. Initially introduced in 2003, it was significantly amended in 2020 to align with global privacy standards, such as GDPR.
APPI sets out unambiguous rules for how businesses and organisations collect, use, and protect personal information. It also sets conditions for transferring the personal information of Japanese residents outside of Japan.
China
The new, at least for now, most comprehensive data privacy law in Asia is China’s Personal Information Protection Law (PIPL). It’s part of the country’s rapidly evolving data governance framework, alongside the Cybersecurity Law and the Data Security Law.
PIPL came into effect in November 2021 and was informed by GDPR and Japan’s APPI, among others. The data protection regime establishes a framework for protecting personal information and imposes significant compliance obligations on businesses operating in China or targeting consumers in that country.
Other countries
Many other nations have already brought in legislation and regulations or are in the process of developing them. As mentioned earlier, there are 162 of them at this point, and they include :
Argentina Costa Rica Paraguay Australia Ecuador Peru Bahrain Hong Kong Saudi Arabia Bermuda Israel Singapore Brazil Mauritius South Africa Chile Mexico UAE Colombia New Zealand Uruguay Observant readers might have noticed that only two countries in Africa are on that list. More than half of the 55 countries on the continent have or are working on data privacy legislation.
It’s a complex landscape
Building a globalised business model has become very complicated, with so much legislation already in play and more coming. What you must do depends on the countries you plan to operate in or target. And that’s before you consider the agreements groups of countries have entered into to ease the flow of personal data between them.
In this regard, the EU-US relationship is instructive. When GDPR came into force in 2016, so did the EU-US Privacy Shield. However, about four years later, the Court of Justice of the European Union (CJEU) invalidated it. The court ruled that the Privacy Shield didn’t adequately protect personal data transferred from the EU to the US.
The ruling was based on US laws that allow excessive government surveillance of personal data transferred to the US. The CJEU found that this conflicted with the basic rights of EU citizens under the European Union’s Charter of Fundamental Rights.
A replacement was negotiated in a new mechanism : the EU-US Data Privacy Framework. However, legal challenges are expected, and its long-term viability is uncertain. The APEC Privacy Framework and the OECD Privacy Framework, both involving the US, also exist.
Penalties for non-compliance
Whichever way you look at it, consumer data privacy laws and regulations make sense. But what’s really interesting is that many of them have real teeth to punish offenders. GDPR is a great example. It was largely an EU concern until January 2022 when the French data protection regulator hit Google and Facebook with serious fines and criminal penalties.
Google was fined €150M, and Facebook was told to pay €60M for failing to allow French users to reject cookie tracking technology easily. That started a tsunami of ever-larger fines.
The largest so far was the €1.2B fine levied by the Irish Data Protection Commission on Meta, the owner of Instagram, Facebook, and WhatsApp. It was issued for transferring European users’ personal data to the US without adequate data protection mechanisms. This significant penalty demonstrated the serious financial implications of non-compliance.
These penalties follow a structured approach rather than arbitrary determinations. The GDPR defines an unambiguous framework for fines. They can be up to 4% of a company’s total global turnover in the previous fiscal year. That’s a serious business threat.
What should you do ?
For businesses committed to long-term success, accepting and adapting to regulatory requirements is essential. Data privacy regulations and protection impact assessments are here to stay, with many national governments implementing similar frameworks.
However, there is some good news. As you’ve seen, many of these laws and regulations were informed by GDPR or retrospectively aligned. That’s a good place to start. Choose tools to handle your customer’s data that are natively GDPR-compliant.
For example, web analytics is all about data, and a lot of that data is personal. And if, like many people, you use Google Analytics 4, you’re already in trouble because it’s not GDPR-compliant by default. And achieving compliance requires significant additional configuration.
A better option would be to choose a web analytics platform that is compliant with GDPR right off the bat. Something like Matomo would do the trick. Then, complying with any of the tweaks individual countries have made to the basic GDPR framework will be a lot easier—and may even be handled for you.
Privacy-centric data strategies
Effective website data analysis is essential for business success. It enables organisations to understand customer needs and improve service delivery.
But that data doesn’t necessarily need to be tied to their identity — and that’s at the root of many of these regulations.
It’s not to stop companies from collecting data but to encourage and enforce responsible and ethical handling of that data. Without an official privacy policy or ethical data collection practices, the temptation for some to use and abuse that data for financial gain seems too great to resist.
Cookie usage and compliance
There was a time when cookies were the only way to collect reliable information about your customers and prospects. But under GDPR, and in many countries that based or aligned their laws with GDPR, businesses have to give users an easy way to opt out of all tracking, particularly tracking cookies.
So, how do you collect the information you need without cookies ? Easy. You use a web analytics platform that doesn’t depend wholly on cookies. For example, in certain countries and when configured for maximum privacy, Matomo allows for cookieless operation. It can also help you manage the cookie consent requirements of various data privacy regulations.
Choose the right tools
Data privacy regulations have become a permanent feature of the global business landscape. As digital commerce continues to expand, these regulatory frameworks will only become more established. Fortunately, there is a practical approach forward.
As mentioned several times, GDPR is considered by many countries to be a particularly good example of effective data privacy regulation. For that reason, many of them model their own legislation on the EU’s effort, making a few tweaks here and there to satisfy local requirements or anomalies.
As a result, if you comply with GDPR, the chances are that you’ll also comply with many of the other data privacy regulations discussed here. That also means that you can select tools for your data harvesting and analytics that comply with the GDPR out of the box, so to speak. Tools like Matomo.
Matomo lets website visitors retain full control over their data.
Before deciding whether to go with Matomo On-premise or the EU-hosted cloud version, why not start your 21-day free trial ? No credit card required.
-
MOV to ACVHD conversion via Spring Boot and FFmpeg leads to file system error
31 décembre 2024, par epicUsernameI am experiencing an issue on a personal project that seeks to convert HEIC to JPG files and MOV files to AVCHD format. The HEIC to JPG conversion works, but the MOV to AVCHD does not, which is where my problems lie.


The intent is to do this with Spring Boot and FFmpeg, using a simple interface done in WindowBuilder.


The relevant bits are the pom file :


<dependencies>
 
 
 <dependency>
 <groupid>jmagick</groupid>
 <artifactid>jmagick</artifactid>
 <version>6.6.9</version>
 </dependency>

 
 <dependency>
 <groupid>net.java.dev.jna</groupid>
 <artifactid>jna</artifactid>
 <version>5.7.0</version> 
 </dependency>
 <dependency>
 <groupid>net.java.dev.jna</groupid>
 <artifactid>jna-platform</artifactid>
 <version>5.7.0</version>
 </dependency>
 
 


 <dependency>
 <groupid>org.bytedeco</groupid>
 <artifactid>ffmpeg</artifactid>
 <version>7.1-1.5.11</version>
 </dependency>
 <dependency>
 <groupid>org.bytedeco</groupid>
 <artifactid>javacv</artifactid>
 <version>1.5.11</version>
 </dependency>
 <dependency>
 <groupid>org.bytedeco</groupid>
 <artifactid>ffmpeg-platform</artifactid>
 <version>7.1-1.5.11</version>
 </dependency>
 
 <dependency>
 <groupid>org.bytedeco</groupid>
 <artifactid>javacpp</artifactid>
 <version>1.5.11</version>
 </dependency>
 </dependencies>




and the main file with the event handling for the application, based on the interface :


package home.multimeida.mmconverter;

imports...

public class MMConverterInterface extends JFrame {

 public static void main(String[] args) {
 
 
 try {
 System.setProperty("jna.library.path", "absolute/path/to/gstreamer/bin");
 // Gst.init("GStreamer Test");
 System.out.println("GStreamer initialized successfully.");
 } catch (Exception e) {
 e.printStackTrace();
 System.out.println("Failed to initialize GStreamer.");
 }
 EventQueue.invokeLater(new Runnable() {
 public void run() {
 try {
 MMConverterInterface frame = new MMConverterInterface();
 frame.setVisible(true);
 } catch (Exception e) {
 e.printStackTrace();
 }
 }
 });
 }

 /**
 * Create the frame.
 */
 public MMConverterInterface() {
 
 // convert button
 
 btnConvert.addActionListener(e -> {
 
 try {
 
 if (sourceFileLabel.getText().equals("No file chosen...") || destinationFolderLabel.getText().equals("No folder selected...")) {
 JOptionPane.showMessageDialog(null, "Please select both an input file and a save location.", "Validation Error", JOptionPane.WARNING_MESSAGE);
 return;
 }
 
 File sourceFile = new File(sourceFileLabel.getText());
 File destinationFile;
 
 if (rdbtnNewRadioButton.isSelected()) {
 
 System.out.println("Converting HEIC to JPG...");
 
 String outputFileName = sourceFile.getName().replaceFirst("[.][^.]+$", ".jpg");
 
 // Call your conversion logic here
 
 destinationFile = new File(destinationFolderLabel.getText(), outputFileName);
 
 convertHeicToJpg(sourceFile, destinationFile);
 
 } else if (rdbtnNewRadioButton_1.isSelected()) {
 
 if (sourceFileLabel.getText().equals("No file chosen...") || destinationFolderLabel.getText().equals("No folder selected...")) {
 JOptionPane.showMessageDialog(null, "Please select both an input file and a save location.", "Validation Error", JOptionPane.WARNING_MESSAGE);
 return;
 }
 
 // Validate source file
 if (!sourceFile.exists() || !sourceFile.canRead()) {
 JOptionPane.showMessageDialog(null, "Source file does not exist or is not readable.", "File Error", JOptionPane.ERROR_MESSAGE);
 return;
 }
 
 // Validate destination folder
 String destinationPath = destinationFolderLabel.getText();
 if (destinationPath == null || destinationPath.isEmpty() || !(new File(destinationPath).isDirectory())) {
 JOptionPane.showMessageDialog(null, "Invalid destination folder.", "File Error", JOptionPane.ERROR_MESSAGE);
 return;
 }
 
 System.out.println("Converting MOV to AVCHD...");
 
 String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date());

 // Extract the file name without the extension
 String baseName = sourceFile.getName().replaceFirst("[.][^.]+$", "");

 // Sanitize the base name (replace invalid characters with '_')
 baseName = baseName.replaceAll("[^a-zA-Z0-9-_]", "_");
 
 String sanitizedFileName = baseName + "_" + currentDate;
 sanitizedFileName = sanitizedFileName.replaceAll("[^a-zA-Z0-9._-]", "_"); // Allow alphanumeric, '-', '_', and '.'

 destinationFile = new File(destinationPath, sanitizedFileName);
 
 
 /*
 // Ensure the destination file is writable
 if (!destinationFile.canWrite()) {
 JOptionPane.showMessageDialog(null, "Output file is not writable.", "File Error", JOptionPane.ERROR_MESSAGE);
 return;
 }
 */
 

 convertMovToAvchd(sourceFile, destinationFile);
 
 } else {
 
 JOptionPane.showMessageDialog(null, "Please select a conversion type.");
 
 }
 
 } catch (Exception ex) {
 
 JOptionPane.showMessageDialog(null, "Error: " + ex.getMessage(), "Conversion Error", JOptionPane.ERROR_MESSAGE);
 ex.printStackTrace();
 }
 
 
 });
 
 // cancel button:
 
 btnCancel.addActionListener(e -> {
 System.out.println("Operation canceled.");
 System.exit(0); // Close the application
 });

 }
 
 public void convertMovToAvchd(File sourceFile, File destinationFile) {
 avutil.av_log_set_level(avutil.AV_LOG_DEBUG);
 
 

 AVFormatContext inputFormatContext = null;
 AVFormatContext outputFormatContext = new AVFormatContext(null);
 AVCodecContext inputCodecContext = null;
 AVCodecContext outputCodecContext = null;

 try {
 // Validate input file
 if (!sourceFile.exists() || !sourceFile.canRead()) {
 System.out.println("Source file does not exist or is not readable: " + sourceFile.getAbsolutePath());
 return;
 }
 
 // Validate output file path using the validateFileCreation method
 if (!validateFileCreation(destinationFile)) {
 return; // Exit if destination file validation fails
 }

 // Validate output file path
 if (destinationFile.getParentFile() == null || !destinationFile.getParentFile().exists()) {
 System.out.println("Output directory does not exist: " + destinationFile.getParentFile());
 return;
 }
 if (!destinationFile.getParentFile().canWrite()) {
 System.out.println("Output directory is not writable: " + destinationFile.getParentFile());
 return;
 }

 // Open input file
 inputFormatContext = avformat.avformat_alloc_context();
 if (avformat.avformat_open_input(inputFormatContext, sourceFile.getAbsolutePath(), null, null) < 0) {
 System.out.println("Failed to open input file: " + sourceFile.getAbsolutePath());
 return;
 }

 // Find stream information
 if (avformat.avformat_find_stream_info(inputFormatContext, (PointerPointer) null) < 0) {
 System.out.println("Failed to retrieve input stream information.");
 return;
 }

 // Find video stream
 int videoStreamIndex = avformat.av_find_best_stream(inputFormatContext, avutil.AVMEDIA_TYPE_VIDEO, -1, -1, (AVCodec) null, 0);
 if (videoStreamIndex < 0) {
 System.out.println("Failed to find video stream in input file.");
 return;
 }

 // Initialize input codec context
 inputCodecContext = avcodec.avcodec_alloc_context3(null);
 avcodec.avcodec_parameters_to_context(inputCodecContext, inputFormatContext.streams(videoStreamIndex).codecpar());

 AVCodec decoder = avcodec.avcodec_find_decoder(inputCodecContext.codec_id());
 if (decoder == null || avcodec.avcodec_open2(inputCodecContext, decoder, (PointerPointer) null) < 0) {
 System.out.println("Failed to open video decoder.");
 return;
 }

 // Allocate output format context
 if (avformat.avformat_alloc_output_context2(outputFormatContext, null, "mpegts", destinationFile.getAbsolutePath()) < 0) {
 System.out.println("Failed to allocate output format context.");
 return;
 }

 // Initialize output codec
 AVCodec encoder = avcodec.avcodec_find_encoder_by_name("mpeg2video");
 if (encoder == null) {
 System.out.println("Failed to find MPEG2 video encoder.");
 return;
 }

 outputCodecContext = avcodec.avcodec_alloc_context3(encoder);
 if (outputCodecContext == null) {
 System.out.println("Failed to allocate output codec context.");
 return;
 }
 
 if ((outputFormatContext.oformat().flags() & avformat.AVFMT_GLOBALHEADER) != 0) {
 outputCodecContext.flags(outputCodecContext.flags() | avcodec.AV_CODEC_FLAG_GLOBAL_HEADER);
 }


 //outputCodecContext.codec_id(avcodec.AV_CODEC_ID_MPEG2VIDEO);
 outputCodecContext.codec_id(encoder.id());
 outputCodecContext.codec_type(avutil.AVMEDIA_TYPE_VIDEO);
 outputCodecContext.width(1920);
 outputCodecContext.height(1080);
 outputCodecContext.pix_fmt(avutil.AV_PIX_FMT_YUV420P);
 outputCodecContext.time_base(avutil.av_make_q(1, 25));
 outputCodecContext.bit_rate(4000000);
 outputCodecContext.gop_size(12);

 if ((outputFormatContext.oformat().flags() & avformat.AVFMT_GLOBALHEADER) != 0) {
 outputCodecContext.flags(outputCodecContext.flags() | avcodec.AV_CODEC_FLAG_GLOBAL_HEADER);
 }

 
 
 if (avcodec.avcodec_open2(outputCodecContext, encoder, (PointerPointer) null) < 0) {
 System.out.println("Failed to open video encoder.");
 return;
 }

 // Create output stream
 AVStream videoStream = avformat.avformat_new_stream(outputFormatContext, encoder);
 if (videoStream == null) {
 System.out.println("Failed to create video stream.");
 return;
 }

 avcodec.avcodec_parameters_from_context(videoStream.codecpar(), outputCodecContext);
 
 System.out.println("Destination file path before trying to open the file is: " + destinationFile);

 if ((outputFormatContext.oformat().flags() & avformat.AVFMT_NOFILE) == 0) {
 // Ensure the output path has the correct extension
 String outputPath = destinationFile.getAbsolutePath().replace("\\", "/") + ".avchd";
 System.out.println("Normalized output path: " + outputPath);

 // Try opening the output file
 int ret = avformat.avio_open(outputFormatContext.pb(), outputPath, avformat.AVIO_FLAG_WRITE);
 if (ret < 0) {
 BytePointer errorBuffer = new BytePointer(avutil.AV_ERROR_MAX_STRING_SIZE);
 avutil.av_strerror(ret, errorBuffer, errorBuffer.capacity());
 System.out.println("Failed to open output file: " + errorBuffer.getString());
 return;
 }
 }


 // Write header
 if (avformat.avformat_write_header(outputFormatContext, (PointerPointer) null) < 0) {
 System.out.println("Failed to write header to output file.");
 return;
 }


 // Packet processing loop
 AVPacket packet = new AVPacket();
 while (avformat.av_read_frame(inputFormatContext, packet) >= 0) {
 if (packet.stream_index() == videoStreamIndex) {
 if (avcodec.avcodec_send_packet(inputCodecContext, packet) >= 0) {
 AVFrame frame = avutil.av_frame_alloc();
 while (avcodec.avcodec_receive_frame(inputCodecContext, frame) >= 0) {
 if (avcodec.avcodec_send_frame(outputCodecContext, frame) >= 0) {
 AVPacket encodedPacket = new AVPacket();
 while (avcodec.avcodec_receive_packet(outputCodecContext, encodedPacket) >= 0) {
 encodedPacket.stream_index(videoStream.index());
 avformat.av_interleaved_write_frame(outputFormatContext, encodedPacket);
 avcodec.av_packet_unref(encodedPacket);
 }
 }
 avutil.av_frame_unref(frame);
 }
 avutil.av_frame_free(frame);
 }
 }
 avcodec.av_packet_unref(packet);
 }

 // Write trailer
 avformat.av_write_trailer(outputFormatContext);
 System.out.println("Conversion completed successfully.");
 
 if (avcodec.avcodec_send_frame(outputCodecContext, null) >= 0) {
 AVPacket encodedPacket = new AVPacket();
 while (avcodec.avcodec_receive_packet(outputCodecContext, encodedPacket) >= 0) {
 encodedPacket.stream_index(videoStream.index());
 avformat.av_interleaved_write_frame(outputFormatContext, encodedPacket);
 avcodec.av_packet_unref(encodedPacket);
 }
 }

 } catch (Exception e) {
 e.printStackTrace();
 } finally {
 // Cleanup
 avcodec.avcodec_free_context(inputCodecContext);
 avcodec.avcodec_free_context(outputCodecContext);
 avformat.avformat_close_input(inputFormatContext);

 if (outputFormatContext != null && outputFormatContext.pb() != null) {
 avformat.avio_closep(outputFormatContext.pb());
 }
 avformat.avformat_free_context(outputFormatContext);
 }
 }
 
 private boolean validateFileCreation(File destinationFile) {
 // Check if the parent directory exists and is writable
 File parentDir = destinationFile.getParentFile();
 if (parentDir == null || !parentDir.exists()) {
 System.out.println("Parent directory does not exist: " + parentDir);
 return false;
 }
 if (!parentDir.canWrite()) {
 System.out.println("Cannot write to parent directory: " + parentDir);
 return false;
 }

 // Check if the file exists and is writable
 if (destinationFile.exists()) {
 if (!destinationFile.canWrite()) {
 System.out.println("Destination file is not writable: " + destinationFile);
 return false;
 }
 } else {
 // If the file doesn't exist, try to create it to verify writability
 try {
 if (!destinationFile.createNewFile()) {
 System.out.println("Unable to create destination file: " + destinationFile);
 return false;
 }
 // Delete the file after successful creation to avoid residual files
 destinationFile.delete();
 } catch (IOException e) {
 System.out.println("File creation failed: " + e.getMessage());
 return false;
 }
 }

 return true;
 }
 
}





A few caveats :


- 

-
I did explore FFmpeg and GStreamer for this project. GStreamer was inconclusive, with available version for it that were too old for use with my current state of STS4.27 and Java 17, even if this version of Java is under long-term support...


-
I've used AI to tell me about the options and suggest ways to build this thing, since multimedia handling is very far away from my skillset. I don't have a good conceptual grasp of video formats and how they transfrom from one to another.








The issue, as I have identified it, occurs at these lines :


// Ensure the destination file is writable
 if (!destinationFile.canWrite()) {
 JOptionPane.showMessageDialog(null, "Output file is not writable.", "File Error", JOptionPane.ERROR_MESSAGE);
 return;
 }



^^ And this, while temporarily commented out for testing, it meant to compensate for an issue that occurs here in the conversion function :


if ((outputFormatContext.oformat().flags() & avformat.AVFMT_NOFILE) == 0) {
 // Ensure the output path has the correct extension
 String outputPath = destinationFile.getAbsolutePath().replace("\\", "/") + ".avchd";
 System.out.println("Normalized output path: " + outputPath);

 // Try opening the output file
 int ret = avformat.avio_open(outputFormatContext.pb(), outputPath, avformat.AVIO_FLAG_WRITE);
 if (ret < 0) {
 BytePointer errorBuffer = new BytePointer(avutil.AV_ERROR_MAX_STRING_SIZE);
 avutil.av_strerror(ret, errorBuffer, errorBuffer.capacity());
 System.out.println("Failed to open output file: " + errorBuffer.getString());
 return;
 }
 }



The idea here is that the avio_open() function requires the use of the a valid file path that it can open to be able to write it.


Padadoxically, the file conversion seems to work, but the project crashes with a fatal error in the console :


Selected file: E:\TestConveresions\sample_960x540.mov
Save location: E:\TestConveresions
Converting MOV to AVCHD...
Destination file path before trying to open the file is: E:\TestConveresions\sample_960x540_20241231
Normalized output path: E:/TestConveresions/sample_960x540_20241231.avchd
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffcffb0868b, pid=11020, tid=14436
#
# JRE version: OpenJDK Runtime Environment Temurin-21.0.5+11 (21.0.5+11) (build 21.0.5+11-LTS)
# Java VM: OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (21.0.5+11-LTS, mixed mode, emulated-client, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# C 0x00007ffcffb0868b
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# E:\STS4 Workspace\MMConverter\hs_err_pid11020.log
[80.882s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
# https://github.com/adoptium/adoptium-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
[AVFormatContext @ 000002528adcea40] Opening 'E:\TestConveresions\sample_960x540.mov' for reading
[file @ 000002528ae51c40] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] ISO: File Type Major Brand: qt 
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] Processing st: 0, edit list 0 - media time: 2002, duration: 400410
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] Offset DTS by 2002 to make first pts zero.
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] Setting codecpar->delay to 2 for stream st: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] Before avformat_find_stream_info() pos: 1320742 bytes read:38225 seeks:1 nb_streams:1
[h264 @ 000002528ae62780] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 000002528ae62780] Decoding VUI
[h264 @ 000002528ae62780] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 000002528ae62780] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 000002528ae62780] Decoding VUI
[h264 @ 000002528ae62780] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 000002528ae62780] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 000002528ae62780] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 000002528ae62780] Format yuv420p chosen by get_format().
[h264 @ 000002528ae62780] Reinit context to 960x544, pix_fmt: yuv420p
[h264 @ 000002528ae62780] no picture 
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002528adcea40] After avformat_find_stream_info() pos: 51943 bytes read:90132 seeks:2 frames:1
[h264 @ 000002528ae62780] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 000002528ae62780] Decoding VUI
[h264 @ 000002528ae62780] nal_unit_type: 8(PPS), nal_ref_idc: 3
[mpeg2video @ 000002528ae8e700] intra_quant_bias = 96 inter_quant_bias = 0




If I refer to the error log, I get this. It is partial, as I'm not sure SO will take all of it (quite long), but still might have enough to be relevant :


Host: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 8 cores, 31G, Windows 11 , 64 bit Build 26100 (10.0.26100.2454)


--------------- T H R E A D ---------------

Current thread (0x00000252d030b340): JavaThread "AWT-EventQueue-0" [_thread_in_native, id=14436, stack(0x000000a4e2b00000,0x000000a4e2c00000) (1024K)]

Stack: [0x000000a4e2b00000,0x000000a4e2c00000], sp=0x000000a4e2bfdf30, free space=1015k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x00007ffcffb0868b

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.bytedeco.ffmpeg.global.avformat.avio_open(Lorg/bytedeco/ffmpeg/avformat/AVIOContext;Ljava/lang/String;I)I+0
j home.multimeida.mmconverter.MMConverterInterface.convertMovToAvchd(Ljava/io/File;Ljava/io/File;)V+1120
j home.multimeida.mmconverter.MMConverterInterface.lambda$2(Ljavax/swing/JRadioButton;Ljavax/swing/JRadioButton;Ljava/awt/event/ActionEvent;)V+347
j home.multimeida.mmconverter.MMConverterInterface$$Lambda+0x000002528c0c7778.actionPerformed(Ljava/awt/event/ActionEvent;)V+13
j javax.swing.AbstractButton.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+84 java.desktop@21.0.5
j javax.swing.AbstractButton$Handler.actionPerformed(Ljava/awt/event/ActionEvent;)V+5 java.desktop@21.0.5
j javax.swing.DefaultButtonModel.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+34 java.desktop@21.0.5
j javax.swing.DefaultButtonModel.setPressed(Z)V+117 java.desktop@21.0.5
j javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Ljava/awt/event/MouseEvent;)V+35 java.desktop@21.0.5
j java.awt.Component.processMouseEvent(Ljava/awt/event/MouseEvent;)V+64 java.desktop@21.0.5
j javax.swing.JComponent.processMouseEvent(Ljava/awt/event/MouseEvent;)V+23 java.desktop@21.0.5
J 2581 c1 java.awt.Component.processEvent(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (220 bytes) @ 0x00000252fa62719c [0x00000252fa627020+0x000000000000017c]
J 2580 c1 java.awt.Container.processEvent(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (22 bytes) @ 0x00000252fa627d9c [0x00000252fa627cc0+0x00000000000000dc]
J 2406 c1 java.awt.Component.dispatchEventImpl(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (785 bytes) @ 0x00000252fa670f14 [0x00000252fa670040+0x0000000000000ed4]
J 2325 c1 java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (129 bytes) @ 0x00000252fa64e93c [0x00000252fa64e8a0+0x000000000000009c]
J 2608 c1 java.awt.LightweightDispatcher.retargetMouseEvent(Ljava/awt/Component;ILjava/awt/event/MouseEvent;)V java.desktop@21.0.5 (372 bytes) @ 0x00000252fa61c364 [0x00000252fa61b9e0+0x0000000000000984]
J 2578 c1 java.awt.LightweightDispatcher.processMouseEvent(Ljava/awt/event/MouseEvent;)Z java.desktop@21.0.5 (268 bytes) @ 0x00000252fa628a54 [0x00000252fa6284c0+0x0000000000000594]
J 2474 c1 java.awt.LightweightDispatcher.dispatchEvent(Ljava/awt/AWTEvent;)Z java.desktop@21.0.5 (73 bytes) @ 0x00000252fa699bbc [0x00000252fa699a60+0x000000000000015c]
J 2325 c1 java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (129 bytes) @ 0x00000252fa64e914 [0x00000252fa64e8a0+0x0000000000000074]
J 2473 c1 java.awt.Window.dispatchEventImpl(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (23 bytes) @ 0x00000252fa699654 [0x00000252fa6994e0+0x0000000000000174]
J 1838 c1 java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V java.desktop@21.0.5 (139 bytes) @ 0x00000252fa3bec64 [0x00000252fa3beb20+0x0000000000000144]
J 1837 c1 java.awt.EventQueue$4.run()Ljava/lang/Void; java.desktop@21.0.5 (60 bytes) @ 0x00000252fa3c0504 [0x00000252fa3c0460+0x00000000000000a4]
J 1836 c1 java.awt.EventQueue$4.run()Ljava/lang/Object; java.desktop@21.0.5 (5 bytes) @ 0x00000252fa3c0a04 [0x00000252fa3c09c0+0x0000000000000044]
J 1778 c1 java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object; java.base@21.0.5 (22 bytes) @ 0x00000252fa4601d4 [0x00000252fa45ffa0+0x0000000000000234]
J 1832 c1 java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V java.desktop@21.0.5 (80 bytes) @ 0x00000252fa44f14c [0x00000252fa44eae0+0x000000000000066c]
J 1846 c1 java.awt.EventDispatchThread.pumpOneEventForFilters(I)V java.desktop@21.0.5 (106 bytes) @ 0x00000252fa3ba544 [0x00000252fa3ba2e0+0x0000000000000264]
j java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35 java.desktop@21.0.5
j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11 java.desktop@21.0.5
j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4 java.desktop@21.0.5
j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3 java.desktop@21.0.5
j java.awt.EventDispatchThread.run()V+9 java.desktop@21.0.5
v ~StubRoutines::call_stub 0x00000252fa08100d

siginfo: EXCEPTION_ACCESS_VIOLATION (0xc0000005), writing address 0x0000000000000000




If anyone has a perspective on this, it'd be appreciated.


The catch 22 in this project is that pre-creating the file is not a good idea, since avio_open has a purpose in-built method for that (I tried). Error checking everything about Java's File class in terms of setting pathways and creating and deleting files is not problematic. Likewise, permissions are all fine (Full Control in source and target folders) ; I've tested default C drive folders, which have restritions, to a separate volume and removable media, to no effect. Likewise, FFmpeg requires a forward slash, "/" in file paths, whereas Java does the backslash, generally. That's been handled with the replace method in the above conditioning, also to no effect.


The basic contradiction in the project seems to be that the error tries open a file that does not exist, with a valid source and destination file, and if I try to create a placeholder file wiht an acvhd extension at the event handling for the Convert button, it still errors out ; meanwhile, FFmpeg allegedly handles the file creation at its core, but requires a valid path to be passed ; I've tried with and without a filename, with and without an extension. I'm not able to resovle it.


The excessive error handling conditions are in an effort to isolate the problem, which I think I've done.


There also seems to be a compatibility between mpegts and acvhd, which is why I also had that format specified in the conversion function, without result.


I also have the idea to be able to do this without having to install any libraries locally or having to set path variables, which is an aspect that both GStreamer and FFmpeg have.


Nearest suggestion I've found is this : integrate ffmpeg with spring boot


AI remains hopeless for resolving this issue.


-
-
How to verify user permissions – Introducing the Piwik Platform
9 novembre 2014, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to make your plugin multilingual). This time you’ll learn how to verify user permissions. For this tutorial you will need to have basic knowledge of PHP and the Piwik platform.
When should a plugin verify permissions ?
Usually you want to do this before executing any action – such as deleting or fetching data – and before rendering any sensitive information that should not be accessible by everyone. For instance in an API method or Controller action. You sometimes also need to verify permissions before registering menu items or widgets.
How does Piwik’s user management work ?
It is quite simple as it only differentiates between a few roles : View permission, Admin permission and Super User permission. If you manage multiple websites with Piwik a user can be assigned to different roles as a user might have no permission for some websites but view or admin permission for another set of websites.
Worth mentioning is that roles inherit from each other. This means the role admin automatically includes the role view and a super user automatically covers the view and admin role.
Getting started
In this post, we assume that you have already set up your development environment and created a plugin. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik and other Guides that help you to develop a plugin.
Verifying user permissions
To protect your data the platform offers many convenient methods in the \Piwik\Piwik class. There you will find methods that either start with
check
,is
orhas
. While methods that start withcheck
throw an exception in case a condition is not met, the other methods return a booleantrue
orfalse
.Use methods that throw an exception if you want to stop any further execution in case a user does not have an appropriate role. The platform will catch the exception and display an error message or ask the user to log in.
- public function deleteAllMessages()
- {
- // delete messages only if user has super user access, otherwise show an error message
- Piwik::checkUserSuperUserAccess();
- $this->getModel()->deleteAllMessages();
- }
Use methods that return a boolean for instance when registering menu items or widgets.
- public function configureAdminMenu(MenuAdmin $menu)
- {
- if (Piwik::hasUserSuperUserAccess()) {
- $menu->addPlatformItem('Plugins', $this->urlForDefaultAction());
- }
- }
It is important to be aware that just because the menu item won’t be displayed in the UI a user can still open the registered URL manually. Therefore you have to check for permissions in the actual controller action as well.
View permission
A user having a view permission should be only able to view reports but not make any changes apart from his personal settings. The methods that end with
UserHasSomeViewAccess
make sure a user has at least view permission for one website whereas the methods*UserHasViewAccess($idSites = array(1,2,3))
check whether a user has view access for all of the given websites.- Piwik::checkUserHasSomeViewAccess();
As a plugin developer you would usually use the latter example to verify the permissions for specific websites. Use the first example in case you develop something like an “All Websites Dashboard” where you only want to make sure the user has a view permission for at least one website.
Admin permission
A user having an admin permission cannot only view reports but also change website related settings. The methods to check for this role are similar to the ones before, just swap the term
View
withAdmin
.- Piwik::checkUserHasSomeAdminAccess();
Super user permission
A user having the super user permission is allowed to access all of the data stored in Piwik and change any settings. To check if a user has this role use one of the methods that end with
UserSuperUserAccess
.Piwik::checkUserHasSuperUserAccess();
As a plugin developer you would check for this permission for instance in places where your plugin shows an activity log over all users or where it offers the possibility to change any system wide settings.
Getting information about the currently logged in user
Sometimes you might want to know which user is currently logged in. This can be useful if you want to persist user related information in the database or if you want to send an email to the currently logged in user. You can easily get this information by calling the following methods :
- $login = Piwik::getCurrentUserLogin()
- $email = Piwik::getCurrentUserEmail()
Advanced features
Of course there is more that you can do. For instance you can verify whether a user is an anonymous user or whether a user has a specific role. You can also perform any operation in the context of a super user even if the current user does not have this role. Would you like to know more about those features ? Check out the Piwik class reference, the Security guide and the Manage Users user guide.
If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.