
Recherche avancée
Médias (91)
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
-
Core Media Video
4 avril 2013, par
Mis à jour : Juin 2013
Langue : français
Type : Video
-
The pirate bay depuis la Belgique
1er avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
-
Exemple de boutons d’action pour une collection collaborative
27 février 2013, par
Mis à jour : Mars 2013
Langue : français
Type : Image
-
Exemple de boutons d’action pour une collection personnelle
27 février 2013, par
Mis à jour : Février 2013
Langue : English
Type : Image
Autres articles (68)
-
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs
Sur d’autres sites (9239)
-
Processing of multipart/form-data request failed. Unexpected EOF read on the socket
23 mai 2017, par RaresI am trying to upload a video file to the server(
Spring Boot
) from android.A video filmed with the phone has >50 MB if you film at least 2 minutes so I have to compress the file before uploading.
Before compressing I tried to upload uncompressed files and it worked fine(10-30MB videos). Now I want to compress files because I want to send bigger videos to the server.
I use multipart/form-data in android to send the file to the server.EDIT :
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_PICK_VIDEO && resultCode == RESULT_OK && data != null) {
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("Uploading");
progressDialog.setMessage("Please wait...");
progressDialog.show();
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
String filePath = getRealPathFromURI(getApplicationContext(), data.getData());
///get the name of file without extension
StringBuilder stringBuilder = new StringBuilder(filePath);
int start = filePath.lastIndexOf('.');
stringBuilder.delete(start, filePath.length());
//--------------
//get file extension(e.g mp4)
File file = new File(filePath);
String contentType = getFileType(file.getAbsolutePath());
//--------------
//create compressed file path=initial file path+ _compressed+(random nr.)+ extension .mp4
Random random = new Random();
int fileNr = random.nextInt(999);
String compressedFilePath = stringBuilder.toString() + "_compressed" + fileNr +"."+ contentType;
//compress file from gallery and save it with the above name
String[] command = {"-y", "-i", filePath, "-s", "640x480", "-r", "25", "-vcodec",
"mpeg4", "-b:v", "150k", "-b:a", "48000", "-ac", "2", "-ar", "22050", compressedFilePath};
executeFFmpegBinary(command);
File file2 = new File(compressedFilePath);
if (file2.exists()) {
OkHttpClient httpClient = new OkHttpClient();
RequestBody fileBody = RequestBody.create(MediaType.parse(contentType), file2);
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("type", contentType)
.addFormDataPart("uploaded_file", file2.getName(), fileBody)
.build();
Request request = new Request.Builder()
.url(SERVER_ADDRESS_UPLOAD)
.post(requestBody)
.build();
try {
final Response response = httpClient.newCall(request).execute();
if (!response.isSuccessful()) {
printFromThread(response.toString());
throw new IOException("Error: " + response);
} else {
printFromThread(response.body().string());
}
progressDialog.dismiss();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
thread.start();
}
}When I use FFmpeg compression and I send the compressed file to the server I receive the following error in the server :
Processing of multipart/form-data request failed. Unexpected EOF read on the socket
Server bean :
@RequestMapping(value = "/upload-image", method = RequestMethod.POST)
@ResponseBody
public String handleUploadImageRequest(@RequestParam("uploaded_file")
MultipartFile file) throws IOException {
File fileReceived = new File(VIDEOS_DIR+"/"+file.getOriginalFilename());
fileReceived.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(fileReceived);
fileOutputStream.write(file.getBytes());
fileOutputStream.close();
prelucrareVideo(fileReceived);
return "....";}
Here is the exception :
2017-05-22 23:36:24.122 DEBUG 5032 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
2017-05-22 23:36:24.122 DEBUG 5032 --- [nio-8080-exec-1] .w.s.m.a.ResponseStatusExceptionResolver : Resolving exception from handler [null]: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
2017-05-22 23:36:24.123 DEBUG 5032 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
2017-05-22 23:36:24.123 DEBUG 5032 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : Could not complete request
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:111) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:85) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:79) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1100) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:932) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
at org.apache.catalina.connector.Request.parseParts(Request.java:2874) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParameters(Request.java:3177) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.getParameter(Request.java:1110) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:75) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
... 23 more
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:297) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParts(Request.java:2801) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParameters(Request.java:3177) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.getParameter(Request.java:1110) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:75) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
... 23 more
Caused by: java.io.EOFException: Unexpected EOF read on the socket
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:717) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:40) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1061) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:139) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:256) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.Request.doRead(Request.java:540) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:319) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:627) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:342) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:183) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.8.0_121]
at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:132) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:977) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:881) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.8.0_121]
at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:132) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at java.io.FilterInputStream.read(FilterInputStream.java:107) ~[?:1.8.0_121]
at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:68) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:293) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParts(Request.java:2801) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParameters(Request.java:3177) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.getParameter(Request.java:1110) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:75) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
... 23 more
2017-05-22 23:36:24.130 ERROR 5032 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket] with root cause
java.io.EOFException: Unexpected EOF read on the socket
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:717) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:40) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1061) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:139) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:256) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.Request.doRead(Request.java:540) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:319) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:627) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:342) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:183) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.8.0_121]
at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:132) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:977) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:881) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.8.0_121]
at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:132) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at java.io.FilterInputStream.read(FilterInputStream.java:107) ~[?:1.8.0_121]
at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:68) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:293) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParts(Request.java:2801) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.parseParameters(Request.java:3177) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.Request.getParameter(Request.java:1110) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:75) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
</init>What is the solution ? Thanks in advance.
-
FFmpeg decoded video is garbled mess with no audio. How can I fix it ? [closed]
14 septembre 2023, par Señor TontoI am trying to use FFmpeg 6.0 (which seems to have a terrible lack of documentation) to decode a .mp4/.mov file & play its audio. I am testing this on a .mov file (I tried also with a .mp4, same result) of an old animation I found. This turns out as a garbled mess that looks like an old film movie with no audio. Now, I used some old tutorials & managed to with much trial get the code I have now, which is of course half-working. I am using SDL to output the video. I'm not sure if it's a problem on the SDL end or the FFmpeg end at the moment (but I'm sure the video is a mix of the two & the audio because of SDL) I would appreciate some help as there's very little documentation I can find that isn't outdated & the deprecated list on FFmpeg hardly helps when I need to fix API-related changes. Here's my code


LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
 OPENFILENAME ofn;

 wchar_t g_filePath[MAX_PATH] = L"";
 char szFile[MAX_PATH] = "";
 wchar_t wFile[MAX_PATH] = L"";
 char data[MAX_PATH];
 DWORD bytesRead = 0;
 BOOL bSuccess = FALSE;
 static int iVscrollPos, cyClient, cyChar, cxChar, cxCaps, iMaxVerticalScroll = 0, iNumLines = 0;
 HDC hdc;
 TEXTMETRIC tm;
 static int tabIndex;
 std::wstring filePath;

 //FFmpeg variables
 static AVFormatContext* format_ctx = nullptr; 
 static AVCodecContext* video_codec_ctx = nullptr;
 static AVCodecContext* audio_codec_ctx = nullptr;
 static AVFrame* video_frame = nullptr;
 static AVFrame* audio_frame = nullptr;
 static AVPacket packet;
 static struct SwsContext* sws_ctx = nullptr;
 static int video_stream_idx = -1;
 static int audio_stream_idx = -1;
 static int video_width = 0;
 static int video_height = 0;
 static HWND hVideoWnd = nullptr;
 static HDC hVideoDC = nullptr;
 static HBITMAP hVideoBitmap = nullptr;

 switch (msg) {
 case WM_CREATE:
 break;
 case WM_SIZE:
 break;
 case WM_NOTIFY:
 //code for handling tab switching & creating all content inside the tabs, currently half-working, perhaps give each tab a show & update win call?
 if (((LPNMHDR)lParam)->code == TCN_SELCHANGE) {
 tabIndex = TabCtrl_GetCurSel(g_hWndTabs);
 if (tabIndex == 0) {
 DestroyWindow(openFileBtn);
 DestroyWindow(saveFileBtn);
 DestroyWindow(emboldenBtn);
 DestroyWindow(italiciseBtn);
 DestroyWindow(hEditControl);
 DestroyWindow(hScrollContainer);

 //this code reloads table data & reconstructs the table whenever the 'table view' tab is opened,
 std::wifstream infile("tabledata.txt");
 while (numRows > 0) {
 numRows--;
 }
 while (true) {
 // Read in data for a row
 wchar_t buf1[MAX_PATH], buf2[MAX_PATH], buf3[MAX_PATH];
 if (!(infile >> buf1 >> buf2 >> buf3)) {
 // End of file reached, break out of loop
 break;
 }

 // Create new row window for this row of data
 HWND hRow = CreateWindowEx(0, L"STATIC", nullptr,
 WS_CHILD | WS_VISIBLE | WS_BORDER,
 startX, startY + numRows * ROW_HEIGHT,
 3 * CELL_WIDTH, ROW_HEIGHT,
 g_hWndMain, nullptr, g_hInstance, nullptr);

 // Create cell edit controls within the new row
 HWND hCell1 = CreateWindowEx(0, L"EDIT", nullptr,
 WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_BORDER,
 0, 0, CELL_WIDTH, ROW_HEIGHT,
 hRow, nullptr, g_hInstance, nullptr);
 HWND hCell2 = CreateWindowEx(0, L"EDIT", nullptr,
 WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_BORDER,
 CELL_WIDTH, 0, CELL_WIDTH, ROW_HEIGHT,
 hRow, nullptr, g_hInstance, nullptr);
 HWND hCell3 = CreateWindowEx(0, L"EDIT", nullptr,
 WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_BORDER,
 2 * CELL_WIDTH, 0, CELL_WIDTH, ROW_HEIGHT,
 hRow, nullptr, g_hInstance, nullptr);

 // Set the text of each cell edit control
 SetWindowTextW(hCell1, buf1);
 SetWindowTextW(hCell2, buf2);
 SetWindowTextW(hCell3, buf3);

 // Update the row window
 InvalidateRect(hRow, nullptr, TRUE);
 UpdateWindow(hRow);

 numRows++;
 }



 tblHeaderOne = CreateWindow(L"STATIC", L"Header 1",
 WS_CHILD | WS_VISIBLE | SS_CENTER | WS_BORDER,
 0, 40, 110, 20,
 g_hWndMain, (HMENU)CELL_1_ID, g_hInstance, NULL);
 InvalidateRect(tblHeaderOne, NULL, TRUE);
 UpdateWindow(tblHeaderOne);


 tblHeaderTwo = CreateWindow(L"STATIC", L"Header 2",
 WS_CHILD | WS_VISIBLE | SS_CENTER | WS_BORDER,
 110, 40, 110, 20,
 g_hWndMain, (HMENU)CELL_2_ID, g_hInstance, NULL);
 InvalidateRect(tblHeaderTwo, NULL, TRUE);
 UpdateWindow(tblHeaderTwo);

 tblHeaderThree = CreateWindow(L"STATIC", L"Header 3",
 WS_CHILD | WS_VISIBLE | SS_CENTER | WS_BORDER,
 220, 40, 110, 20,
 g_hWndMain, (HMENU)CELL_3_ID, g_hInstance, NULL);
 InvalidateRect(tblHeaderThree, NULL, TRUE);
 UpdateWindow(tblHeaderThree);

 // Create button to add new row
 addRowBtn = CreateWindow(L"BUTTON", L"Add Row",
 WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
 390, 40, 100, 30,
 g_hWndMain, (HMENU)ADD_ROW_BTN, g_hInstance, NULL);
 InvalidateRect(addRowBtn, NULL, TRUE);
 UpdateWindow(addRowBtn);

 }
 else if (tabIndex == 1) {

 DestroyWindow(hRow);
 DestroyWindow(tableContainer);
 DestroyWindow(tblHeaderOne);
 DestroyWindow(tblHeaderTwo);
 DestroyWindow(tblHeaderThree);
 DestroyWindow(addRowBtn);



 openFileBtn = CreateWindow(L"BUTTON", L"Open File",
 WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
 10, 40, 150, 25,
 g_hWndMain, (HMENU)OPEN_FILE_BTN, NULL, NULL);
 InvalidateRect(openFileBtn, NULL, TRUE);
 UpdateWindow(openFileBtn);

 saveFileBtn = CreateWindow(L"BUTTON", L"Save File",
 WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
 10, 80, 150, 25,
 g_hWndMain, (HMENU)SAVE_FILE_BTN, nullptr, nullptr);
 InvalidateRect(saveFileBtn, NULL, TRUE);
 UpdateWindow(saveFileBtn);

 hScrollContainer = CreateWindowEx(WS_EX_CLIENTEDGE, L"SCROLLBAR", NULL,
 WS_CHILD | WS_VISIBLE | WS_VSCROLL | SBS_VERT,
 170, 40, 600, 300,
 g_hWndMain, (HMENU)SCROLL_CONTAINER, g_hInstance, NULL);


 hEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", NULL,
 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
 0, 0, 600, 300,
 hScrollContainer, (HMENU)EDIT_CONTROL, g_hInstance, NULL);
 InvalidateRect(hEditControl, NULL, TRUE);
 UpdateWindow(hEditControl);

 SetFocus(hEditControl);

 SetScrollRange(hScrollContainer, SB_VERT, 0, 5, TRUE);
 SetScrollPos(hScrollContainer, SB_VERT, 0, TRUE);

 // Add embolden button
 emboldenBtn = CreateWindow(L"BUTTON", L"Embolden",
 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
 10, 120, 100, 25,
 g_hWndMain, (HMENU)EMBOLDEN_BTN, nullptr, nullptr);
 InvalidateRect(emboldenBtn, NULL, TRUE);
 UpdateWindow(emboldenBtn);

 // Add italicise button
 italiciseBtn = CreateWindow(L"BUTTON", L"Italicise",
 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
 10, 150, 100, 25,
 g_hWndMain, (HMENU)ITALICISE_BTN, nullptr, nullptr);
 InvalidateRect(italiciseBtn, NULL, TRUE);
 UpdateWindow(italiciseBtn);
 }
 else if (tabIndex == 2) {
 DestroyWindow(hRow);
 DestroyWindow(tableContainer);
 DestroyWindow(tblHeaderOne);
 DestroyWindow(tblHeaderTwo);
 DestroyWindow(tblHeaderThree);
 DestroyWindow(addRowBtn);
 DestroyWindow(openFileBtn);
 DestroyWindow(saveFileBtn);
 DestroyWindow(emboldenBtn);
 DestroyWindow(italiciseBtn);
 DestroyWindow(hEditControl);
 DestroyWindow(hScrollContainer);

 // Create container for player
 hWMPContainer = CreateWindowEx(WS_EX_CLIENTEDGE, L"STATIC", nullptr,
 WS_CHILD | WS_VISIBLE | SS_CENTER | SS_GRAYFRAME,
 50, 50, 700, 400,
 g_hWndMain, nullptr, g_hInstance, nullptr);

 // Create Open .mp4/.mov button
 OpenMp4Btn = CreateWindow(L"BUTTON", L"Open .mp4/.mov",
 WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
 50, 460, 150, 30,
 g_hWndMain, (HMENU)FILEMENU_OPEN_FILE_BTN, nullptr, nullptr);
 InvalidateRect(OpenMp4Btn, nullptr, TRUE);
 UpdateWindow(OpenMp4Btn);


 // Create play/pause button
 hPlayBtn = CreateWindow(L"BUTTON", L"Play",
 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
 350, 460, 100, 30,
 g_hWndMain, nullptr, g_hInstance, nullptr);
 InvalidateRect(hPlayBtn, nullptr, TRUE);
 UpdateWindow(hPlayBtn);

 }
 }
 return DefWindowProc(hwnd, msg, wParam, lParam);
 break;
 case WM_MOUSEWHEEL:
 //also WIP, will be developed after WM_VSCROLL is established
 break;
 case WM_VSCROLL:
 //to be developed 9516555
 case WM_PAINT:
 break;
 case WM_COMMAND:
 //all commands passed to the window through buttons, menus, forms, etc.
 if (HIWORD(wParam) == BN_CLICKED) {
 if ((HWND)lParam == addRowBtn) {
 const wchar_t* ROW_CLASS_NAME = L"Row Window";
 WNDCLASS rowWc{};
 rowWc.hInstance = g_hInstance;
 rowWc.lpszClassName = ROW_CLASS_NAME;
 rowWc.hCursor = LoadCursor(nullptr, IDC_ARROW);
 rowWc.hbrBackground = (HBRUSH)COLOR_WINDOW;
 rowWc.lpfnWndProc = AddRowDlgProc;
 RegisterClass(&rowWc);

 hWnd = CreateWindow(ROW_CLASS_NAME, L"Row Window",
 WS_OVERLAPPEDWINDOW,
 CW_USEDEFAULT, CW_USEDEFAULT,
 250, 200,
 nullptr, nullptr, nullptr, nullptr);

 // Create text box controls
 hWndCell1Label = CreateWindowW(
 L"STATIC", L"Cell 1:",
 WS_CHILD | WS_VISIBLE | SS_LEFT,
 10, 10, 50, 20,
 hWnd, NULL, g_hInstance, NULL);


 hWndCell1Edit = CreateWindowW(
 L"EDIT", NULL,
 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
 65, 10, 100, 20,
 hWnd, NULL, g_hInstance, NULL);


 hWndCell2Label = CreateWindowW(
 L"STATIC", L"Cell 2:",
 WS_CHILD | WS_VISIBLE | SS_LEFT,
 10, 40, 50, 20,
 hWnd, NULL, g_hInstance, NULL);


 hWndCell2Edit = CreateWindowW(
 L"EDIT", NULL,
 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
 65, 40, 100, 20,
 hWnd, NULL, g_hInstance, NULL);

 hWndCell3Label = CreateWindowW(
 L"STATIC", L"Cell 3:",
 WS_CHILD | WS_VISIBLE | SS_LEFT,
 10, 70, 50, 20,
 hWnd, NULL, g_hInstance, NULL);


 hWndCell3Edit = CreateWindowW(
 L"EDIT", NULL,
 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
 65, 70, 100, 20,
 hWnd, NULL, g_hInstance, NULL);


 // Create OK and Cancel button controls
 hWndOkButton = CreateWindowW(
 L"BUTTON", L"OK",
 WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
 40, 110, 50, 25,
 hWnd, (HMENU)IDOK, g_hInstance, NULL);


 hWndCancelButton = CreateWindowW(
 L"BUTTON", L"Cancel",
 WS_CHILD | WS_VISIBLE,
 100, 110, 50, 25,
 hWnd, (HMENU)IDCANCEL, g_hInstance, NULL);


 ShowWindow(hWnd, SW_SHOW);
 UpdateWindow(hWnd);

 MSG msg{};
 while (GetMessage(&msg, nullptr, 0, 0)) {
 TranslateMessage(&msg);
 DispatchMessage(&msg);
 }

 }
 if ((HWND)lParam == openFileBtn) {
 // Open File button clicked, show open file dialoge and load the selected file into the edit control
 OPENFILENAME ofn = { };
 WCHAR szFile[MAX_PATH] = L"";
 ofn.lStructSize = sizeof(OPENFILENAME);
 ofn.hwndOwner = hWnd;
 ofn.lpstrFilter = L"Text files\0*.txt\0All files\0*.*\0";
 ofn.lpstrFile = szFile;
 ofn.nMaxFile = MAX_PATH;
 ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
 if (GetOpenFileName(&ofn)) {
 // Read file and set text of edit box
 std::ifstream infile(ofn.lpstrFile, std::ios::in | std::ios::binary);
 if (infile) {
 std::wstring text((std::istreambuf_iterator<char>(infile)), std::istreambuf_iterator<char>());
 SetWindowText(hEditControl, text.c_str());
 filePath = ofn.lpstrFile;
 }
 }
 }
 if ((HWND)lParam == saveFileBtn) {
 if (!filePath.empty()) {
 std::wofstream outfile(filePath, std::ios::out | std::ios::binary); // use std::wofstream instead of std::ofstream
 if (outfile) {
 int textLength = GetWindowTextLength(hEditControl);
 if (textLength != 0) {
 wchar_t* textBuffer = new wchar_t[textLength + 1];
 GetWindowTextW(hEditControl, textBuffer, textLength + 1);
 outfile.write(textBuffer, textLength * sizeof(wchar_t));
 delete[] textBuffer;
 }
 }
 outfile.close();
 MessageBox(NULL, L"File saved successfully!", L"File save", MB_OK);
 }

 }
 //The following are not currently working due to an issue in connecting to the edit box for char type manipulation
 if ((HWND)lParam == emboldenBtn) {

 }
 if ((HWND)lParam == italiciseBtn) {

 }
 //cannot or failed to open video file 
 if ((HWND)lParam == OpenMp4Btn) {
 OPENFILENAMEA ofn = {};
 ofn.lStructSize = sizeof(ofn);
 ofn.hwndOwner = hwnd;
 ofn.lpstrFilter = "Video Files (*.mp4;*.mov)\0*.mp4;*.mov\0All Files (*.*)\0*.*\0";
 char szFile[MAX_PATH] = {};
 ofn.lpstrFile = szFile;
 ofn.nMaxFile = MAX_PATH;
 ofn.lpstrTitle = "Open Video File";
 ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
 if (GetOpenFileNameA(&ofn)) {
 // Initialize SDL
 SDL_Init(SDL_INIT_VIDEO);

 // Open the selected video file
 AVFormatContext* format_ctx = nullptr;
 if (avformat_open_input(&format_ctx, szFile, nullptr, nullptr) != 0) {
 // Error handling
 }

 // Retrieve stream information
 if (avformat_find_stream_info(format_ctx, nullptr) < 0) {
 // Error handling
 }

 // Find the video and audio streams
 int video_stream_idx = av_find_best_stream(format_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);
 int audio_stream_idx = av_find_best_stream(format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0);

 // Open the video and audio codecs
 AVCodecContext* video_codec_ctx = avcodec_alloc_context3(nullptr);
 avcodec_parameters_to_context(video_codec_ctx, format_ctx->streams[video_stream_idx]->codecpar);
 AVCodec* video_codec = const_cast(avcodec_find_decoder(video_codec_ctx->codec_id));
 if (avcodec_open2(video_codec_ctx, video_codec, nullptr) < 0) {
 // Error handling
 }

 AVCodecContext* audio_codec_ctx = avcodec_alloc_context3(nullptr);
 avcodec_parameters_to_context(audio_codec_ctx, format_ctx->streams[audio_stream_idx]->codecpar);
 AVCodec* audio_codec = const_cast(avcodec_find_decoder(audio_codec_ctx->codec_id));
 if (avcodec_open2(audio_codec_ctx, audio_codec, nullptr) < 0) {
 // Error handling
 }
 // Allocate memory for the video and audio frames
 AVFrame* video_frame = av_frame_alloc();
 AVFrame* audio_frame = av_frame_alloc();

 // Create a window for displaying the video frames
 SDL_Window* window = SDL_CreateWindow("Video Player", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, video_codec_ctx->width, video_codec_ctx->height, SDL_WINDOW_SHOWN);

 // Create a renderer for displaying the video frames
 SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0);

 // Create a texture for displaying the video frames
 SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_BGR24, SDL_TEXTUREACCESS_STREAMING, video_codec_ctx->width, video_codec_ctx->height);

 // Create a scaling context for converting the video frames to RGB
 SwsContext* sws_ctx = sws_getContext(video_codec_ctx->width, video_codec_ctx->height, video_codec_ctx->pix_fmt,
 video_codec_ctx->width, video_codec_ctx->height, AV_PIX_FMT_BGR24,
 SWS_BILINEAR, nullptr, nullptr, nullptr);

 // Decode and display the video frames
 AVPacket packet;
 while (av_read_frame(format_ctx, &packet) >= 0) {
 if (packet.stream_index == video_stream_idx) {
 avcodec_send_packet(video_codec_ctx, &packet);
 while (avcodec_receive_frame(video_codec_ctx, video_frame) == 0) {
 sws_scale(sws_ctx, video_frame->data, video_frame->linesize, 0, video_codec_ctx->height,
 video_frame->data, video_frame->linesize);
 SDL_UpdateTexture(texture, NULL, video_frame->data[0], video_frame->linesize[0]);
 SDL_RenderClear(renderer);
 SDL_RenderCopy(renderer, texture, NULL, NULL);
 SDL_RenderPresent(renderer);
 }
 }
 av_packet_unref(&packet);
 }

 // Free the allocated memory and close the codecs
 av_frame_free(&video_frame);
 av_frame_free(&audio_frame);
 avcodec_free_context(&video_codec_ctx);
 avcodec_free_context(&audio_codec_ctx);
 avformat_close_input(&format_ctx);

 // Destroy the window, renderer, and texture
 SDL_DestroyTexture(texture);
 SDL_DestroyRenderer(renderer);
 SDL_DestroyWindow(window);

 // Quit SDL
 SDL_Quit();
 }
 }
 }
 break;
 case WM_DESTROY:
 //code that executes on window destruction
 PostQuitMessage(0);
 return 0;
 default:
 return DefWindowProc(hwnd, msg, wParam, lParam);
 }
}
</char></char>


