
Recherche avancée
Médias (39)
-
Stereo master soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Audio
-
ED-ME-5 1-DVD
11 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Audio
-
1,000,000
27 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Four of Us are Dying
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (23)
-
Installation en mode ferme
4 février 2011, parLe mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
C’est la méthode que nous utilisons sur cette même plateforme.
L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...) -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)
Sur d’autres sites (5870)
-
No Audio in Recorded File from IP Camera using ffmpeg
26 janvier, par LeXela-EDI'm trying to record video and audio from an IP camera equipped with a microphone. Below is a simplified version of my code, which compiles and runs without errors :


#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>opt.h>
#include 
#include 

#define AUDIO_CODEC "aac"

void log_error(const char *message, int error_code) {
 char error_buffer[AV_ERROR_MAX_STRING_SIZE];
 av_strerror(error_code, error_buffer, sizeof(error_buffer));
 fprintf(stderr, "%s: %s\n", message, error_buffer);
 exit(1);
}

int main(int argc, char *argv[]) {
 const char *input_url = "rtsp://admin:123456@192.168.1.99:554/mode=real&idc=1&ids=1";
 const char *output_file = "D:/abc.ts"; // MPEG-TS file

 avformat_network_init();

 AVFormatContext *input_ctx = NULL;
 AVFormatContext *output_ctx = NULL;
 AVStream *video_stream = NULL, *audio_stream = NULL;
 AVCodecContext *audio_codec_ctx = NULL;
 AVCodec *audio_codec = NULL;
 int ret;

 // Open input stream
 if ((ret = avformat_open_input(&input_ctx, input_url, NULL, NULL)) < 0) {
 log_error("Failed to open input", ret);
 }

 if ((ret = avformat_find_stream_info(input_ctx, NULL)) < 0) {
 log_error("Failed to find stream info", ret);
 }

 // Find video and audio streams
 int video_stream_index = -1, audio_stream_index = -1;
 for (int i = 0; i < input_ctx->nb_streams; i++) {
 if (input_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 video_stream_index = i;
 } else if (input_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
 audio_stream_index = i;
 }
 }

 if (video_stream_index == -1) {
 fprintf(stderr, "No video stream found\n");
 exit(1);
 }
 if (audio_stream_index == -1) {
 fprintf(stderr, "No audio stream found\n");
 exit(1);
 }

 // Allocate output context
 avformat_alloc_output_context2(&output_ctx, NULL, NULL, output_file);
 if (!output_ctx) {
 fprintf(stderr, "Failed to create output context\n");
 exit(1);
 }

 // Copy video stream
 video_stream = avformat_new_stream(output_ctx, NULL);
 if (!video_stream) {
 fprintf(stderr, "Failed to create video stream\n");
 exit(1);
 }
 avcodec_parameters_copy(video_stream->codecpar, input_ctx->streams[video_stream_index]->codecpar);
 video_stream->codecpar->codec_tag = 0;

 // Transmux audio stream to AAC
 audio_codec = avcodec_find_encoder_by_name(AUDIO_CODEC);
 if (!audio_codec) {
 fprintf(stderr, "AAC codec not found\n");
 exit(1);
 }

 audio_stream = avformat_new_stream(output_ctx, audio_codec);
 if (!audio_stream) {
 fprintf(stderr, "Failed to create audio stream\n");
 exit(1);
 }

 audio_codec_ctx = avcodec_alloc_context3(audio_codec);
 if (!audio_codec_ctx) {
 fprintf(stderr, "Failed to allocate audio codec context\n");
 exit(1);
 }

 // Set audio codec parameters
 audio_codec_ctx->sample_fmt = audio_codec->sample_fmts ? audio_codec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
 audio_codec_ctx->bit_rate = 64000;
 audio_codec_ctx->sample_rate = 44100;

 // Use AVChannelLayout for channel configuration
 AVChannelLayout stereo_layout = AV_CHANNEL_LAYOUT_STEREO;
 av_channel_layout_copy(&audio_codec_ctx->ch_layout, &stereo_layout);

 if (output_ctx->oformat->flags & AVFMT_GLOBALHEADER) {
 audio_codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 }

 if ((ret = avcodec_open2(audio_codec_ctx, audio_codec, NULL)) < 0) {
 log_error("Failed to open audio codec", ret);
 }

 avcodec_parameters_from_context(audio_stream->codecpar, audio_codec_ctx);

 // Open output file
 if (!(output_ctx->oformat->flags & AVFMT_NOFILE)) {
 if ((ret = avio_open(&output_ctx->pb, output_file, AVIO_FLAG_WRITE)) < 0) {
 log_error("Failed to open output file", ret);
 }
 }

 // Write header
 if ((ret = avformat_write_header(output_ctx, NULL)) < 0) {
 log_error("Failed to write header", ret);
 }

 // Read and write packets
 AVPacket pkt;
 int count = 0;
 while (count++, count < 500) {
 if ((ret = av_read_frame(input_ctx, &pkt)) < 0) {
 break; // End of stream or error
 }

 if (pkt.stream_index == video_stream_index) {
 // Video packet: copy as-is
 pkt.stream_index = video_stream->index;
 } else if (pkt.stream_index == audio_stream_index) {
 // Audio packet: transmux to AAC
 pkt.stream_index = audio_stream->index;
 } else {
 av_packet_unref(&pkt);
 continue;
 }

 av_packet_rescale_ts(&pkt, input_ctx->streams[pkt.stream_index]->time_base, output_ctx->streams[pkt.stream_index]->time_base);

 if ((ret = av_interleaved_write_frame(output_ctx, &pkt)) < 0) {
 log_error("Failed to write frame", ret);
 }

 av_packet_unref(&pkt);
 }

 // Write trailer
 av_write_trailer(output_ctx);

 // Cleanup
 avcodec_free_context(&audio_codec_ctx);
 avformat_close_input(&input_ctx);
 if (output_ctx && !(output_ctx->oformat->flags & AVFMT_NOFILE)) {
 avio_closep(&output_ctx->pb);
 }
 avformat_free_context(output_ctx);

 printf("Recording completed successfully.\n");
 return 0;
}



