
Recherche avancée
Autres articles (20)
-
Le plugin : Podcasts.
14 juillet 2010, parLe 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, parMediaSPIP 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 2011Documentation 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 meherenI 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 
#include 
#include 
#include <alsa></alsa>asoundlib.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>opt.h>
#include <libswresample></libswresample>swresample.h>

int terminate = 0;
int channels = 2;

// Function to handle termination signal
void sigint_handler(int sig) {
 terminate = 1;
}

// Function to initialize the FFmpeg encoder and writer
AVFormatContext* init_ffmpeg_writer(const char *filename, AVCodecContext **audio_codec_ctx) {
 AVFormatContext *fmt_ctx = NULL;
 AVCodec *audio_codec = NULL;
 AVStream *audio_stream = NULL;

 // Initialize the output format context
 if (avformat_alloc_output_context2(&fmt_ctx, NULL, "mp4", filename) < 0) {
 fprintf(stderr, "Could not create output context\n");
 exit(1);
 }

 // Find the codec
 audio_codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
 if (!audio_codec) {
 fprintf(stderr, "Codec not found\n");
 exit(1);
 }

 // Create a new stream
 audio_stream = avformat_new_stream(fmt_ctx, audio_codec);
 if (!audio_stream) {
 fprintf(stderr, "Could not create audio stream\n");
 exit(1);
 }

 // Set up codec context
 *audio_codec_ctx = avcodec_alloc_context3(audio_codec);
 (*audio_codec_ctx)->channels = 2;
 (*audio_codec_ctx)->channel_layout = AV_CH_LAYOUT_STEREO;
 (*audio_codec_ctx)->sample_rate = 44100;
 (*audio_codec_ctx)->sample_fmt = AV_SAMPLE_FMT_FLTP; // 32-bit float for input format
 (*audio_codec_ctx)->bit_rate = 128000; // Bitrate for AAC encoding

 // Open the codec
 if (avcodec_open2(*audio_codec_ctx, audio_codec, NULL) < 0) {
 fprintf(stderr, "Could not open codec\n");
 exit(1);
 }

 // Copy codec parameters from codec context to the stream
 if (avcodec_parameters_from_context(audio_stream->codecpar, *audio_codec_ctx) < 0) {
 fprintf(stderr, "Could not copy codec parameters\n");
 exit(1);
 }

 // Open the output file
 if (!(fmt_ctx->oformat->flags & AVFMT_NOFILE)) {
 if (avio_open(&fmt_ctx->pb, filename, AVIO_FLAG_WRITE) < 0) {
 fprintf(stderr, "Could not open output file\n");
 exit(1);
 }
 }

 // Write the file header
 if (avformat_write_header(fmt_ctx, NULL) < 0) {
 fprintf(stderr, "Error occurred when writing header\n");
 exit(1);
 }

 return fmt_ctx;
}

