Recherche avancée

Médias (0)

Mot : - Tags -/interaction

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (20)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

Sur d’autres sites (6434)

  • Record Audio using ALSA in mp4 format

    18 novembre 2024, par teena meheren

    I am working on to record audio using ALSA library. I am able to record the audio using the same library in .wav file, but what I need is to record an .mp4 file. For that I initialize the FFmpeg encoder to create MP4 file and trying to record the audio by writing the audio frames into the file. The result which I am getting is an empty MP4 file with no audio.

    


    Here I am attaching the code which I have tried

    


    #include &#xA;#include &#xA;#include &#xA;#include <alsa></alsa>asoundlib.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libswresample></libswresample>swresample.h>&#xA;&#xA;int terminate = 0;&#xA;int channels = 2;&#xA;&#xA;// Function to handle termination signal&#xA;void sigint_handler(int sig) {&#xA;    terminate = 1;&#xA;}&#xA;&#xA;// Function to initialize the FFmpeg encoder and writer&#xA;AVFormatContext* init_ffmpeg_writer(const char *filename, AVCodecContext **audio_codec_ctx) {&#xA;    AVFormatContext *fmt_ctx = NULL;&#xA;    AVCodec *audio_codec = NULL;&#xA;    AVStream *audio_stream = NULL;&#xA;&#xA;    // Initialize the output format context&#xA;    if (avformat_alloc_output_context2(&amp;fmt_ctx, NULL, "mp4", filename) &lt; 0) {&#xA;        fprintf(stderr, "Could not create output context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Find the codec&#xA;    audio_codec = avcodec_find_encoder(AV_CODEC_ID_AAC);&#xA;    if (!audio_codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Create a new stream&#xA;    audio_stream = avformat_new_stream(fmt_ctx, audio_codec);&#xA;    if (!audio_stream) {&#xA;        fprintf(stderr, "Could not create audio stream\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Set up codec context&#xA;    *audio_codec_ctx = avcodec_alloc_context3(audio_codec);&#xA;    (*audio_codec_ctx)->channels = 2;&#xA;    (*audio_codec_ctx)->channel_layout = AV_CH_LAYOUT_STEREO;&#xA;    (*audio_codec_ctx)->sample_rate = 44100;&#xA;    (*audio_codec_ctx)->sample_fmt = AV_SAMPLE_FMT_FLTP; // 32-bit float for input format&#xA;    (*audio_codec_ctx)->bit_rate = 128000; // Bitrate for AAC encoding&#xA;&#xA;    // Open the codec&#xA;    if (avcodec_open2(*audio_codec_ctx, audio_codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Copy codec parameters from codec context to the stream&#xA;    if (avcodec_parameters_from_context(audio_stream->codecpar, *audio_codec_ctx) &lt; 0) {&#xA;        fprintf(stderr, "Could not copy codec parameters\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Open the output file&#xA;    if (!(fmt_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        if (avio_open(&amp;fmt_ctx->pb, filename, AVIO_FLAG_WRITE) &lt; 0) {&#xA;            fprintf(stderr, "Could not open output file\n");&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;&#xA;    // Write the file header&#xA;    if (avformat_write_header(fmt_ctx, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error occurred when writing header\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    return fmt_ctx;&#xA;}&#xA;&#xA;void write_audio_frame(AVFormatContext *fmt_ctx, AVCodecContext *audio_codec_ctx, uint8_t *buffer, int buffer_size) {&#xA;    AVPacket pkt;&#xA;    AVFrame *frame;&#xA;    int ret;&#xA;    static int64_t frame_count = 0; // Ensure this is initialized correctly&#xA;    static double stream_time = 0;&#xA;&#xA;    // Initialize the packet&#xA;    av_init_packet(&amp;pkt);&#xA;    pkt.data = NULL;&#xA;    pkt.size = 0;&#xA;&#xA;    // Allocate and set up frame&#xA;    frame = av_frame_alloc();&#xA;    frame->nb_samples = audio_codec_ctx->frame_size;&#xA;    frame->channel_layout = audio_codec_ctx->channel_layout;&#xA;    frame->format = audio_codec_ctx->sample_fmt;&#xA;    frame->sample_rate = audio_codec_ctx->sample_rate;&#xA;&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Could not allocate frame buffer\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Initialize swresample context&#xA;    SwrContext *swr_ctx = swr_alloc();&#xA;    av_opt_set_int(swr_ctx, "in_channel_layout", frame->channel_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "out_channel_layout", frame->channel_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "in_sample_rate", 44100, 0);&#xA;    av_opt_set_int(swr_ctx, "out_sample_rate", 44100, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);&#xA;&#xA;    if (swr_init(swr_ctx) &lt; 0) {&#xA;        fprintf(stderr, "Error initializing swresample context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Calculate the number of samples based on buffer size and format&#xA;    int num_samples = buffer_size / (2 * channels); // 2 bytes per sample (S16)&#xA;    uint8_t *out_buffer = (uint8_t *)malloc(num_samples * 4); // 4 bytes per sample (float)&#xA;&#xA;    // Resample audio data&#xA;    ret = swr_convert(swr_ctx, &amp;out_buffer, num_samples, (const uint8_t **)&amp;buffer, num_samples);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error during resampling\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Copy resampled data to the frame&#x27;s buffer&#xA;    int out_size = num_samples * av_get_bytes_per_sample(audio_codec_ctx->sample_fmt);&#xA;    memcpy(frame->data[0], out_buffer, out_size);&#xA;&#xA;    if (frame->data[0] == NULL) {&#xA;        fprintf(stderr, "Frame data is NULL\n");&#xA;    }&#xA;&#xA;    // Set timestamps for the packet&#xA;    pkt.pts = pkt.dts = (frame_count * audio_codec_ctx->frame_size * AV_TIME_BASE) / audio_codec_ctx->sample_rate;&#xA;    stream_time &#x2B;= (double)frame->nb_samples / audio_codec_ctx->sample_rate;&#xA;&#xA;    // Send the frame for encoding&#xA;    ret = avcodec_send_frame(audio_codec_ctx, frame);&#xA;    if (ret &lt; 0) {&#xA;        if (ret == AVERROR(EAGAIN)) {&#xA;            // Encoder is temporarily unavailable, wait or retry&#xA;            fprintf(stderr, "Encoder temporarily unavailable, retrying...\n");&#xA;            return;&#xA;        } else {&#xA;            // Another error occurred&#xA;            fprintf(stderr, "Error sending audio frame to encoder: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;&#xA;    // Receive the encoded packet&#xA;    ret = avcodec_receive_packet(audio_codec_ctx, &amp;pkt);&#xA;    if (ret &lt; 0) {&#xA;        if (ret == AVERROR(EAGAIN)) {&#xA;            // No packet is available yet, maybe retry later&#xA;            fprintf(stderr, "No packet available, retrying...\n");&#xA;            return;&#xA;        } else {&#xA;            fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;&#xA;    pkt.stream_index = 0;&#xA;&#xA;    // Write the packet to the output&#xA;    ret = av_interleaved_write_frame(fmt_ctx, &amp;pkt);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error while writing frame\n");&#xA;        exit(1);&#xA;    }else if (ret==0){&#xA;&#xA;    printf("Writing frames successfully\n");&#xA;}&#xA;&#xA;    // Clean up&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_unref(&amp;pkt);&#xA;    free(out_buffer);&#xA;&#xA;    frame_count&#x2B;&#x2B;;  // Increment the frame count to track timestamps&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;int main() {&#xA;    snd_pcm_t *capture_handle;&#xA;    snd_pcm_hw_params_t *hw_params;&#xA;    int err;&#xA;    unsigned int sample_rate = 44100;&#xA;    snd_pcm_uframes_t frames = 32;&#xA;    char *buffer;&#xA;    int buffer_size;&#xA;&#xA;    // Register signal handler for termination (Ctrl&#x2B;C)&#xA;    signal(SIGINT, sigint_handler);&#xA;&#xA;    // Open the PCM device for recording (capture)&#xA;    if ((err = snd_pcm_open(&amp;capture_handle, "default", SND_PCM_STREAM_CAPTURE, 0)) &lt; 0) {&#xA;        fprintf(stderr, "cannot open audio device %s (%s)\n", "default", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Allocate the hardware parameters structure&#xA;    if ((err = snd_pcm_hw_params_malloc(&amp;hw_params)) &lt; 0) {&#xA;        fprintf(stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Initialize the hardware parameters with default values&#xA;    if ((err = snd_pcm_hw_params_any(capture_handle, hw_params)) &lt; 0) {&#xA;        fprintf(stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Set the desired hardware parameters&#xA;    if ((err = snd_pcm_hw_params_set_access(capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) &lt; 0) {&#xA;        fprintf(stderr, "cannot set access type (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if ((err = snd_pcm_hw_params_set_format(capture_handle, hw_params, SND_PCM_FORMAT_S16_LE)) &lt; 0) {&#xA;        fprintf(stderr, "cannot set sample format (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if ((err = snd_pcm_hw_params_set_rate_near(capture_handle, hw_params, &amp;sample_rate, 0)) &lt; 0) {&#xA;        fprintf(stderr, "cannot set sample rate (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if ((err = snd_pcm_hw_params_set_channels(capture_handle, hw_params, channels)) &lt; 0) {&#xA;        fprintf(stderr, "cannot set channel count (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if ((err = snd_pcm_hw_params(capture_handle, hw_params)) &lt; 0) {&#xA;        fprintf(stderr, "cannot set parameters (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Free the hardware parameters structure&#xA;    snd_pcm_hw_params_free(hw_params);&#xA;&#xA;    // Prepare the PCM device for use&#xA;    if ((err = snd_pcm_prepare(capture_handle)) &lt; 0) {&#xA;        fprintf(stderr, "cannot prepare audio interface for use (%s)\n", snd_strerror(err));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Calculate buffer size&#xA;    buffer_size = frames * channels * 2; // 2 bytes/sample, 2 channels&#xA;    buffer = (char *) malloc(buffer_size);&#xA;&#xA;    // Initialize FFmpeg&#xA;    av_register_all();&#xA;&#xA;    // Initialize the output file and codec&#xA;    AVCodecContext *audio_codec_ctx = NULL;&#xA;    AVFormatContext *fmt_ctx = init_ffmpeg_writer("recorded_audio.mp4", &amp;audio_codec_ctx);&#xA;&#xA;    printf("Recording...\n");&#xA;&#xA;    // Record audio data until termination signal is received&#xA;    while (!terminate) {&#xA;        printf("entered while\n");&#xA;        if ((err = snd_pcm_readi(capture_handle, buffer, frames)) != frames) {&#xA;            fprintf(stderr, "read from audio interface failed (%s)\n", snd_strerror(err));&#xA;            exit(1);&#xA;        }&#xA;&#xA;        // Write audio frame to the MP4 file&#xA;        write_audio_frame(fmt_ctx, audio_codec_ctx, (uint8_t *)buffer, buffer_size);&#xA;    }&#xA;&#xA;    printf("Recording finished.\n");&#xA;&#xA;    // Write the file footer and close&#xA;    av_write_trailer(fmt_ctx);&#xA;    avcodec_free_context(&amp;audio_codec_ctx);&#xA;    avformat_close_input(&amp;fmt_ctx);&#xA;    avformat_free_context(fmt_ctx);&#xA;&#xA;    // Clean up ALSA resources&#xA;    snd_pcm_close(capture_handle);&#xA;    free(buffer);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    Here I am attaching the logs too

    &#xA;

    Recording...&#xA;entered while&#xA;No packet available, retrying...&#xA;entered while&#xA;[mp4 @ 0x611490ddeb40] 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;[mp4 @ 0x611490ddeb40] Encoder did not produce proper pts, making some up.&#xA;Writing frames successfully&#xA;entered while&#xA;Writing frames successfully&#xA;entered while&#xA;Writing frames successfully&#xA;entered while&#xA;Writing frames successfully&#xA;

    &#xA;

    Can anyone help me how to resolve the above error by setting up the timestamp properly and record audio in mp4 file using ALSA .

    &#xA;

  • Error initializing FFmpegKit : "TypeError : Cannot read property 'getLogLevel' of null" in React Native

    9 janvier, par Md Monirozzaman khan

    I'm developing a React Native application where I need to process videos using the ffmpeg-kit-react-native library. However, I'm encountering an issue during the initialization of FFmpegKitConfig. The error message is :

    &#xA;

    ERROR  Error initializing FFmpegKit: [TypeError: Cannot read property &#x27;getLogLevel&#x27; of null]&#xA;

    &#xA;

    Here is my App.js code

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    import React, { useState, useEffect } from &#x27;react&#x27;;&#xA;import { StyleSheet, Text, View, TouchableOpacity, Alert, Dimensions, ScrollView, LayoutAnimation, UIManager, Platform } from &#x27;react-native&#x27;;&#xA;import * as ImagePicker from &#x27;expo-image-picker&#x27;;&#xA;import * as FileSystem from &#x27;expo-file-system&#x27;;&#xA;import { Video } from &#x27;expo-av&#x27;;&#xA;import { MaterialIcons } from &#x27;@expo/vector-icons&#x27;;&#xA;import { FFmpegKit, FFmpegKitConfig, ReturnCode } from &#x27;ffmpeg-kit-react-native&#x27;;&#xA;&#xA;const windowWidth = Dimensions.get(&#x27;window&#x27;).width;&#xA;&#xA;if (Platform.OS === &#x27;android&#x27;) {&#xA;  UIManager.setLayoutAnimationEnabledExperimental &amp;&amp; UIManager.setLayoutAnimationEnabledExperimental(true);&#xA;}&#xA;&#xA;export default function App() {&#xA;  const [videoFiles, setVideoFiles] = useState([]);&#xA;  const [isGridView, setIsGridView] = useState(false);&#xA;  const [isConverting, setIsConverting] = useState(false);&#xA;&#xA;  useEffect(() => {&#xA;    FFmpegKitConfig.init()&#xA;      .then(() => {&#xA;        console.log(&#x27;FFmpegKit initialized&#x27;);&#xA;      })&#xA;      .catch((error) => {&#xA;        console.error(&#x27;Error initializing FFmpegKit:&#x27;, error);&#xA;      });&#xA;  }, []);&#xA;&#xA;  const pickVideo = async () => {&#xA;    const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();&#xA;    if (status !== &#x27;granted&#x27;) {&#xA;      alert(&#x27;Sorry, we need media library permissions to make this work!&#x27;);&#xA;      return;&#xA;    }&#xA;&#xA;    let result = await ImagePicker.launchImageLibraryAsync({&#xA;      mediaTypes: ImagePicker.MediaTypeOptions.Videos,&#xA;      allowsMultipleSelection: true,&#xA;    });&#xA;&#xA;    if (!result.canceled &amp;&amp; result.assets.length > 0) {&#xA;      const newFiles = result.assets.filter(&#xA;        (newFile) => !videoFiles.some((existingFile) => existingFile.uri === newFile.uri)&#xA;      );&#xA;&#xA;      if (newFiles.length &lt; result.assets.length) {&#xA;        Alert.alert(&#x27;Duplicate Files&#x27;, &#x27;Some files were already added.&#x27;);&#xA;      }&#xA;&#xA;      LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;      setVideoFiles([...videoFiles, ...newFiles]);&#xA;    }&#xA;  };&#xA;&#xA;  const convertVideos = async () => {&#xA;    setIsConverting(true);&#xA;    const outputDir = `${FileSystem.documentDirectory}Output`;&#xA;&#xA;    const dirInfo = await FileSystem.getInfoAsync(outputDir);&#xA;    if (!dirInfo.exists) {&#xA;      await FileSystem.makeDirectoryAsync(outputDir, { intermediates: true });&#xA;    }&#xA;&#xA;    for (const video of videoFiles) {&#xA;      const { uri } = video;&#xA;      const filename = uri.split(&#x27;/&#x27;).pop();&#xA;      const outputFilePath = `${outputDir}/${filename.split(&#x27;.&#x27;).slice(0, -1).join(&#x27;.&#x27;)}_modified.mp4`;&#xA;&#xA;      const ffmpegCommand = `-y -i "${uri}" -af "atempo=1.02, bass=g=4:f=80:w=3, treble=g=4:f=3200:w=3, firequalizer=gain_entry=&#x27;entry(0,0);entry(62,2);entry(125,1.5);entry(250,1);entry(500,1);entry(1000,1);entry(2000,1.5);entry(4000,2.5);entry(8000,3);entry(16000,4)&#x27;, compand=attacks=0.05:decays=0.25:points=-80/-80-50/-15-30/-10-10/-2:soft-knee=4:gain=2, deesser, highpass=f=35, lowpass=f=17000, loudnorm=I=-16:LRA=11:TP=-1.5, volume=3.9dB" -c:v copy -c:a aac -b:a 224k -ar 48000 -threads 0 "${outputFilePath}"`;&#xA;&#xA;      try {&#xA;        const session = await FFmpegKit.execute(ffmpegCommand);&#xA;        const returnCode = await session.getReturnCode();&#xA;&#xA;        if (ReturnCode.isSuccess(returnCode)) {&#xA;          console.log(`Video converted: ${outputFilePath}`);&#xA;        } else if (ReturnCode.isCancel(returnCode)) {&#xA;          console.log(&#x27;Conversion cancelled&#x27;);&#xA;        } else {&#xA;          console.error(`FFmpeg process failed: ${session.getFailStackTrace()}`);&#xA;        }&#xA;      } catch (error) {&#xA;        console.error(`Error converting video: ${error.message}`);&#xA;      }&#xA;    }&#xA;&#xA;    setIsConverting(false);&#xA;    Alert.alert(&#x27;Conversion Complete&#x27;, &#x27;All videos have been converted.&#x27;);&#xA;  };&#xA;&#xA;  const deleteVideo = (uri) => {&#xA;    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;    setVideoFiles(videoFiles.filter((video) => video.uri !== uri));&#xA;  };&#xA;&#xA;  const clearAllVideos = () => {&#xA;    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;    setVideoFiles([]);&#xA;  };&#xA;&#xA;  const toggleLayout = () => {&#xA;    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;    setIsGridView(!isGridView);&#xA;  };&#xA;&#xA;  return (&#xA;    <view style="{styles.container}">&#xA;      <text style="{styles.header}">Video Converter App</text>&#xA;      <touchableopacity style="{styles.addButton}">&#xA;        <text style="{styles.addButtonText}">Select or Browse Videos</text>&#xA;      </touchableopacity>&#xA;      <view style="{styles.headerContainer}">&#xA;        <text style="{styles.videoCount}">Total Videos: {videoFiles.length}</text>&#xA;        {videoFiles.length > 0 &amp;&amp; (&#xA;          &lt;>&#xA;            <touchableopacity style="{styles.clearButtonContainer}">&#xA;              <materialicons size="{24}" color="red" style="{styles.clearIcon}"></materialicons>&#xA;              <text style="{styles.clearAllText}">Clear All</text>&#xA;            </touchableopacity>&#xA;            <touchableopacity style="{styles.toggleLayoutButton}">&#xA;              <materialicons size="{24}" color="#fff"></materialicons>&#xA;            </touchableopacity>&#xA;          >&#xA;        )}&#xA;      </view>&#xA;      {isGridView ? (&#xA;        <scrollview contentcontainerstyle="{styles.gridContainer}">&#xA;          {videoFiles.map((item, index) => (&#xA;            <view key="{index}" style="{styles.videoItemGrid}">&#xA;              &#xA;              <touchableopacity>> deleteVideo(item.uri)} style={styles.deleteButtonGrid}>&#xA;                <materialicons size="{24}" color="red"></materialicons>&#xA;              </touchableopacity>&#xA;            </view>&#xA;          ))}&#xA;        </scrollview>&#xA;      ) : (&#xA;        <view style="{styles.list}">&#xA;          {videoFiles.map((item, index) => (&#xA;            <view key="{index}" style="{styles.videoItem}">&#xA;              &#xA;              <text style="{styles.fileName}">{decodeURI(item.fileName || item.uri.split(&#x27;/&#x27;).pop() || &#x27;Unknown File&#x27;)}</text>&#xA;              <touchableopacity>> deleteVideo(item.uri)} style={styles.deleteButton}>&#xA;                <materialicons size="{24}" color="red"></materialicons>&#xA;              </touchableopacity>&#xA;            </view>&#xA;          ))}&#xA;        </view>&#xA;      )}&#xA;      {videoFiles.length > 0 &amp;&amp; (&#xA;        <touchableopacity style="{styles.convertButton}" disabled="{isConverting}">&#xA;          <text style="{styles.convertButtonText}">{isConverting ? &#x27;Converting...&#x27; : &#x27;Convert&#x27;}</text>&#xA;        </touchableopacity>&#xA;      )}&#xA;    </view>&#xA;  );&#xA;}&#xA;&#xA;const styles = StyleSheet.create({&#xA;  container: {&#xA;    flex: 1,&#xA;    backgroundColor: &#x27;#fff&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    padding: 10,&#xA;  },&#xA;  header: {&#xA;    fontSize: 24,&#xA;    fontWeight: &#x27;bold&#x27;,&#xA;    marginBottom: 5,&#xA;  },&#xA;  addButton: {&#xA;    backgroundColor: &#x27;#007BFF&#x27;,&#xA;    padding: 15,&#xA;    borderRadius: 10,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    marginBottom: 5,&#xA;    width: &#x27;100%&#x27;,&#xA;    elevation: 2,&#xA;    shadowColor: &#x27;#000&#x27;,&#xA;    shadowOffset: { width: 0, height: 5 },&#xA;    shadowOpacity: 0.8,&#xA;    shadowRadius: 2,&#xA;  },&#xA;  addButtonText: {&#xA;    color: &#x27;#fff&#x27;,&#xA;    fontSize: 18,&#xA;    fontWeight: &#x27;bold&#x27;,&#xA;  },&#xA;  headerContainer: {&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    justifyContent: &#x27;space-between&#x27;,&#xA;    width: &#x27;100%&#x27;,&#xA;    marginBottom: 10,&#xA;  },&#xA;  videoCount: {&#xA;    fontSize: 18,&#xA;  },&#xA;  clearButtonContainer: {&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    marginRight: 10,&#xA;  },&#xA;  clearIcon: {&#xA;    marginRight: 5,&#xA;  },&#xA;  clearAllText: {&#xA;    fontSize: 16,&#xA;    color: &#x27;red&#x27;,&#xA;    textDecorationLine: &#x27;underline&#x27;,&#xA;  },&#xA;  toggleLayoutButton: {&#xA;    backgroundColor: &#x27;#007BFF&#x27;,&#xA;    padding: 1,&#xA;    borderRadius: 8,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    justifyContent: &#x27;center&#x27;,&#xA;  },&#xA;  list: {&#xA;    flex: 1,&#xA;    width: &#x27;100%&#x27;,&#xA;  },&#xA;  videoItem: {&#xA;    padding: 5,&#xA;    borderBottomColor: &#x27;#ccc&#x27;,&#xA;    borderBottomWidth: 0.7,&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;  },&#xA;  videoItemGrid: {&#xA;    flexDirection: &#x27;column&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    margin: 4,&#xA;    borderWidth: 1,&#xA;    borderColor: &#x27;#ccc&#x27;,&#xA;    borderRadius: 8,&#xA;    padding: 2,&#xA;    position: &#x27;relative&#x27;,&#xA;  },&#xA;  thumbnail: {&#xA;    width: 70,&#xA;    height: 70,&#xA;    marginRight: 10,&#xA;  },&#xA;  thumbnailGrid: {&#xA;    width: 80,&#xA;    height: 80,&#xA;    marginBottom: 0,&#xA;  },&#xA;  fileName: {&#xA;    fontSize: 16,&#xA;    marginLeft: 10,&#xA;    flex: 1,&#xA;  },&#xA;  deleteButton: {&#xA;    marginLeft: 60,&#xA;    width: 20,&#xA;    height: 20,&#xA;  },&#xA;  deleteButtonGrid: {&#xA;    position: &#x27;absolute&#x27;,&#xA;    bottom: 5,&#xA;    right: 5,&#xA;  },&#xA;  convertButton: {&#xA;    backgroundColor: &#x27;#007BFF&#x27;,&#xA;    padding: 15,&#xA;    borderRadius: 10,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    marginTop: 20,&#xA;    width: &#x27;100%&#x27;,&#xA;  },&#xA;  convertButtonText: {&#xA;    color: &#x27;#fff&#x27;,&#xA;    fontSize: 18,&#xA;    fontWeight: &#x27;bold&#x27;,&#xA;  },&#xA;  gridContainer: {&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    flexWrap: &#x27;wrap&#x27;,&#xA;    justifyContent: &#x27;flex-start&#x27;,&#xA;    paddingVertical: 5,&#xA;    paddingHorizontal: 5,&#xA;    width: &#x27;100%&#x27;,&#xA;  },&#xA;});

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    App.json

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    {&#xA;  "expo": {&#xA;    "name": "VidoeConvert",&#xA;    "slug": "VidoeConvert",&#xA;    "version": "1.0.0",&#xA;    "orientation": "portrait",&#xA;    "icon": "./assets/icon.png",&#xA;    "userInterfaceStyle": "light",&#xA;    "splash": {&#xA;      "image": "./assets/splash.png",&#xA;      "resizeMode": "contain",&#xA;      "backgroundColor": "#ffffff"&#xA;    },&#xA;    "ios": {&#xA;      "supportsTablet": true&#xA;    },&#xA;    "android": {&#xA;      "adaptiveIcon": {&#xA;        "foregroundImage": "./assets/adaptive-icon.png",&#xA;        "backgroundColor": "#ffffff"&#xA;      },&#xA;      "package": "com.anonymous.VidoeConvert"&#xA;    },&#xA;    "web": {&#xA;      "favicon": "./assets/favicon.png"&#xA;    },&#xA;    "plugins": [&#xA;      "@config-plugins/ffmpeg-kit-react-native",&#xA;      "expo-build-properties"&#xA;    ]&#xA;  }&#xA;}

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    Package.json

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    {&#xA;  "name": "vidoeconvert",&#xA;  "version": "1.0.0",&#xA;  "main": "expo/AppEntry.js",&#xA;  "scripts": {&#xA;    "start": "expo start",&#xA;    "android": "expo run:android",&#xA;    "ios": "expo run:ios",&#xA;    "web": "expo start --web"&#xA;  },&#xA;  "dependencies": {&#xA;    "@config-plugins/ffmpeg-kit-react-native": "^8.0.0",&#xA;    "@expo/metro-runtime": "~3.2.1",&#xA;    "expo": "~51.0.17",&#xA;    "expo-asset": "~10.0.10",&#xA;    "expo-av": "^14.0.6",&#xA;    "expo-document-picker": "~12.0.2",&#xA;    "expo-file-system": "~17.0.1",&#xA;    "expo-image-picker": "~15.0.7",&#xA;    "expo-media-library": "~16.0.4",&#xA;    "expo-status-bar": "~1.12.1",&#xA;    "ffmpeg-kit-react-native": "^6.0.2",&#xA;    "react": "18.2.0",&#xA;    "react-dom": "18.2.0",&#xA;    "react-native": "^0.74.3",&#xA;    "react-native-document-picker": "^9.3.0",&#xA;    "react-native-ffmpeg": "^0.5.2",&#xA;    "react-native-vector-icons": "^10.1.0",&#xA;    "react-native-web": "~0.19.10",&#xA;    "expo-build-properties": "~0.12.3"&#xA;  },&#xA;  "devDependencies": {&#xA;    "@babel/core": "^7.20.0"&#xA;  },&#xA;  "private": true&#xA;}

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    Has anyone encountered a similar issue or can point me in the right direction to resolve this error ? Any help would be greatly appreciated !

    &#xA;

    How to remove the error ?

    &#xA;

    any configruation required for this project ?

    &#xA;

  • ffmpeg encode video produce incorrect mediainfo encoding settings

    25 août 2021, par Foong

    I've been trying to do batch encode videos to H265 format. I am using media-autobuild_suite to build ffmpeg and have already updating ffmpeg to the latest version.

    &#xA;

    ffmpeg version N-103367-g5ddb4b6a1b-g88b3e31562&#x2B;1 Copyright (c) 2000-2021 the FFmpeg developers&#xA;built with gcc 10.3.0 (Rev5, Built by MSYS2 project)&#xA;configuration:  --pkg-config=pkgconf --cc=&#x27;ccache gcc&#x27; --cxx=&#x27;ccache g&#x2B;&#x2B;&#x27; --ld=&#x27;ccache g&#x2B;&#x2B;&#x27; --disable-autodetect --enable-amf --enable-bzlib --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-schannel --enable-zlib --enable-sdl2 --enable-ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-gmp --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-libaom --disable-debug --enable-libfdk-aac --extra-libs=-liconv --enable-gpl --enable-version3 --enable-nonfree&#xA;libavutil      57.  4.101 / 57.  4.101&#xA;libavcodec     59.  5.101 / 59.  5.101&#xA;libavformat    59.  4.102 / 59.  4.102&#xA;libavdevice    59.  0.101 / 59.  0.101&#xA;libavfilter     8.  3.100 /  8.  3.100&#xA;libswscale      6.  0.100 /  6.  0.100&#xA;libswresample   4.  0.100 /  4.  0.100&#xA;libpostproc    56.  0.100 / 56.  0.100&#xA;

    &#xA;

    However, the Writing library and Encoding settings output is incorrect. Before update ffmpeg doesn't have this issue. I wonder what have been missing that causing this issue.

    &#xA;

    encoding CLI :

    &#xA;

    ffmpeg -y -hide_banner -loglevel error -stats -hwaccel dxva2 -i "input.mkv" -c:v libx265 -vsync cfr -pix_fmt yuv420p10le -preset fast -tune animation -x265-params ctu=32:min-cu-size=8:max-tu-size=16:tu-intra-depth=2:tu-inter-depth=2:me=1:subme=3:merange=44:max-merge=2:keyint=250:min-keyint=23:rc-lookahead=60:lookahead-slices=6:bframes=6:bframe-bias=0:b-adapt=2:ref=6:limit-refs=3:limit-tu=1:aq-mode=3:aq-strength=0.6:rd=3:psy-rd=1.00:psy-rdoq=1.50:rdoq-level=1:deblock=-1,-1:crf=21.0:qblur=0.50:qcomp=0.60:qpmin=0:qpmax=51:frame-threads=1:strong-intra-smoothing=1:no-lossless=1:no-cu-lossless=1:constrained-intra=1:no-fast-intra=1:no-open-gop=1:no-temporal-layers=1:no-limit-modes=1:weightp=1:no-weightb=1:no-analyze-src-pics=1:no-rd-refine=1:signhide=1:sao=1:no-sao-non-deblock=1:b-pyramid=1:no-cutree=1:no-intra-refresh=1:no-amp=1:temporal-mvp=1:no-early-skip=1:no-tskip=1:no-tskip-fast=1:no-deblock=1:no-b-intra=1:no-splitrd-skip=1:no-strict-cbr=1:no-rc-grain=1:no-const-vbv=1:no-opt-qp-pps=1:no-opt-ref-list-length-pps=1:no-multi-pass-opt-rps=1:no-opt-cu-delta-qp=1:no-hdr=1:no-hdr-opt=1:no-dhdr10-opt=1:no-idr-recovery-sei=1:no-limit-sao=1:no-lowpass-dct=1:no-dynamic-refine=1:no-single-sei=1 -c:a libfdk_aac -vf "fps=fps=29.970,setdar=16/9,scale=960:540:flags=lanczos" -map 0:v:? -map 0:a:? -map_metadata:g -1 -map_chapters 0 "output.mkv"&#xA;

    &#xA;

    Input video info :

    &#xA;

    Video&#xA;ID                          : 1&#xA;Format                      : AVC&#xA;Format/Info                 : Advanced Video Codec&#xA;Format profile              : High@L3&#xA;Format settings             : CABAC / 5 Ref Frames&#xA;Format settings, CABAC      : Yes&#xA;Format settings, Reference  : 5 frames&#xA;Codec ID                    : V_MPEG4/ISO/AVC&#xA;Bit rate                    : 1 595 kb/s&#xA;Nominal bit rate            : 2 030 kb/s&#xA;Width                       : 720 pixels&#xA;Height                      : 480 pixels&#xA;Display aspect ratio        : 16:9&#xA;Original display aspect rat : 3:2&#xA;Frame rate mode             : Variable&#xA;Original frame rate         : 29.970 FPS&#xA;Color space                 : YUV&#xA;Chroma subsampling          : 4:2:0&#xA;Bit depth                   : 8 bits&#xA;Scan type                   : Progressive&#xA;Bits/(Pixel*Frame)          : 0.196&#xA;Writing library             : x264 core 66 r1115M 11863ac&#xA;Encoding settings           : cabac=1 / ref=5 / deblock=1:1:1 / analyse=0x3:0x133 / me=esa / subme=7 / psy_rd=1.0:0.0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=2 / deadzone=21,11 / chroma_qp_offset=-2 / threads=1 / nr=0 / decimate=0 / mbaff=0 / bframes=1 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / wpredb=1 / keyint=250 / keyint_min=25 / scenecut=40 / rc=2pass / bitrate=2030 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00&#xA;Default                     : Yes&#xA;Forced                      : No&#xA;

    &#xA;

    Output video info :

    &#xA;

    Video&#xA;ID                          : 1&#xA;Format                      : HEVC&#xA;Format/Info                 : High Efficiency Video Coding&#xA;Format profile              : Main 10@L3.1@Main&#xA;Codec ID                    : V_MPEGH/ISO/HEVC&#xA;Duration                    : 23 min 29 s&#xA;Width                       : 960 pixels&#xA;Height                      : 540 pixels&#xA;Display aspect ratio        : 16:9&#xA;Frame rate mode             : Constant&#xA;Frame rate                  : 29.970 (29970/1000) FPS&#xA;Color space                 : YUV&#xA;Chroma subsampling          : 4:2:0&#xA;Bit depth                   : 10 bits&#xA;Writing library             : Lavc59.5.100 libx265&#xA;Encoding settings           : cabac=1 / ref=5 / deblock=1:1:1 / analyse=0x3:0x133 / me=esa / subme=7 / psy_rd=1.0:0.0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / cqm=2 / deadzone=21,11 / chroma_qp_offset=-2 / threads=1 / nr=0 / decimate=0 / mbaff=0 / bframes=1 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / wpredb=1 / keyint=250 / keyint_min=25 / scenecut=40 / rc=2pass / bitrate=2030 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00&#xA;Default                     : Yes&#xA;Forced                      : No&#xA;Color range                 : Limited&#xA;

    &#xA;

    Expecting (from previous encoded videos) :

    &#xA;

    Video&#xA;ID                          : 1&#xA;Format                      : HEVC&#xA;Format/Info                 : High Efficiency Video Coding&#xA;Format profile              : Main 10@L3.1@Main&#xA;Codec ID                    : V_MPEGH/ISO/HEVC&#xA;Duration                    : 24 min 37 s&#xA;Bit rate                    : 833 kb/s&#xA;Width                       : 960 pixels&#xA;Height                      : 720 pixels&#xA;Display aspect ratio        : 4:3&#xA;Frame rate mode             : Constant&#xA;Frame rate                  : 23.976 (23976/1000) FPS&#xA;Color space                 : YUV&#xA;Chroma subsampling          : 4:2:0&#xA;Bit depth                   : 10 bits&#xA;Bits/(Pixel*Frame)          : 0.050&#xA;Stream size                 : 147 MiB&#xA;Title                       : HEVC&#xA;Writing library             : x265 3.4&#x2B;28-419182243:[Windows][GCC 10.2.0][64 bit] 10bit&#xA;Encoding settings           : cpuid=1111039 / frame-threads=3 / numa-pools=12 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=960x720 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=5 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-hrd / info / hash=0 / no-temporal-layers / no-open-gop / min-keyint=1 / keyint=360 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=4 / scenecut=40 / hist-scenecut=0 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=2 / limit-refs=3 / no-limit-modes / me=1 / subme=3 / merange=16 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / no-deblock / sao / no-sao-non-deblock / rd=3 / selective-sao=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=0.20 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=26.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.00 / aq-mode=0 / aq-strength=0.00 / no-cutree / zone-count=0 / no-strict-cbr / qg-size=64 / no-rc-grain / qpmax=51 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=2 / transfer=2 / colormatrix=2 / chromaloc=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / hist-threshold=0.03 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / no-scenecut-aware-qpconformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0 / no-vbv-live-multi-pass&#xA;Language                    : English&#xA;Default                     : Yes&#xA;Forced                      : No&#xA;Color range                 : Limited&#xA;

    &#xA;

    I have tried with simplest ffmpeg from official wedsite and encoding cli but the output still same.

    &#xA;

    ffmpeg -i "input.mkv" -c:v libx265 "output.mkv"&#xA;

    &#xA;

    Update :&#xA;Tried converting video with FFmpeg 4.4 "Rao" from https://www.ffmpeg.org/ working fine. But compiled ffmpeg from media-autobuild_suite, tried with light build and full build, Writing library and Encoding settings output still incorrect.

    &#xA;