Recherche avancée

Médias (91)

Sur d’autres sites (335)

  • File conversion to mp3 returning failure everytime using flutter package ffmpeg_kit_flutter

    7 mai, par Sanath balthar

    I am trying to convert an audio file generated from flutter "text to speech" package to mp3 file but it is failing everytime.
I have written the below code for file conversion. The conversion fails everytime. I have imported the package ffmpeg_kit_flutter. It doesnt even show why the conversion is failing.
I have looked up in stackoverflow and other sites but could not find any relevant solutions. I am using vscode as editor. I have attached flutter doctor output below as well. Could anyone please guide me ? Let me know if you need more information.

    


    List<string> command = [&#xA;              &#x27;-i&#x27;, audiofilepath,&#xA;              &#x27;-c:a&#x27;, &#x27;lame&#x27;,&#xA;              &#x27;$filePath/999.mp3&#x27;&#xA;            ];&#xA;&#xA; await FFmpegKitConfig.enableLogs();&#xA;            FFmpegKitConfig.enableLogCallback((log) =>print(&#x27;FFmpeg log: $log&#x27;));        &#xA;          FFmpegSession result = await FFmpegKit.executeWithArguments(command);&#xA;          dynamic resultcode = await result.getReturnCode();&#xA;          dynamic resultlogs = await result.getLogsAsString();&#xA;          // FFmpegKitConfig.setLogLevel(logLevel)&#xA;          if(ReturnCode.isSuccess(resultcode)){&#xA;          print("file saved after conversion at $filePath/999.mp3 and result : Success and logs : $resultlogs");&#xA;          }&#xA;          else{&#xA;            print("file saved after conversion at $filePath/999.mp3 and result : failure and logs : $resultlogs");&#xA;          }&#xA;&#xA;Flutter doctor output:&#xA;[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3296], locale en-IN)&#xA;[√] Windows Version (Installed version of Windows is version 10 or higher)&#xA;[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)&#xA;[√] Chrome - develop for the web&#xA;[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.5)&#xA;X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C&#x2B;&#x2B;"&#xA;workload, and include these components:&#xA;MSVC v142 - VS 2019 C&#x2B;&#x2B; x64/x86 build tools&#xA;- If there are multiple build tool versions available, install the latest&#xA;C&#x2B;&#x2B; CMake tools for Windows&#xA;Windows 10 SDK&#xA;[√] Android Studio (version 2023.2)&#xA;[√] VS Code (version 1.89.0)&#xA;[√] Connected device (3 available)&#xA;[√] Network resources&#xA;&#xA;! Doctor found issues in 1 category.&#xA;&#xA;</string>

    &#xA;

    Edit : Attaching error logs from the getLogsAsString() function :

    &#xA;

     I/flutter (20432): Result : failure and logs : ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers&#xA;I/flutter (20432):   built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)&#xA;I/flutter (20432):   configuration: --cross-prefix=aarch64-linux-android- --sysroot=/Users/sue/Library/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/darwin-x86_64/sysroot --prefix=/Users/sue/Projects/arthenica/ffmpeg-kit/prebuilt/android-arm64/ffmpeg --pkg-config=/opt/homebrew/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --ar=aarch64-linux-android-ar --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang&#x2B;&#x2B; --ranlib=aarch64-linux-android-ranlib --strip=aarch64-linux-android-strip --nm=aarch64-linux-android-nm --extra-libs=&#x27;-L/Users/sue/Projects/arthenica/ffmpeg-kit/prebuilt/android-arm64/cpu-features/lib -lndk_compat&#x27; --disable-autodetect --enable-cross-compile   &#xA;

    &#xA;

  • FFmpeg uses xface to merge videos without transition effects

    30 avril, par soapbar

    ffmpeg -i ./first.mp4 -i ./first.mp4 -filter_complex "xfade=transition=circlecrop:duration=1:offset=4,format=yuv420p" -y output.mp4

    &#xA;

    FFMPEG version 6.1.1, the video is generated normally without any error prompts, but the generated video does not have any transition effects.

    &#xA;

    output

    &#xA;

    &#xA;ffmpeg version 6.1.1-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with Apple clang version 11.0.0 (clang-1100.0.33.17)&#xA;  configuration : —cc=/usr/bin/clang —prefix=/opt/ffmpeg —extra-version=tessus —enable-avisynth —enable-fontconfig —enable-gpl —enable-libaom —enable-libass —enable-libbluray —enable-libdav1d —enable-libfreetype —enable-libgsm —enable-libmodplug —enable-libmp3lame —enable-libmysofa —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libopenh264 —enable-libopenjpeg —enable-libopus —enable-librubberband —enable-libshine —enable-libsnappy —enable-libsoxr —enable-libspeex —enable-libtheora —enable-libtwolame —enable-libvidstab —enable-libvmaf —enable-libvo-amrwbenc —enable-libvorbis —enable-libvpx —enable-libwebp —enable-libx264 —enable-libx265 —enable-libxavs —enable-libxml2 —enable-libxvid —enable-libzimg —enable-libzmq —enable-libzvbi —enable-version3 —pkg-config-flags=—static —disable-ffplay&#xA;  libavutil      58. 29.100 / 58. 29.100&#xA;  libavcodec     60. 31.102 / 60. 31.102&#xA;  libavformat    60. 16.100 / 60. 16.100&#xA;  libavdevice    60.  3.100 / 60.  3.100&#xA;  libavfilter     9. 12.100 /  9. 12.100&#xA;  libswscale      7.  5.100 /  7.  5.100&#xA;  libswresample   4. 12.100 /  4. 12.100&#xA;  libpostproc    57.  3.100 / 57.  3.100&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './first.mp4' :&#xA;  Metadata :&#xA;    major_brand : isom&#xA;    minor_version : 512&#xA;    compatible_brands : isomiso2avc1mp41&#xA;    encoder : Lavf61.1.100&#xA;  Duration : 00:00:05.00, start : 0.000000, bitrate : 110 kb/s&#xA;  Stream #0:0[0x1](und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1920 [SAR 4095:4096 DAR 36855:65536], 109 kb/s, SAR 14317:14320 DAR 128853:229120, 0.20 fps, 0.20 tbr, 16384 tbn (default)&#xA;    Metadata :&#xA;      handler_name : VideoHandler&#xA;      vendor_id : [0][0][0][0]&#xA;      encoder : Lavc61.3.100 libx264&#xA;Input #1, mov,mp4,m4a,3gp,3g2,mj2, from './first.mp4' :&#xA;  Metadata :&#xA;    major_brand : isom&#xA;    minor_version : 512&#xA;    compatible_brands : isomiso2avc1mp41&#xA;    encoder : Lavf61.1.100&#xA;  Duration : 00:00:05.00, start : 0.000000, bitrate : 110 kb/s&#xA;  Stream #1:0[0x1](und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1920 [SAR 4095:4096 DAR 36855:65536], 109 kb/s, SAR 14317:14320 DAR 128853:229120, 0.20 fps, 0.20 tbr, 16384 tbn (default)&#xA;    Metadata :&#xA;      handler_name : VideoHandler&#xA;      vendor_id : [0][0][0][0]&#xA;      encoder : Lavc61.3.100 libx264&#xA;Stream mapping :&#xA;  Stream #0:0 (h264) -> xfade&#xA;  Stream #1:0 (h264) -> xfade&#xA;  format:default -> Stream #0:0 (libx264)&#xA;Press [q] to stop, [?] for help&#xA;[libx264 @ 0x7f9f99fc87c0] using SAR=4095/4096&#xA;[libx264 @ 0x7f9f99fc87c0] using cpu capabilities : MMX2 SSE2Fast SSSE3 SSE4.2&#xA;[libx264 @ 0x7f9f99fc87c0] profile High, level 4.0, 4:2:0, 8-bit&#xA;[libx264 @ 0x7f9f99fc87c0] 264 - core 164 r3172 c1c9931 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options : cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;Output #0, mp4, to 'output.mp4' :&#xA;  Metadata :&#xA;    major_brand : isom&#xA;    minor_version : 512&#xA;    compatible_brands : isomiso2avc1mp41&#xA;    encoder : Lavf60.16.100&#xA;  Stream #0:0 : Video : h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 1080x1920 [SAR 14317:14320 DAR 128853:229120], q=2-31, 0.20 fps, 16384 tbn&#xA;    Metadata :&#xA;      encoder : Lavc60.31.102 libx264&#xA;    Side data :&#xA;      cpb : bitrate max/min/avg : 0/0/0 buffer size : 0 vbv_delay : N/A&#xA;[out#0/mp4 @ 0x7f9f99fc74c0] video:72kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead : 1.190217%&#xA;frame=    2 fps=0.0 q=-1.0 Lsize=      73kB time=00:00:05.00 bitrate= 118.9kbits/s speed=45.5x    &#xA;[libx264 @ 0x7f9f99fc87c0] frame I:1     Avg QP:12.25  size : 72527&#xA;[libx264 @ 0x7f9f99fc87c0] frame P:1     Avg QP:13.77  size :   216&#xA;[libx264 @ 0x7f9f99fc87c0] mb I  I16..4 : 51.4% 34.9% 13.8%&#xA;[libx264 @ 0x7f9f99fc87c0] mb P  I16..4 :  0.0%  0.0%  0.0%  P16..4 :  0.8%  0.0%  0.0%  0.0%  0.0%    skip:99.2%&#xA;[libx264 @ 0x7f9f99fc87c0] 8x8 transform intra:34.9% inter:0.0%&#xA;[libx264 @ 0x7f9f99fc87c0] coded y,uvDC,uvAC intra : 9.2% 9.6% 6.9% inter : 0.0% 0.6% 0.0%&#xA;[libx264 @ 0x7f9f99fc87c0] i16 v,h,dc,p : 79% 20%  2%  0%&#xA;[libx264 @ 0x7f9f99fc87c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu :  1% 97%  2%  0%  0%  0%  0%  0%  0%&#xA;[libx264 @ 0x7f9f99fc87c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu : 36% 32% 10%  3%  3%  3%  4%  3%  4%&#xA;[libx264 @ 0x7f9f99fc87c0] i8c dc,h,v,p : 80% 15%  4%  0%&#xA;[libx264 @ 0x7f9f99fc87c0] Weighted P-Frames : Y:0.0% UV:0.0%&#xA;[libx264 @ 0x7f9f99fc87c0] kb/s:58.19&#xA;

    &#xA;

  • FFmpeg - record from stream terminating unexpectedly using kokorin/Jaffree ffmpeg wrapper for Java

    18 avril, par pyrmon

    I am programming a Spring Boot Application using Maven and Java 21. I am trying to record a stream from a url and save it to a mkv file. I intend to do this with kokorin/Jaffree in version 2023.09.10. The recording seems to work ok, however longer videos are terminating unexpectedly. Sometimes after 5 minutes, other times an hour or even longer. Sometimes with Exit Code 0 and sometimes with 1.

    &#xA;

    I have implemented the recording like this :

    &#xA;

    @Override&#xA;    public void startRecording(RecordingSchedule recordingSchedule) {&#xA;        logger.info("Starting recording for schedule with filename {}", recordingSchedule.getFileName());&#xA;&#xA;        String m3uUrl = recordingSchedule.getM3uUrl();&#xA;        LocalDateTime endTime = timeUtils.parseStringToLocalDateTime(recordingSchedule.getEndTime());&#xA;        LocalDateTime stopTime = endTime.plusSeconds(20);&#xA;        String timeToRecord = timeUtils.calculateTimeToRecord(stopTime);&#xA;        Path outputPath = Paths.get("/recordings/" &#x2B; recordingSchedule.getFileName());&#xA;&#xA;        try {&#xA;            FFmpeg.atPath()&#xA;                  .addInput(UrlInput.fromUrl(m3uUrl))&#xA;                  .addArgument("-xerror")&#xA;                  .addArguments("-reconnect", "5")&#xA;                  .addArguments("-reconnect_streamed", "5")&#xA;                  .addArguments("-reconnect_delay_max", "20")&#xA;                  .addArguments("-t", timeToRecord)&#xA;                  .addArguments("-c", "copy")&#xA;                  .addOutput(&#xA;                      UrlOutput.toPath(outputPath))&#xA;                  .setLogLevel(LogLevel.WARNING)&#xA;                  .execute();&#xA;            logger.info("Recording complete. Output file: {}", outputPath.toAbsolutePath());&#xA;        } catch (Exception e) {&#xA;            logger.error("Error recording M3U stream {}: {}", recordingSchedule.getFileName(), e.getMessage());&#xA;        }&#xA;    }&#xA;

    &#xA;

    And I am calling the method like this :&#xA;executorConfig.executorService().submit(() -> ffmpegService.startRecording(recording));

    &#xA;

    Any ideas what I am doing wrong ?&#xA;Here are the log lines at the beginning and end of recording of the past two attempts :

    &#xA;

    2024-04-18T00:54:48.689&#x2B;02:00  INFO 1 --- [pool-2-thread-1] m.s.r.service.impl.FfmpegServiceImpl     : Starting recording for schedule with filename Example1.mkv&#xA;2024-04-18T00:54:48.697&#x2B;02:00  WARN 1 --- [pool-2-thread-1] c.github.kokorin.jaffree.ffmpeg.FFmpeg   : ProgressListener isn&#x27;t set, progress won&#x27;t be reported&#xA;2024-04-18T00:54:48.698&#x2B;02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Command constructed:&#xA;ffmpeg -loglevel level&#x2B;warning -i http://example.stream.url.com -n -xerror -reconnect 5 -reconnect_streamed 5 -reconnect_delay_max 20 -t 10771 -c copy /recordings/Example1.mkv&#xA;2024-04-18T00:54:48.698&#x2B;02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Starting process: ffmpeg&#xA;2024-04-18T00:54:48.701&#x2B;02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Waiting for process to finish&#xA;2024-04-18T01:31:02.633&#x2B;02:00  WARN 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [h264 @ 0x559cd22dd940] [warning] Increasing reorder buffer to 2&#xA;2024-04-18T01:31:02.633&#x2B;02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Process has finished with status: 0&#xA;2024-04-18T01:31:02.734&#x2B;02:00  INFO 1 --- [pool-2-thread-1] m.s.r.service.impl.FfmpegServiceImpl     : Recording complete. Output file: /recordings/Example1.mkv&#xA;&#xA;2024-04-18T03:54:48.678&#x2B;02:00  INFO 1 --- [pool-2-thread-2] m.s.r.service.impl.FfmpegServiceImpl     : Starting recording for schedule with filename Example2.mkv&#xA;2024-04-18T03:54:48.678&#x2B;02:00  WARN 1 --- [pool-2-thread-2] c.github.kokorin.jaffree.ffmpeg.FFmpeg   : ProgressListener isn&#x27;t set, progress won&#x27;t be reported&#xA;2024-04-18T03:54:48.678&#x2B;02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Command constructed:&#xA;ffmpeg -loglevel level&#x2B;warning -i http://example.stream.url.com/ -n -xerror -reconnect 5 -reconnect_streamed 5 -reconnect_delay_max 20 -t 11431 -c copy /recordings/Example2.mkv&#xA;2024-04-18T03:54:48.678&#x2B;02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Starting process: ffmpeg&#xA;2024-04-18T03:54:48.679&#x2B;02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Waiting for process to finish&#xA;2024-04-18T04:57:22.256&#x2B;02:00  WARN 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [h264 @ 0x55707ba988c0] [warning] Increasing reorder buffer to 3&#xA;2024-04-18T04:58:47.455&#x2B;02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [NULL @ 0x55707ba988c0] [error] Picture timing SEI payload too large&#xA;2024-04-18T04:58:47.456&#x2B;02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [NULL @ 0x55707ba988c0] [error] non-existing PPS 1 referenced&#xA;2024-04-18T04:58:47.456&#x2B;02:00  WARN 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [matroska @ 0x55707ba9a380] [warning] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly&#xA;2024-04-18T04:58:47.456&#x2B;02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [matroska @ 0x55707ba9a380] [error] Can&#x27;t write packet with unknown timestamp&#xA;2024-04-18T04:58:47.463&#x2B;02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [error] av_interleaved_write_frame(): Invalid argument&#xA;2024-04-18T04:58:47.463&#x2B;02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Process has finished with status: 1&#xA;2024-04-18T04:58:47.564&#x2B;02:00 ERROR 1 --- [pool-2-thread-2] m.s.r.service.impl.FfmpegServiceImpl     : Error recording M3U stream Example2.mkv: Process execution has ended with non-zero status: 1. Check logs for detailed error message.&#xA;

    &#xA;

    They were supposed to run nearly 3 hours and the other one over 3 hours. And with the timestamps you can see that they are not running nearly as long.&#xA;Thank you for your help !

    &#xA;