
Recherche avancée
Médias (91)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
avec chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
sans chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
config chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (68)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)
Sur d’autres sites (6979)
-
A Primer to Ethical Marketing : How to Build Trust in a Privacy-First World
Imagine a marketing landscape where transparency replaces tactics, where consumer privacy is prioritised over exploitation, and where authentic value builds genuine relationships.
This isn’t just an ideal—it’s the future of marketing. And it starts with ethical marketing practices.
76% of consumers refuse to buy from companies they do not trust with their data. Ethical marketing has become essential for business survival. As privacy regulations tighten and third-party cookies phase out, marketers face a critical question : how can they balance effective, personalised campaigns whilst respecting privacy ?
This comprehensive guide explores what ethical marketing is, the key principles behind ethical marketing practices, and practical strategies to implement an ethical approach that builds trust while driving growth.
What is ethical marketing ? A comprehensive definition
Ethical marketing places respect for consumer boundaries at its core whilst delivering genuine value. It prioritises transparent practices, honest communication, and fair value exchange with consumers. This approach represents a significant shift from traditional marketing, which often relied on collecting vast amounts of user data through invasive tracking methods and obscure policies.
The modern approach to ethical marketing creates a foundation built on three key pillars :
- User Control : Giving people genuine choice and agency over their data
- Fair Value : Providing clear benefits in exchange for any data shared
- Transparency : Being honest about how data is collected, used, and protected
Key principles of ethical marketing
Transparency
Transparency means being clear and forthright about your marketing practices, data collection policies, and business operations. It involves :
- Using plain language to explain how you collect and use customer data
- Being upfront about pricing, product limitations, and terms of service
- Disclosing sponsored content and affiliate relationships
- Making privacy policies accessible and understandable
When Matomo surveyed 2,000 consumers, 81% said they believe an organisation’s data practices reflect their overall treatment of customers. Transparency isn’t just about compliance—it’s about demonstrating respect.
Honesty
While similar to transparency, honesty focuses specifically on truthfulness in communications :
- Avoiding misleading claims or exaggerations about products and services
- Not manipulating statistics or research findings to support marketing narratives
- Representing products accurately in advertisements and marketing materials
- Acknowledging mistakes and taking responsibility when things go wrong
Social responsibility
Ethical marketing requires consideration of a brand’s impact on society as a whole :
- Considering environmental impacts of marketing campaigns and business practices
- Promoting diversity and inclusion in marketing representations
- Supporting social causes authentically rather than through “purpose-washing”
- Ensuring marketing activities don’t promote harmful stereotypes or behaviours
Ethical marketing dilemmas : Navigating complex business decisions
Data privacy concerns
The digital marketing landscape has been transformed by increasing awareness of data privacy issues and stricter regulations like GDPR, CCPA, and upcoming legislation. Key challenges include :
- The phase-out of third-party cookies, impacting targeting and measurement
- Growing consumer resistance to invasive tracking technologies
- Balancing personalisation with privacy (71% of consumers expect personalised experiences, yet demand privacy)
- Ensuring compliance across different jurisdictional requirements
Cultural sensitivity
Global brands must navigate complex cultural landscapes :
- Avoiding cultural appropriation in marketing campaigns
- Understanding varied cultural expectations around privacy
- Respecting local customs and values in international marketing
- Adapting messaging appropriately for diverse audiences
Environmental sustainability
The environmental impact of marketing activities is under increasing scrutiny :
- Digital carbon footprints from ad serving and website hosting
- Waste generated from physical marketing materials
- Promoting sustainable products honestly without greenwashing
- Aligning marketing messages with actual business practices
The benefits of ethical marketing
For years, digital marketing has relied on third-party data collection and broad-scale tracking. However, new regulations such as GDPR, CCPA, and the end of third-party cookies are pushing brands to adopt ethical data practices.
Increased customer loyalty
Ethical marketing fosters deeper relationships with customers by building trust. Research consistently shows that consumers are more loyal to brands they trust, with 71% indicating they would stop buying from a brand if trust is broken.
These trust-based relationships are more resilient during business challenges. When customers believe in a company’s integrity, they’re more likely to give the benefit of the doubt during controversies or service issues. They’re also more likely to provide constructive feedback rather than simply leaving for competitors.
Perhaps most importantly, loyal customers become advocates, sharing positive experiences with others and defending the brand against criticism. This organic advocacy is far more powerful than paid promotions and reduces customer acquisition costs significantly over time.
Enhanced brand reputation
A strong ethical stance improves overall brand perception across multiple dimensions. Media outlets are increasingly focused on corporate behaviour, providing positive coverage for ethical practices that extends a brand’s reach organically.
Social conversations about ethical brands tend to be more positive, with consumers sharing experiences and values rather than just discussing products. This creates a halo effect that benefits all aspects of the business.
This enhanced reputation also provides resilience during public relations challenges. Organisations with strong ethical foundations find it easier to navigate controversies because they’ve built a reservoir of goodwill with customers, employees, and other stakeholders.
Competitive advantage
Ethical marketing provides several distinct competitive advantages in modern markets. It helps brands access privacy-conscious consumer segments that actively avoid companies with questionable data practices. These segments often include higher-income, educated consumers who are valuable long-term customers.
Ethical approaches also reduce vulnerability to regulatory changes and potential penalties. As privacy laws continue to evolve globally, organisations with strong ethical foundations find compliance easier and less disruptive than those scrambling to meet minimum requirements.
Perhaps most significantly, ethical marketing supports more sustainable growth trajectories. While manipulative tactics might drive short-term results, they typically lead to higher churn rates and increasing acquisition costs. Ethical approaches build foundations for long-term success and stable growth.
For a detailed roadmap, download the Ethical Marketing Guide.
Case studies : Ethical marketing in action
Patagonia : Purpose-driven marketing
Patagonia integrates sustainability into its marketing, reinforcing its commitment to ethical business practices. By aligning with social causes, the brand strengthens customer loyalty.
Apple : Privacy as a competitive advantage
Apple positions itself as a leader in consumer privacy, ensuring data protection remains central to its marketing strategy. This commitment has become a key differentiator in the tech industry.
Matomo : The ethical analytics tool
Matomo offers privacy-first analytics that prioritise data ownership and compliance. Businesses using Matomo benefit from accurate insights while respecting user privacy.
These companies demonstrate that ethical marketing is not just a compliance requirement—it is a long-term competitive advantage.
Strategies for implementing ethical marketing
Aligning marketing efforts with brand values
Consistency between values and actions is essential for ethical marketing. This alignment starts with a clear understanding of what your organisation truly stands for—not just aspirational statements, but genuine commitments that inform daily decisions.
Implementing this alignment requires cross-functional collaboration. Marketing teams need to work closely with product development, customer service, and leadership to ensure consistency across all touchpoints. When different departments send contradictory messages about company values, trust erodes quickly.
Clear guidelines help marketing teams apply values in practical decisions, from campaign concepts to media placements. Regular ethical reviews of marketing plans can identify potential issues before campaigns launch, avoiding reactive corrections that damage credibility.
Privacy-first data strategies
Developing robust approaches to customer data is fundamental to ethical marketing. This starts with prioritising first-party data (collected directly from your own channels) and zero-party data (actively shared by customers through preference centres, surveys, and similar mechanisms).
Measuring success doesn’t have to come at the expense of privacy. Ethical analytics provide accurate insights while protecting user data, ensuring compliance, and enhancing customer trust.
Ethical personalisation approaches focus on using aggregated or anonymised data rather than individual tracking. This allows for relevant experiences without the invasive feeling that erodes trust when consumers feel watched across the internet.
Most importantly, ethical data strategies create transparent value exchanges where users clearly understand what benefits they receive in return for sharing information. This reciprocity transforms data collection from exploitation to fair exchange.
Measuring success ethically
Traditional marketing measurement often relies on individual-level tracking across sites and platforms. Ethical approaches require adapting these frameworks to respect privacy while still demonstrating impact.
Focusing on aggregate patterns rather than individual behaviour provides valuable insights without privacy invasions. For example, understanding that 30% of visitors to a specific page subsequently make purchases is actionable intelligence that doesn’t require tracking specific people.
Incrementality testing measures campaign impact by comparing outcomes between exposed and control groups at an aggregate level. This provides more accurate attribution than traditional last-click models while respecting privacy boundaries.
Server-side conversion tracking offers another ethical measurement approach, collecting necessary data on your servers rather than through client-side scripts vulnerable to blocking. This improves data accuracy while reducing reliance on cookies and browser storage.
Implementing ethical marketing strategies : A practical framework
1. Align marketing with brand values – Ensure campaigns reflect transparency and trust
2. Leverage first-party data – Collect insights directly from consumers with clear consent
3. Respect privacy and consent – Give users control over their data and clearly communicate its use
4. Create value-driven content – Offer educational and relevant resources instead of relying solely on advertising
5. Use privacy-compliant analytics – Switch to ethical platforms such as Matomo for responsible performance measurement
For a step-by-step guide to implementing ethical marketing strategies, download the full report here.
The future of ethical marketing
With the decline of third-party cookies and the rise of privacy regulations, ethical marketing is no longer optional. Brands that adopt privacy-first practices now will gain a sustainable competitive edge in the long term. The future of marketing belongs to brands that earn consumer trust, not those that exploit it.
Key trends shaping the future of marketing include :
- Privacy-first analytics to replace invasive tracking
- First-party and zero-party data strategies for direct consumer engagement
- Consent-driven personalisation to balance relevance and privacy
- Greater emphasis on corporate social responsibility in marketing initiatives
Companies that proactively address these changes will build stronger customer relationships, enhance brand reputation, and ensure long-term success.
Take the next step
Ready to transform your marketing approach for 2025 and beyond ?
Download Matomo’s comprehensive “2025 Ethical Marketing Field Guide” to get practical frameworks, implementation strategies, and real-world case studies that will help you build trust while driving growth.
With detailed guidance on first-party data activation, consent-based personalisation techniques, and privacy-preserving analytics methods, this guide provides everything you need to future-proof your marketing strategy in a privacy-first world.
Download the ethical marketing guide now to start building stronger, more trusted relationships with your customers through ethical marketing practices.
-
Making Your First-Party Data Work for You and Your Customers
11 mars, par Alex CarmonaAt last count, 162 countries had enacted data privacy policies of one kind or another. These laws or regulations, without exception, intend to eliminate the use of third-party data. That puts marketing under pressure because third-party data has been the foundation of online marketing efforts since the dawn of the Internet.
Marketers need to future-proof their operations by switching to first-party data. This will require considerable adjustment to systems and processes, but the reward will be effective marketing campaigns that satisfy privacy compliance requirements and bring the business closer to its customers.
To do that, you’ll need a coherent first-party data strategy. That’s what this article is all about. We’ll explain the different types of personal data and discuss how to use them in marketing without compromising or breaching data privacy regulations. We’ll also discuss how to build that strategy in your business.
So, let’s dive in.
The different data types
There are four distinct types of personal data used in marketing, each subject to different data privacy regulations.
Before getting into the different types, it’s essential to understand that all four may comprise one or more of the following :
Identifying data Name, email address, phone number, etc. Behavioural data Website activity, app usage, wishlist content, purchase history, etc. Transactional data Orders, payments, subscription details, etc. Account data Communication preferences, product interests, wish lists, etc. Demographic data Age, gender, income level, education, etc. Geographic Data Location-based information, such as zip codes or regional preferences. Psychographic Data Interests, hobbies and lifestyle preferences. First-party data
When businesses communicate directly with customers, any data they exchange is first-party. It doesn’t matter how the interaction occurs : on the telephone, a website, a chat session, or even in person.
Of course, the parties involved aren’t necessarily individuals. They may be companies, but people within those businesses will probably share at least some of the data with colleagues. That’s fine, so long as the data :
- Remains confidential between the original two parties involved, and
- It is handled and stored following applicable data privacy regulations.
The core characteristic of first-party data is that it’s collected directly from customer interactions. This makes it reliable, accurate and inherently compliant with privacy regulations — assuming the collecting party complies with data privacy laws.
A great example of first-party data use is in banking. Data collected from customer interactions is used to provide personalised services, detect fraud, assess credit risk and improve customer retention.
Zero-party data
There’s also a subset of first-party data, sometimes called zero-party data. It’s what users intentionally and proactively share with a business. It can be preferences, intentions, personal information, survey responses, support tickets, etc.
What makes it different is that the collection of this data depends heavily on the user’s trust. Transparency is a critical factor, too ; visitors expect to be informed about how you’ll use their data. Consumers also have the right to withdraw permission to use all or some of their information at any time.
Second-party data
This data is acquired from a separate organisation that collects it firsthand. Second-party data is someone else’s first-party data that’s later shared with or sold to other businesses. The key here is that whoever owns that data must give explicit consent and be informed of who businesses share their data with.
A good example is the cooperation between hotel chains, car rental companies, and airlines. They share joint customers’ flight data, hotel reservations, and car rental bookings, much like travel agents did before the internet undermined that business model.
Third-party data
This type of data is the arch-enemy of lawmakers and regulators trying to protect the personal data of citizens and residents in their country. It’s information collected by entities that have no direct relationship with the individuals whose data it is.
Third-party data is usually gathered, aggregated, and sold by data brokers or companies, often by using third-party cookies on popular websites. It’s an entire business model — these third-party brokers sell data for marketing, analytics, or research purposes.
Most of the time, third-party data subjects are unaware that their data has been gathered and sold. Hence the need for strong data privacy regulations.
Benefits of a first-party data strategy
First-party data is reliable, accurate, and ethically sourced. It’s an essential part of any modern digital marketing strategy.
More personalised experiences
The most important application of first-party data is customising and personalising customers’ interactions based on real behaviours and preferences. Personalised experiences aren’t restricted to websites and can extend to all customer communication.
The result is company communications and marketing messages are far more relevant to customers. It allows businesses to engage more meaningfully with them, building trust and strengthening customer relationships. Inevitably, this also results in stronger customer loyalty and better customer retention.
Greater understanding of customers
Because first-party data is more accurate and reliable, it can be used to derive valuable insights into customer needs and wants. When all the disparate first-party data points are centralised and organised, it’s possible to uncover trends and patterns in customer behaviour that might not be apparent using other data.
This helps businesses predict and respond to customer needs. It also allows marketing teams to be more deliberate when segmenting customers and prospects into like-minded groups. The data can also be used to create more precise personas for future campaigns or reveal how likely a customer would be to purchase in response to a campaign.
Build trust with customers
First-party data is unique to a business and originates from interactions with customers. It’s also data collected with consent and is “owned” by the company — if you can ever own someone else’s data. If treated like the precious resource, it can help businesses build trust with customers.
However, developing that trust requires a transparent, step-by-step approach. This gradually strengthens relationships to the point where customers are more comfortable sharing the information they’re asked for.
However, while building trust is a long and sometimes arduous process, it can be lost in an instant. That’s why first-party data must be protected like the Crown Jewels.
Components of a first-party data strategy
Security is essential to any first-party data strategy, and for good reason. As Gartner puts it, a business must find the optimal balance between business outcomes and data risk mitigation. Once security is baked in, attention can turn to the different aspects of the strategy.
Data collection
There are many ways to collect first-party data ethically, within the law and while complying with data privacy regulations, such as Europe’s General Data Protection Regulation (GDPR). Potential sources include :
Website activity forms and surveys, behavioural tracking, cookies, tracking pixels and chatbots Mobile app interactions in-app analytics, push notifications and in-app forms Email marketing newsletter sign-ups, email engagement tracking, promotions, polls and surveys Events registrations, post-event surveys and virtual event analytics Social media interaction polls and surveys, direct messages and social media analytics Previous transactions purchase history, loyalty programmes and e-receipts Customer service call centre data, live chat, chatbots and feedback forms In-person interactions in-store purchases, customer feedback and Wi-Fi sign-ins Gated content whitepapers, ebooks, podcasts, webinars and video downloads Interactive content quizzes, assessments, calculators and free tools CRM platforms customer profiles and sales data Consent management privacy policies, consent forms, preference setting Consent management
It may be the final item on the list above, but it’s also a key requirement of many data privacy laws and regulations. For example, the GDPR is very clear about consent : “Processing personal data is generally prohibited, unless it is expressly allowed by law, or the data subject has consented to the processing.”
For that reason, your first-party data strategy must incorporate various transparent consent mechanisms, such as cookie banners and opt-in forms. Crucially, you must provide customers with a mechanism to manage their preferences and revoke that consent easily if they wish to.
Data management
Effective first-party data management, mainly its security and storage, is critical. Most data privacy regimes restrict the transfer of personal data to other jurisdictions and even prohibit it in some instances. Many even specify where residents’ data must be stored.
Consider this cautionary tale : The single biggest fine levied for data privacy infringement so far was €1.2 billion. The Irish Data Protection Commission imposed a massive fine on Meta for transferring EU users’ data to the US without adequate data protection mechanisms.
Data security is critical. If first-party data is compromised, it becomes third-party data, and any customer trust developed with the business will evaporate. To add insult to injury, data regulators could come knocking. That’s why the trend is to use encryption and anonymisation techniques alongside standard access controls.
Once security is assured, the focus is on data management. Many businesses use a Customer Data Platform. This software gathers, combines and manages data from many sources to create a complete and central customer profile. Modern CRM systems can also do that job. AI tools could help find patterns and study them. But the most important thing is to keep databases clean and well-organised to make it easier to use and avoid data silos.
Data activation
Once first-party data has been collected and analysed, it needs to be activated, which means a business needs to use it for the intended purpose. This is the implementation phase where a well-constructed first-party strategy pays off.
The activation stage is where businesses use the intelligence they gather to :
- Personalise website and app experiences
- Adapt marketing campaigns
- Improve conversion rates
- Match stated preferences
- Cater to observed behaviours
- Customise recommendations based on purchase history
- Create segmented email campaigns
- Improve retargeting efforts
- Develop more impactful content
Measurement and optimisation
Because first-party data is collected directly from customers or prospects, it’s far more relevant, reliable, and specific. Your analytics and campaign tracking will be more accurate. This gives you direct and actionable insights into your audience’s behaviour, empowering you to optimise your strategies and achieve better results.
The same goes for your collection and activation efforts. An advanced web analytics platform like Matomo lets you identify key user behaviour and optimise your tracking. Heatmaps, marketing attribution tools, user behaviour analytics and custom reports allow you to segment audiences for better traction (and collect even more first-party data).
How to build a first-party data strategy
There are five important and sequential steps to building a first-party data strategy. But this isn’t a one-time process. It must be revisited regularly as operating and regulatory environments change. There are five steps :
- Audit existing data
Chances are that customers already freely provide a lot of first-party data in the normal course of business. The first step is to locate this data, and the easiest way to do that is by mapping the customer journey. This identifies all the touchpoints where first-party data might be found.
- Define objectives
Then, it’s time to step back and figure out the goals of the first-party data strategy. Consider what you’re trying to achieve. For example :
- Reduce churn
- Expand an existing loyalty programme
- Unload excess inventory
- Improve customer experiences
Whatever the objectives are, they should be clear and measurable.
- Implement tools and technology
The first two steps point to data gaps. Now, the focus turns to ethical web analytics with a tool like Matomo.
To further comply with data privacy regulations, it may also be appropriate to implement a Consent Management Platform (CMP) to help manage preferences and consent choices.
- Build trust with transparency
With the tools in place, it’s time to engage customers. To build trust, keep them informed about how their data is used and remind them of their right to withdraw their consent.
Transparency is crucial in such engagement, as outlined in the 7 GDPR principles.
- Continuously improve
Rinse and repeat. The one constant in business and life is change. As things change, they expose weaknesses or flaws in the logic behind systems and processes. That’s why a first-party data strategy needs to be continually reviewed, updated, and revised. It must adapt to changing trends, markets, regulations, etc.
Tools that can help
Looking back at the different types of data, it’s clear that some are harder and more bothersome to get than others. But capturing behaviours and interactions can be easy — especially if you use tools that follow data privacy rules.
But here’s a tip. Google Analytics 4 isn’t compliant by default, especially not with Europe’s GDPR. It may also struggle to comply with some of the newer data privacy regulations planned by different US states and other countries.
Matomo Analytics is compliant with the GDPR and many other data privacy regulations worldwide. Because it’s open source, it can be integrated with any consent manager.
Get started today by trying Matomo for free for 21 days,
no credit card required. -
(C_UDP Socket Programming) How can I convert binary file to video format ?
30 avril 2024, par user24723398I am practicing UDP socket programming. My code's functions are below.