I am doing this on MVSC2022 in a C++ win32 application if it's relevant, I will attach some images of the video : some of the videosome more of the videoA screenshot of the output screen


-
FFmpeg : MD5 hash of M3U8 playlists generated from same input video with different segment durations (after applying video filter) don't match
30 juillet 2020, par Saurabh P BhandariHere are a few commands I am using to convert and transize a video in MP4 format to a M3U8 playlist.


For a given input video (MP4 format), generate multiple video segments with segment duration 30 seconds.


ffmpeg -loglevel error -i input.mp4 -dn -sn -an -c:v copy -bsf:v h264_mp4toannexb -copyts -start_at_zero -f segment -segment_time 30 30%03d.mp4 -dn -sn -vn -c:a copy audio.aac



Apply a video filter (in this case scaling) on each segment and convert it to a M3U8 format.


ls 30*.mp4 | parallel 'ffmpeg -loglevel error -i {} -vf scale=-2:144 -hls_list_size 0 {}.m3u8'



Store the list of m3u8 files generated in
list.txt
in this formatfile 'segment-name.m3u8'


for f in 30*.m3u8; do echo "file '$f'" >> list.txt; done



Using concat demuxer, combine all segment files (which are in M3U8 format) and the audio to get one final m3u8 playlist pointing to segments with duration of 10 seconds.


ffmpeg -loglevel error -f concat -i list.txt -i audio.aac -c copy -hls_list_size 0 -hls_time 10 output_30.m3u8




I can change the segment duration in the first step from 30 seconds to 60 seconds, and compare the MD5 hash of the final M3U8 playlist generated in both the cases using this command :


ffmpeg -loglevel error -i <input m3u8="m3u8" playlist="playlist" /> -f md5 -



The MD5 hash of the output files differ, i.e., video streams of
output_30.m3u8
andoutput_60.m3u8
are not the same.

Can anyone elaborate on this ?


(I expected the MD5 hash to be the same)