void write_audio_frame(AVFormatContext *fmt_ctx, AVCodecContext *audio_codec_ctx, uint8_t *buffer, int buffer_size) {
 AVPacket pkt;
 AVFrame *frame;
 int ret;
 static int64_t frame_count = 0; // Ensure this is initialized correctly
 static double stream_time = 0;

 // Initialize the packet
 av_init_packet(&pkt);
 pkt.data = NULL;
 pkt.size = 0;

 // Allocate and set up frame
 frame = av_frame_alloc();
 frame->nb_samples = audio_codec_ctx->frame_size;
 frame->channel_layout = audio_codec_ctx->channel_layout;
 frame->format = audio_codec_ctx->sample_fmt;
 frame->sample_rate = audio_codec_ctx->sample_rate;

 ret = av_frame_get_buffer(frame, 0);
 if (ret < 0) {
 fprintf(stderr, "Could not allocate frame buffer\n");
 exit(1);
 }

 // Initialize swresample context
 SwrContext *swr_ctx = swr_alloc();
 av_opt_set_int(swr_ctx, "in_channel_layout", frame->channel_layout, 0);
 av_opt_set_int(swr_ctx, "out_channel_layout", frame->channel_layout, 0);
 av_opt_set_int(swr_ctx, "in_sample_rate", 44100, 0);
 av_opt_set_int(swr_ctx, "out_sample_rate", 44100, 0);
 av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
 av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);

 if (swr_init(swr_ctx) < 0) {
 fprintf(stderr, "Error initializing swresample context\n");
 exit(1);
 }

 // Calculate the number of samples based on buffer size and format
 int num_samples = buffer_size / (2 * channels); // 2 bytes per sample (S16)
 uint8_t *out_buffer = (uint8_t *)malloc(num_samples * 4); // 4 bytes per sample (float)

 // Resample audio data
 ret = swr_convert(swr_ctx, &out_buffer, num_samples, (const uint8_t **)&buffer, num_samples);
 if (ret < 0) {
 fprintf(stderr, "Error during resampling\n");
 exit(1);
 }

 // Copy resampled data to the frame's buffer
 int out_size = num_samples * av_get_bytes_per_sample(audio_codec_ctx->sample_fmt);
 memcpy(frame->data[0], out_buffer, out_size);

 if (frame->data[0] == NULL) {
 fprintf(stderr, "Frame data is NULL\n");
 }

 // Set timestamps for the packet
 pkt.pts = pkt.dts = (frame_count * audio_codec_ctx->frame_size * AV_TIME_BASE) / audio_codec_ctx->sample_rate;
 stream_time += (double)frame->nb_samples / audio_codec_ctx->sample_rate;

 // Send the frame for encoding
 ret = avcodec_send_frame(audio_codec_ctx, frame);
 if (ret < 0) {
 if (ret == AVERROR(EAGAIN)) {
 // Encoder is temporarily unavailable, wait or retry
 fprintf(stderr, "Encoder temporarily unavailable, retrying...\n");
 return;
 } else {
 // Another error occurred
 fprintf(stderr, "Error sending audio frame to encoder: %s\n", av_err2str(ret));
 exit(1);
 }
 }

 // Receive the encoded packet
 ret = avcodec_receive_packet(audio_codec_ctx, &pkt);
 if (ret < 0) {
 if (ret == AVERROR(EAGAIN)) {
 // No packet is available yet, maybe retry later
 fprintf(stderr, "No packet available, retrying...\n");
 return;
 } else {
 fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
 exit(1);
 }
 }

 pkt.stream_index = 0;

 // Write the packet to the output
 ret = av_interleaved_write_frame(fmt_ctx, &pkt);
 if (ret < 0) {
 fprintf(stderr, "Error while writing frame\n");
 exit(1);
 }else if (ret==0){

 printf("Writing frames successfully\n");
}

 // Clean up
 av_frame_free(&frame);
 av_packet_unref(&pkt);
 free(out_buffer);

 frame_count++; // Increment the frame count to track timestamps
}