- 

- Connect Server-Client and send "hello" message each other (it is working).
- Then Server is sending video file to client (problem).






Transfer video file to client is working. But it is written in binary so I can't open the video.


So I try to use ffmpeg to convert the video, but it doesn't work.


Is there something wrong in my code ? How can I transfer a received file to a video file ?


My environment is MacOs.


Server.c (Server Code) :


#include 
#include 
#include 
#include <arpa></arpa>inet.h>
#include 
#include <sys></sys>socket.h>

#define PORT 8888
#define BUF_SIZE 256

int main(){
 int serv_sock;
 char message[BUF_SIZE];
 char buf[BUF_SIZE];
 int str_len;
 socklen_t clnt_adr_sz;

 struct sockaddr_in serv_adr, clnt_adr;
 
 //create socket
 serv_sock=socket(PF_INET, SOCK_DGRAM, 0);
 if(serv_sock == -1){
 perror("socket() error");
 exit(1);
 }
 
 //socket address
 memset(&serv_adr, 0, sizeof(serv_adr));
 serv_adr.sin_family=AF_INET;
 serv_adr.sin_addr.s_addr=htonl(INADDR_ANY);
 serv_adr.sin_port=htons(PORT);
 //binding socket
 if(bind(serv_sock, (struct sockaddr*)&serv_adr, sizeof(serv_adr)) == -1){
 perror("bind() error");
 exit(1);
 }
 
 while(1){
 clnt_adr_sz=sizeof(clnt_adr);
 str_len=recvfrom(serv_sock, message, BUF_SIZE, 0, (struct sockaddr *)&clnt_adr, &clnt_adr_sz);
 if (str_len < 0) {
 perror("recvfrom error");
 exit(1);
 }
 
 char hello_message[] = "hello i am server";
 if (sendto(serv_sock, hello_message, strlen(hello_message), 0, (struct sockaddr *)&clnt_adr, clnt_adr_sz) < 0) {
 perror("sendto error");
 exit(1);
 }
 
 //print message
 message[str_len] = '\0';
 printf("client say: %s\n", message);
 
 char buf[BUF_SIZE];
 ssize_t bytes_read;
 // sending viedo file
 printf("sending video file...\n");
 size_t fsize;
 
 //video file
 FILE *file;
 char *filename = "video.mp4";
 // open video file
 file = fopen(filename, "rb");
 if (file == NULL) {
 perror("File opening failed");
 exit(EXIT_FAILURE);
 }
 //calculate video file memory
 fseek(file, 0, SEEK_END);
 fsize = ftell(file);
 fseek(file,0,SEEK_SET);
 
 size_t size = htonl(fsize);
 int nsize =0;
 
 while(nsize!=fsize){
 int fpsize = fread(buf,1, BUF_SIZE, file);
 nsize += fpsize;
 if (sendto(serv_sock, &size, sizeof(size), 0, (struct sockaddr *)&clnt_adr, clnt_adr_sz) < 0) {
 perror("sendto");
 exit(EXIT_FAILURE); 
 }
 fclose(file);
 /*
 while ((bytes_read = fread(buf, 1, BUF_SIZE, file)) > 0) {
 if (sendto(serv_sock, buf, bytes_read, 0,
 (struct sockaddr *)&clnt_adr, clnt_adr_sz) < 0) {
 perror("sendto");
 exit(EXIT_FAILURE);
 } 
 }
 */
 } 
 }
 close(serv_sock);
 return 0;
}