Everything seems to work fine during recording, but when I play back the recorded file, there’s no audio. Here’s the output from
ffprobe
:

Input #0, mpegts, from 'D:/abc.ts':
 Duration: 00:00:11.92, start: 0.000000, bitrate: 1897 kb/s
 Program 1
 Metadata:
 service_name : Service01
 service_provider: FFmpeg
 Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
 Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), stereo, fltp, 167 kb/s



What might I be missing here ? I'd greatly appreciate any guidance or suggestions.
Thanks in advance for your help !


-
FFMPEG Corrupt output remuxing MP4 (Using API in C) -First file OK, 2nd file onwards is not
25 janvier, par RichardPI have a simple application written in C - it takes the video from a RTSP camera and just writes to disk in 1 minute segments. The first file created works fine, plays on anlmost anything. The Second file does not play. Programatically, The trace shows they are the same code flows, but I cant seem to find where the problem is to allow the 2nd file to be play exactly the same as the first.


There are frames in the 2nd file but they are random. The second file is created EXACTLY the same way as the first.


Any help from a guru would be greatly appreciated.


EDIT : FIX - The output duration needs to be set before the trailer is written.


int actual_duration = (int)difftime(time(NULL), start_time);

for (int i = 0; i < output_ctx->nb_streams; i++) {
 output_ctx->streams[i]->duration = actual_duration * AV_TIME_BASE;
}

output_ctx->duration = actual_duration * AV_TIME_BASE;
printf("DURATION = %d\r\n",output_ctx->duration);

// Set the start_time for the output context
output_ctx->start_time = 0;

av_write_trailer(output_ctx);



Code flow


Open RTSP Stream 
A: Create File n context 
 Remux to file n 
 Wait for minute to change 
 Close File n context 
 increment n Goto A



Makefile


CC = gcc
CFLAGS = -Wall -g
LIBS = -lavformat -lavcodec -lavutil -lavdevice -lswscale -lavfilter -lavutil -lm -lz -lpthread

TARGET = rtsp_remux

all: $(TARGET)

$(TARGET): rtsp_remux.o
 $(CC) -o $(TARGET) rtsp_remux.o $(LIBS)

rtsp_remux.o: rtsp_remux.c
 $(CC) $(CFLAGS) -c rtsp_remux.c

clean:
 rm -f $(TARGET) rtsp_remux.o

.PHONY: all clean



rtsp_remux.c


