
Recherche avancée
Médias (91)
-
DJ Z-trip - Victory Lap : The Obama Mix Pt. 2
15 septembre 2011
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Matmos - Action at a Distance
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
DJ Dolores - Oslodum 2004 (includes (cc) sample of “Oslodum” by Gilberto Gil)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Danger Mouse & Jemini - What U Sittin’ On ? (starring Cee Lo and Tha Alkaholiks)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Cornelius - Wataridori 2
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Rapture - Sister Saviour (Blackstrobe Remix)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (77)
-
Qualité du média après traitement
21 juin 2013, parLe bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Configuration spécifique pour PHP5
4 février 2011, parPHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
Modules spécifiques
Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)
Sur d’autres sites (1786)
-
(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



-
FFmpeg Could not write header (incorrect codec parameters ?) : Invalid data found when processing input [closed]
14 juillet 2024, par cookieThe command


ffmpeg -v verbose -i in.mkv -c copy -y out.mkv



produces the following error :


ffmpeg version 7.0.1-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
 built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
 configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
 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
[hevc @ 00000133b5bb5040] Invalid default display window
Input #0, matroska,webm, from 'in.mkv':
 Metadata:
 encoder : libebml v1.3.0 + libmatroska v1.4.1
 creation_time : 2015-03-20T14:07:27.000000Z
 Duration: 00:24:11.75, start: 0.000000, bitrate: 5185 kb/s
 Chapters:
 Chapter #0:0: start 0.000000, end 48.047000
 Metadata:
 title : Chapter 01
 Chapter #0:1: start 48.047000, end 137.846000
 Metadata:
 title : Chapter 02
 Chapter #0:2: start 137.846000, end 535.868000
 Metadata:
 title : Chapter 03
 Chapter #0:3: start 535.868000, end 1330.871000
 Metadata:
 title : Chapter 04
 Chapter #0:4: start 1330.871000, end 1420.877000
 Metadata:
 title : Chapter 05
 Chapter #0:5: start 1420.877000, end 1451.741000
 Metadata:
 title : Chapter 06
 Chapter #0:6: start 1451.741000, end 1451.745000
 Metadata:
 title : Chapter 07
 Stream #0:0: Video: hevc (Main 10), 1 reference frame, yuv420p10le(tv, left), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn (default)
 Metadata:
 _STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 32bit built on Jun 9 2014 15:08:34
 _STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 32bit built on Jun 9 2014 15:08:34
 _STATISTICS_WRITING_DATE_UTC: 2015-03-20 14:07:27
 _STATISTICS_WRITING_DATE_UTC-eng: 2015-03-20 14:07:27
 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
 BPS : 3754023
 BPS-eng : 3754023
 DURATION : 00:24:11.742000000
 DURATION-eng : 00:24:11.742000000
 NUMBER_OF_FRAMES: 34807
 NUMBER_OF_FRAMES-eng: 34807
 NUMBER_OF_BYTES : 681234123
 NUMBER_OF_BYTES-eng: 681234123
 Stream #0:1(jpn): Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
 Metadata:
 _STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 32bit built on Jun 9 2014 15:08:34
 _STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 32bit built on Jun 9 2014 15:08:34
 _STATISTICS_WRITING_DATE_UTC: 2015-03-20 14:07:27
 _STATISTICS_WRITING_DATE_UTC-eng: 2015-03-20 14:07:27
 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
 BPS : 1429414
 BPS-eng : 1429414
 DURATION : 00:24:11.745000000
 DURATION-eng : 00:24:11.745000000
 NUMBER_OF_FRAMES: 17013
 NUMBER_OF_FRAMES-eng: 17013
 NUMBER_OF_BYTES : 259393130
 NUMBER_OF_BYTES-eng: 259393130
[out#0/matroska @ 00000133b5bb5a40] No explicit maps, mapping streams automatically...
[vost#0:0/copy @ 00000133b5c2f580] Created video stream from input stream 0:0
[aost#0:1/copy @ 00000133b5bf1680] Created audio stream from input stream 0:1
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
[out#0/matroska @ 00000133b5bb5a40] Could not write header (incorrect codec parameters ?): Invalid data found when processing input
[AVIOContext @ 00000133b5c27940] Statistics: 291 bytes written, 0 seeks, 1 writeouts
[AVIOContext @ 00000133b5b97980] Statistics: 66432 bytes read, 2 seeks
Conversion failed!



Originally, I was trying to add a subtitle to
in.mkv
, but I keep encountering this error. When I add the subtitle to another MKV file, it works fine, so I believe the problem lies within.mkv
.

Troubleshooting


Output only video stream produce the same error :


ffmpeg -i in.mkv -map 0:v:0 -c copy out.mkv



Output only audio stream works fine :


ffmpeg -i in.mkv -map 0:a:0 -c copy out.mkv



Output as mp4 got no error, but the output file is unplayable :


ffmpeg -i in.mkv -c copy -strict -2 out.mp4



Re-encoding works fine :


ffmpeg -i in.mkv -c:v libx265 -c:a copy out.mkv



How can I fix the video stream in
in.mkv
so that I can add a subtitle stream and remux the file without re-encoding the video ? Any insights or suggestions on handling this error would be greatly appreciated.

-
FFMPEG is not working in app service post deployment
1er mars 2024, par Tushar GuptaI using the Xabe.FFmpeg package to generate clips from a video. The code is basically converting a video to multiple clips and it's working fine in my local but whenever I am uploading the code to app service the code is not working.


Stack : .net
App Service OS : Windows


Error :


2024-02-13 08:57:34.092 +00:00 [Error] Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer : Connection ID "16573246629528734243", Request ID "40000a24-0000-e600-b63f-84710c7967bb" : An unhandled exception was thrown by the application.System.ComponentModel.Win32Exception (193) : An error occurred trying to start process 'C :\home\site\wwwroot\Controllers\ffmpeg\bin\ffmpeg.exe' with working directory 'C :\home\site\wwwroot'. The specified executable is not a valid application for this OS platform.at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)at System.Diagnostics.Process.Start()at Xabe.FFmpeg.FFmpeg.RunProcess(String args, String processPath, Nullable
1 priority, Boolean standardInput, Boolean standardOutput, Boolean standardError)at Xabe.FFmpeg.FFmpegWrapper.<>c__DisplayClass14_0.<runprocess>b__0()at System.Threading.Tasks.Task</runprocess>
1.InnerInvoke()at System.Threading.Tasks.Task.<>c.<.cctor>b__281_0(Object obj)at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)--- End of stack trace from previous location ---at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)--- End of stack trace from previous location ---at Xabe.FFmpeg.Conversion.Start(String parameters, CancellationToken cancellationToken)at ExtractResponseAPI.Controllers.HomeController.PrepareVideoClips(CloudBlockBlob sourceVideoBlob, TimeSpan startTime, TimeSpan endTime) in C :\Users\tushar.h.gupta\source\repos\ExtractResponseAPI\Controllers\HomeController.cs:line 164at ExtractResponseAPI.Controllers.HomeController.GetIntervalsAsync(String query) in C :\Users\tushar.h.gupta\source\repos\ExtractResponseAPI\Controllers\HomeController.cs:line 60at ExtractResponseAPI.Controllers.HomeController.Get(String query) in C :\Users\tushar.h.gupta\source\repos\ExtractResponseAPI\Controllers\HomeController.cs:line 24at lambda_method4(Closure, Object)at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<invokenextactionfilterasync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<invokeinnerfilterasync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<invokefilterpipelineasync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<invokeasync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<invokeasync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT</invokeasync></invokeasync></invokefilterpipelineasync></invokeinnerfilterasync></invokenextactionfilterasync>
1.ProcessRequestAsync()

Code :


private async Task> PrepareVideoClips(CloudBlockBlob sourceVideoBlob, TimeSpan startTime, TimeSpan endTime)
{
 string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

 // Create a temporary directory to store clips locally
 Directory.CreateDirectory(tempDirectory);

 // Download the source video
 string sourceVideoPath = Path.Combine(tempDirectory, "sourceVideo.mp4");
 await sourceVideoBlob.DownloadToFileAsync(sourceVideoPath, FileMode.Create);
 FFmpeg.SetExecutablesPath("Controllers\\ffmpeg\\bin\\");
 // Use FFmpegCore to trim the video
 string outputVideoPath = Path.Combine(tempDirectory, "output.mp4");

 await FFmpeg.Conversions.New()
 .AddParameter($"-ss {startTime.TotalSeconds}") // Start time
 .AddParameter($"-i {sourceVideoPath}")
 .AddParameter($"-to {(endTime - startTime).TotalSeconds}") // Duration
 .SetOutput(outputVideoPath)
 .Start();

 // Return a list of file paths for the clips
 return new List<string> { outputVideoPath };
}
</string>


I tried deploying the app service using different OS but still facing the same issue, I also tried using different packages but the result is same.