Client.c (Client code)


#include 
#include 
#include 
#include <arpa></arpa>inet.h>
#include 
#include <sys></sys>socket.h>

#define BUFSIZE 256
#define PORT 8888

int main(){
 int sock;
 char message[BUFSIZE];
 int str_len;
 socklen_t adr_sz;

 struct sockaddr_in serv_addr, client_addr; 
 
 sock = socket(PF_INET, SOCK_DGRAM, 0);
 if(sock == -1){
 printf("socket() error\n");
 exit(1);
 }

 memset(&serv_addr, 0, sizeof(serv_addr));
 serv_addr.sin_family = AF_INET;
 serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
 serv_addr.sin_port = htons(PORT);

 char hello_message[] = "hello i am client";
 sendto(sock, hello_message, strlen(hello_message), 0, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
 adr_sz = sizeof(client_addr);
 str_len=recvfrom(sock,message,BUFSIZE,0,(struct sockaddr*)&client_addr,&adr_sz);
 
 message[str_len] = '\0';
 printf("client say: %s\n", message);
 
 /*
 char buf[BUFSIZE];
 ssize_t bytes_received;
 socklen_t serv_len = sizeof(serv_addr);
 while ((bytes_received = recvfrom(sock, buf, BUFSIZE, 0,
 (struct sockaddr *)&serv_addr, &serv_len)) > 0) {
 fwrite(buf, 1, bytes_received, file);
 }
 */
 
 FILE *file = fopen("received_test.mp4", "wb");

 int nbyte = BUFSIZE;
 while(nbyte>= BUFSIZE){
 nbyte = recvfrom(sock, message, BUFSIZE, 0, (struct sockaddr*)&serv_addr, &adr_sz);
 fwrite(message, sizeof(char), nbyte, file);
 }

 if (file == NULL) {
 perror("File opening failed");
 exit(EXIT_FAILURE);
 }

 fclose(file);
 close(sock);
 printf("File received successfully\n");
 
 return 0;
}



I try to convert the binary file to an
.mp4
file using ffmpeg
but it doesn't work :

ffmpeg -i received_test.mp4 output.mp4
ffmpeg version 7.0 Copyright (c) 2000-2024 the FFmpeg developers
 built with Apple clang version 15.0.0 (clang-1500.3.9.4)
 configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
 libavutil 59. 8.100 / 59. 8.100
 libavcodec 61. 3.100 / 61. 3.100
 libavformat 61. 1.100 / 61. 1.100
 libavdevice 61. 1.100 / 61. 1.100
 libavfilter 10. 1.100 / 10. 1.100
 libswscale 8. 1.100 / 8. 1.100
 libswresample 5. 1.100 / 5. 1.100
 libpostproc 58. 1.100 / 58. 1.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x12a62bdb0] Format mov,mp4,m4a,3gp,3g2,mj2 detected only with low score of 1, misdetection possible!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x12a62bdb0] moov atom not found
[in#0 @ 0x12b0043c0] Error opening input: Invalid data found when processing input
Error opening input file received_test.mp4.
Error opening input files: Invalid data found when processing input