#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>time.h>
#include 
#include 

#define OUTPUT_PREFIX "output"
#define OUTPUT_EXTENSION ".mp4"
#define MAX_FILES 4

int main(int argc, char *argv[]) {
 if (argc < 2) {
 fprintf(stderr, "Usage: %s <rtsp url="url">\n", argv[0]);
 return -1;
 }

 const char *rtsp_url = argv[1];
 AVFormatContext *input_ctx = NULL, *output_ctx = NULL;
 AVOutputFormat *output_fmt = NULL;
 AVPacket pkt;
 int ret, file_count = 0;
 char output_filename[1024];
 time_t current_time;
 struct tm *timeinfo;
 int rename_lock = 0;

 avformat_network_init();

 if ((ret = avformat_open_input(&input_ctx, rtsp_url, NULL, NULL)) < 0) {
 fprintf(stderr, "Could not open input file '%s'\n", rtsp_url);
 return -1;
 }

 if ((ret = avformat_find_stream_info(input_ctx, NULL)) < 0) {
 fprintf(stderr, "Failed to retrieve input stream information\n");
 return -1;
 }

 av_dump_format(input_ctx, 0, rtsp_url, 0);

 while (file_count < MAX_FILES) {
 snprintf(output_filename, sizeof(output_filename), "%s_%03d%s", OUTPUT_PREFIX, file_count, OUTPUT_EXTENSION);

 if ((ret = avformat_alloc_output_context2(&output_ctx, NULL, NULL, output_filename)) < 0) {
 fprintf(stderr, "Could not create output context\n");
 return -1;
 }

 output_fmt = output_ctx->oformat;

 for (int i = 0; i < input_ctx->nb_streams; i++) {
 AVStream *in_stream = input_ctx->streams[i];
 AVStream *out_stream = avformat_new_stream(output_ctx, NULL);
 if (!out_stream) {
 fprintf(stderr, "Failed allocating output stream\n");
 return -1;
 }

 if ((ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar)) < 0) {
 fprintf(stderr, "Failed to copy codec parameters\n");
 return -1;
 }
 out_stream->codecpar->codec_tag = 0;
 }

 if (!(output_fmt->flags & AVFMT_NOFILE)) {
 if ((ret = avio_open(&output_ctx->pb, output_filename, AVIO_FLAG_WRITE)) < 0) {
 fprintf(stderr, "Could not open output file '%s'\n", output_filename);
 return -1;
 }
 }

 if ((ret = avformat_write_header(output_ctx, NULL)) < 0) {
 fprintf(stderr, "Error occurred when opening output file\n");
 return -1;
 }

 while (1) {
 current_time = time(NULL);
 timeinfo = localtime(&current_time);

 if (timeinfo->tm_sec == 0 && !rename_lock) {
 rename_lock = 1;
 break;
 } else if (timeinfo->tm_sec != 0) {
 rename_lock = 0;
 }

 if ((ret = av_read_frame(input_ctx, &pkt)) < 0)
 break;

 AVStream *in_stream = input_ctx->streams[pkt.stream_index];
 AVStream *out_stream = output_ctx->streams[pkt.stream_index];

 pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
 pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
 pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
 pkt.pos = -1;

 if ((ret = av_interleaved_write_frame(output_ctx, &pkt)) < 0) {
 fprintf(stderr, "Error muxing packet\n");
 break;
 }

 av_packet_unref(&pkt);
 }

 av_write_trailer(output_ctx);

 if (!(output_fmt->flags & AVFMT_NOFILE))
 avio_closep(&output_ctx->pb);

 avformat_free_context(output_ctx);

 file_count++;
 }

 avformat_close_input(&input_ctx);
 avformat_network_deinit();

 return 0;
}
</rtsp>


I have tried changing to pointers, freeing and different things. I was expecting the 2nd file created to behave identically to the first.


-
Converting HLS Stream to stream supported by old radio
29 novembre 2024, par Alberto FaenzaI have an old internet radio that does not support HLS streams.
Therefore I cannot listen to my favourite radio at this url :
https://streamcdnf31-4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/master_ma.m3u8


I found a solution using a paid software https://minimradio.com/ which is based on minimserver and minimstreamer.


This solution works if I install mininmserver and minimstreamer on a local computer and use the internet radio to point to the converter stream but I will have to pay if I want to use this.