int main() {
 snd_pcm_t *capture_handle;
 snd_pcm_hw_params_t *hw_params;
 int err;
 unsigned int sample_rate = 44100;
 snd_pcm_uframes_t frames = 32;
 char *buffer;
 int buffer_size;

 // Register signal handler for termination (Ctrl+C)
 signal(SIGINT, sigint_handler);

 // Open the PCM device for recording (capture)
 if ((err = snd_pcm_open(&capture_handle, "default", SND_PCM_STREAM_CAPTURE, 0)) < 0) {
 fprintf(stderr, "cannot open audio device %s (%s)\n", "default", snd_strerror(err));
 exit(1);
 }

 // Allocate the hardware parameters structure
 if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) {
 fprintf(stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
 exit(1);
 }

 // Initialize the hardware parameters with default values
 if ((err = snd_pcm_hw_params_any(capture_handle, hw_params)) < 0) {
 fprintf(stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
 exit(1);
 }

 // Set the desired hardware parameters
 if ((err = snd_pcm_hw_params_set_access(capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
 fprintf(stderr, "cannot set access type (%s)\n", snd_strerror(err));
 exit(1);
 }

 if ((err = snd_pcm_hw_params_set_format(capture_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
 fprintf(stderr, "cannot set sample format (%s)\n", snd_strerror(err));
 exit(1);
 }

 if ((err = snd_pcm_hw_params_set_rate_near(capture_handle, hw_params, &sample_rate, 0)) < 0) {
 fprintf(stderr, "cannot set sample rate (%s)\n", snd_strerror(err));
 exit(1);
 }

 if ((err = snd_pcm_hw_params_set_channels(capture_handle, hw_params, channels)) < 0) {
 fprintf(stderr, "cannot set channel count (%s)\n", snd_strerror(err));
 exit(1);
 }

 if ((err = snd_pcm_hw_params(capture_handle, hw_params)) < 0) {
 fprintf(stderr, "cannot set parameters (%s)\n", snd_strerror(err));
 exit(1);
 }

 // Free the hardware parameters structure
 snd_pcm_hw_params_free(hw_params);

 // Prepare the PCM device for use
 if ((err = snd_pcm_prepare(capture_handle)) < 0) {
 fprintf(stderr, "cannot prepare audio interface for use (%s)\n", snd_strerror(err));
 exit(1);
 }

 // Calculate buffer size
 buffer_size = frames * channels * 2; // 2 bytes/sample, 2 channels
 buffer = (char *) malloc(buffer_size);

 // Initialize FFmpeg
 av_register_all();

 // Initialize the output file and codec
 AVCodecContext *audio_codec_ctx = NULL;
 AVFormatContext *fmt_ctx = init_ffmpeg_writer("recorded_audio.mp4", &audio_codec_ctx);

 printf("Recording...\n");

 // Record audio data until termination signal is received
 while (!terminate) {
 printf("entered while\n");
 if ((err = snd_pcm_readi(capture_handle, buffer, frames)) != frames) {
 fprintf(stderr, "read from audio interface failed (%s)\n", snd_strerror(err));
 exit(1);
 }

 // Write audio frame to the MP4 file
 write_audio_frame(fmt_ctx, audio_codec_ctx, (uint8_t *)buffer, buffer_size);
 }

 printf("Recording finished.\n");

 // Write the file footer and close
 av_write_trailer(fmt_ctx);
 avcodec_free_context(&audio_codec_ctx);
 avformat_close_input(&fmt_ctx);
 avformat_free_context(fmt_ctx);

 // Clean up ALSA resources
 snd_pcm_close(capture_handle);
 free(buffer);

 return 0;
}



Here I am attaching the logs too


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



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


-
Error initializing FFmpegKit : "TypeError : Cannot read property 'getLogLevel' of null" in React Native
9 janvier, par Md Monirozzaman khanI'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 :


ERROR Error initializing FFmpegKit: [TypeError: Cannot read property 'getLogLevel' of null]



Here is my App.js code




import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, Alert, Dimensions, ScrollView, LayoutAnimation, UIManager, Platform } from 'react-native';
import * as ImagePicker from 'expo-image-picker';
import * as FileSystem from 'expo-file-system';
import { Video } from 'expo-av';
import { MaterialIcons } from '@expo/vector-icons';
import { FFmpegKit, FFmpegKitConfig, ReturnCode } from 'ffmpeg-kit-react-native';

const windowWidth = Dimensions.get('window').width;

if (Platform.OS === 'android') {
 UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
}

export default function App() {
 const [videoFiles, setVideoFiles] = useState([]);
 const [isGridView, setIsGridView] = useState(false);
 const [isConverting, setIsConverting] = useState(false);

 useEffect(() => {
 FFmpegKitConfig.init()
 .then(() => {
 console.log('FFmpegKit initialized');
 })
 .catch((error) => {
 console.error('Error initializing FFmpegKit:', error);
 });
 }, []);

 const pickVideo = async () => {
 const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
 if (status !== 'granted') {
 alert('Sorry, we need media library permissions to make this work!');
 return;
 }

 let result = await ImagePicker.launchImageLibraryAsync({
 mediaTypes: ImagePicker.MediaTypeOptions.Videos,
 allowsMultipleSelection: true,
 });

 if (!result.canceled && result.assets.length > 0) {
 const newFiles = result.assets.filter(
 (newFile) => !videoFiles.some((existingFile) => existingFile.uri === newFile.uri)
 );

 if (newFiles.length < result.assets.length) {
 Alert.alert('Duplicate Files', 'Some files were already added.');
 }

 LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
 setVideoFiles([...videoFiles, ...newFiles]);
 }
 };

 const convertVideos = async () => {
 setIsConverting(true);
 const outputDir = `${FileSystem.documentDirectory}Output`;

 const dirInfo = await FileSystem.getInfoAsync(outputDir);
 if (!dirInfo.exists) {
 await FileSystem.makeDirectoryAsync(outputDir, { intermediates: true });
 }

 for (const video of videoFiles) {
 const { uri } = video;
 const filename = uri.split('/').pop();
 const outputFilePath = `${outputDir}/${filename.split('.').slice(0, -1).join('.')}_modified.mp4`;

 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='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)', 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}"`;

 try {
 const session = await FFmpegKit.execute(ffmpegCommand);
 const returnCode = await session.getReturnCode();

 if (ReturnCode.isSuccess(returnCode)) {
 console.log(`Video converted: ${outputFilePath}`);
 } else if (ReturnCode.isCancel(returnCode)) {
 console.log('Conversion cancelled');
 } else {
 console.error(`FFmpeg process failed: ${session.getFailStackTrace()}`);
 }
 } catch (error) {
 console.error(`Error converting video: ${error.message}`);
 }
 }

 setIsConverting(false);
 Alert.alert('Conversion Complete', 'All videos have been converted.');
 };

 const deleteVideo = (uri) => {
 LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
 setVideoFiles(videoFiles.filter((video) => video.uri !== uri));
 };

 const clearAllVideos = () => {
 LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
 setVideoFiles([]);
 };

 const toggleLayout = () => {
 LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
 setIsGridView(!isGridView);
 };

 return (
 <view style="{styles.container}">
 <text style="{styles.header}">Video Converter App</text>
 <touchableopacity style="{styles.addButton}">
 <text style="{styles.addButtonText}">Select or Browse Videos</text>
 </touchableopacity>
 <view style="{styles.headerContainer}">
 <text style="{styles.videoCount}">Total Videos: {videoFiles.length}</text>
 {videoFiles.length > 0 && (
 <>
 <touchableopacity style="{styles.clearButtonContainer}">
 <materialicons size="{24}" color="red" style="{styles.clearIcon}"></materialicons>
 <text style="{styles.clearAllText}">Clear All</text>
 </touchableopacity>
 <touchableopacity style="{styles.toggleLayoutButton}">
 <materialicons size="{24}" color="#fff"></materialicons>
 </touchableopacity>
 >
 )}
 </view>
 {isGridView ? (
 <scrollview contentcontainerstyle="{styles.gridContainer}">
 {videoFiles.map((item, index) => (
 <view key="{index}" style="{styles.videoItemGrid}">
 
 <touchableopacity>> deleteVideo(item.uri)} style={styles.deleteButtonGrid}>
 <materialicons size="{24}" color="red"></materialicons>
 </touchableopacity>
 </view>
 ))}
 </scrollview>
 ) : (
 <view style="{styles.list}">
 {videoFiles.map((item, index) => (
 <view key="{index}" style="{styles.videoItem}">
 
 <text style="{styles.fileName}">{decodeURI(item.fileName || item.uri.split('/').pop() || 'Unknown File')}</text>
 <touchableopacity>> deleteVideo(item.uri)} style={styles.deleteButton}>
 <materialicons size="{24}" color="red"></materialicons>
 </touchableopacity>
 </view>
 ))}
 </view>
 )}
 {videoFiles.length > 0 && (
 <touchableopacity style="{styles.convertButton}" disabled="{isConverting}">
 <text style="{styles.convertButtonText}">{isConverting ? 'Converting...' : 'Convert'}</text>
 </touchableopacity>
 )}
 </view>
 );
}

const styles = StyleSheet.create({
 container: {
 flex: 1,
 backgroundColor: '#fff',
 alignItems: 'center',
 padding: 10,
 },
 header: {
 fontSize: 24,
 fontWeight: 'bold',
 marginBottom: 5,
 },
 addButton: {
 backgroundColor: '#007BFF',
 padding: 15,
 borderRadius: 10,
 alignItems: 'center',
 marginBottom: 5,
 width: '100%',
 elevation: 2,
 shadowColor: '#000',
 shadowOffset: { width: 0, height: 5 },
 shadowOpacity: 0.8,
 shadowRadius: 2,
 },
 addButtonText: {
 color: '#fff',
 fontSize: 18,
 fontWeight: 'bold',
 },
 headerContainer: {
 flexDirection: 'row',
 alignItems: 'center',
 justifyContent: 'space-between',
 width: '100%',
 marginBottom: 10,
 },
 videoCount: {
 fontSize: 18,
 },
 clearButtonContainer: {
 flexDirection: 'row',
 alignItems: 'center',
 marginRight: 10,
 },
 clearIcon: {
 marginRight: 5,
 },
 clearAllText: {
 fontSize: 16,
 color: 'red',
 textDecorationLine: 'underline',
 },
 toggleLayoutButton: {
 backgroundColor: '#007BFF',
 padding: 1,
 borderRadius: 8,
 alignItems: 'center',
 justifyContent: 'center',
 },
 list: {
 flex: 1,
 width: '100%',
 },
 videoItem: {
 padding: 5,
 borderBottomColor: '#ccc',
 borderBottomWidth: 0.7,
 flexDirection: 'row',
 alignItems: 'center',
 },
 videoItemGrid: {
 flexDirection: 'column',
 alignItems: 'center',
 margin: 4,
 borderWidth: 1,
 borderColor: '#ccc',
 borderRadius: 8,
 padding: 2,
 position: 'relative',
 },
 thumbnail: {
 width: 70,
 height: 70,
 marginRight: 10,
 },
 thumbnailGrid: {
 width: 80,
 height: 80,
 marginBottom: 0,
 },
 fileName: {
 fontSize: 16,
 marginLeft: 10,
 flex: 1,
 },
 deleteButton: {
 marginLeft: 60,
 width: 20,
 height: 20,
 },
 deleteButtonGrid: {
 position: 'absolute',
 bottom: 5,
 right: 5,
 },
 convertButton: {
 backgroundColor: '#007BFF',
 padding: 15,
 borderRadius: 10,
 alignItems: 'center',
 marginTop: 20,
 width: '100%',
 },
 convertButtonText: {
 color: '#fff',
 fontSize: 18,
 fontWeight: 'bold',
 },
 gridContainer: {
 flexDirection: 'row',
 flexWrap: 'wrap',
 justifyContent: 'flex-start',
 paddingVertical: 5,
 paddingHorizontal: 5,
 width: '100%',
 },
});







App.json




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







Package.json




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







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


How to remove the error ?


any configruation required for this project ?


-
ffmpeg encode video produce incorrect mediainfo encoding settings
25 août 2021, par FoongI'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.


ffmpeg version N-103367-g5ddb4b6a1b-g88b3e31562+1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
configuration: --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++' --ld='ccache g++' --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
libavutil 57. 4.101 / 57. 4.101
libavcodec 59. 5.101 / 59. 5.101
libavformat 59. 4.102 / 59. 4.102
libavdevice 59. 0.101 / 59. 0.101
libavfilter 8. 3.100 / 8. 3.100
libswscale 6. 0.100 / 6. 0.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100



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.


encoding CLI :


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"



Input video info :


Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3
Format settings : CABAC / 5 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference : 5 frames
Codec ID : V_MPEG4/ISO/AVC
Bit rate : 1 595 kb/s
Nominal bit rate : 2 030 kb/s
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 16:9
Original display aspect rat : 3:2
Frame rate mode : Variable
Original frame rate : 29.970 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.196
Writing library : x264 core 66 r1115M 11863ac
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
Default : Yes
Forced : No



Output video info :


Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main 10@L3.1@Main
Codec ID : V_MPEGH/ISO/HEVC
Duration : 23 min 29 s
Width : 960 pixels
Height : 540 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 (29970/1000) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 10 bits
Writing library : Lavc59.5.100 libx265
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
Default : Yes
Forced : No
Color range : Limited



Expecting (from previous encoded videos) :


Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main 10@L3.1@Main
Codec ID : V_MPEGH/ISO/HEVC
Duration : 24 min 37 s
Bit rate : 833 kb/s
Width : 960 pixels
Height : 720 pixels
Display aspect ratio : 4:3
Frame rate mode : Constant
Frame rate : 23.976 (23976/1000) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 10 bits
Bits/(Pixel*Frame) : 0.050
Stream size : 147 MiB
Title : HEVC
Writing library : x265 3.4+28-419182243:[Windows][GCC 10.2.0][64 bit] 10bit
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
Language : English
Default : Yes
Forced : No
Color range : Limited



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


ffmpeg -i "input.mkv" -c:v libx265 "output.mkv"



Update :
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.