Checking the documentation of minimradio and ministreamer I can see the following :


*Some internet radios can play the previous AAC ADTS streams but can't play these new HLS streams
...


If the network stream URL points to an HLS .m3u8 master playlist or media playlist file, MinimStreamer reads this file and uses the HLS protocol to read the stream audio data and send it to the music player as a conventional HTTP stream. This makes the stream playable on music players that don't support the HLS protocol. The audio data in the stream must be encoded in AAC format.*
and not a single destination receiver I should use a streaming (broadcasting) server. What can I use to do that ?


My question is the following :
Is there a way to replicate what minimstreamer is doing using ffmpeg ?
I have tried this :




ffmpeg -re -i https://streamcdnf31-4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/master_ma.m3u8 -c copy -listen 1 -f mpegts http://192.168.1.9:10000




which is playing corrctly in local vlc on the same computer. But when I stop VLC is got this error in ffmpeg :


[https @ 00000291de047400] Cannot reuse HTTP connection for different host: StreamCdnG20-4c4b867c89244861ac216426883d1ad0.msvdn.net:-1 != 4c4b867c89244861ac216426883d1ad0.msvdn.net:-1
[hls @ 00000291dd96d140] keepalive request failed for 'https://4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/play1.m3u8' with error: 'Invalid argument' when parsing playlist
[hls @ 00000291dd96d140] Opening 'https://4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/play1.m3u8' for reading
[hls @ 00000291dd96d140] Skip ('#EXT-X-DISCONTINUITY-SEQUENCE:0')
[hls @ 00000291dd96d140] Skip ('#EXT-X-PROGRAM-DATE-TIME:2024-11-29T06:36:56.926Z')
[hls @ 00000291dd96d140] Skip ('#EXT-X-PROGRAM-DATE-TIME:2024-11-29T06:37:07.314Z')
[hls @ 00000291dd96d140] Skip ('#EXT-X-PROGRAM-DATE-TIME:2024-11-29T06:37:17.571Z')
[https @ 00000291de4e00c0] Opening 'https://StreamCdnG20-4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/20240722T095729_p1s_001086632.ts' for reading
[aost#0:0/copy @ 00000291de1c4f40] Error submitting a packet to the muxer: Error number -10054 occurred
 Last message repeated 1 times
[out#0/mpegts @ 00000291deaa7e40] Error muxing a packet
[out#0/mpegts @ 00000291deaa7e40] Task finished with error code: -10054 (Error number -10054 occurred)
[out#0/mpegts @ 00000291deaa7e40] Terminating thread with return code -10054 (Error number -10054 occurred)
[out#0/mpegts @ 00000291deaa7e40] Error writing trailer: Error number -10054 occurred
[http @ 00000291de8870c0] URL read error: Error number -10054 occurred
[out#0/mpegts @ 00000291deaa7e40] Error closing file: Error number -10054 occurred
[out#0/mpegts @ 00000291deaa7e40] video:0KiB audio:797KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 21.849292%
size= 971KiB time=00:00:50.98 bitrate= 156.0kbits/s speed=1.01x
Conversion failed!



And if I try to connect from my internet radio I immediately got this error :


[aost#0:0/copy @ 0000027081584a40] Error submitting a packet to the muxer: Error number -10053 occurred
 Last message repeated 1 times
[out#0/mpegts @ 0000027081e684c0] Error muxing a packet
[out#0/mpegts @ 0000027081e684c0] Task finished with error code: -10053 (Error number -10053 occurred)
[out#0/mpegts @ 0000027081e684c0] Terminating thread with return code -10053 (Error number -10053 occurred)
[out#0/mpegts @ 0000027081e684c0] Error writing trailer: Error number -10053 occurred
[http @ 0000027081c47680] URL read error: Error number -10053 occurred
[out#0/mpegts @ 0000027081e684c0] Error closing file: Error number -10053 occurred
[out#0/mpegts @ 0000027081e684c0] video:0KiB audio:46KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 13.917515%
size= 52KiB time=00:00:02.94 bitrate= 145.1kbits/s speed= 1.2x
Conversion failed!



What is the correct way to stream this one locally in order to be listened in my internet radio ?
Shall I use ffmpeg or can be done directly with ngnix ? Or shall I use both ?