
Recherche avancée
Médias (91)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
avec chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
sans chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
config chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (19)
-
Qualité du média après traitement
21 juin 2013, parLe bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
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" (...)
Sur d’autres sites (6844)
-
About "ffmpeg -c copy" two ts files, can not play the problem
4 septembre 2022, par Orlando Bloomaaa.mp4


General
Complete name : C:/aaa.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 3.08 MiB
Duration : 11 s 512 ms
Overall bit rate : 2 248 kb/s
Writing application : Lavf57.83.100
Comment : GIFSHOW [899819595][iOS][11.4.1][iPhone9,2][5.8.5.606][Camera:f]#[720x1280][5327k][78k][C][1][tv=bec1_f80c][ags=0.455141][agm=0.747282][agsi=2000]

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 11 s 512 ms
Bit rate : 2 161 kb/s
Width : 720 pixels
Height : 1 280 pixels
Display aspect ratio : 0.563
Frame rate mode : Constant
Frame rate : 29.970 (29970/1000) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.078
Stream size : 2.96 MiB (96%)
Writing library : x264 core 148
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC SBR
Format/Info : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name : HE-AAC
Format settings : Explicit
Codec ID : mp4a-40-2
Duration : 11 s 501 ms
Bit rate mode : Constant
Bit rate : 78.8 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 21.533 FPS (2048 SPF)
Compression mode : Lossy
Stream size : 111 KiB (4%)
Default : Yes
Alternate group : 1





I want to merge this mp4 with another ts file, because my hardware configuration is very poor, so I choose "-c copy"


General
ID : 1 (0x1)
Complete name : C:/bbb.ts
Format : MPEG-TS
File size : 3.41 MiB
Duration : 15 s 315 ms
Overall bit rate mode : Variable
Overall bit rate : 1 861 kb/s

Video
ID : 256 (0x100)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : 27
Duration : 15 s 382 ms
Width : 1 080 pixels
Height : 606 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive

Audio
ID : 257 (0x101)
Menu ID : 1 (0x1)
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Format version : Version 4
Muxing mode : ADTS
Codec ID : 15-2
Duration : 15 s 185 ms
Bit rate mode : Variable
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Delay relative to video : -46 ms






I directly -c copy them, can't play the whole thing,


Then I convert aaa.mp4 to ts
using "ffmpeg -i aaa.mp4 -bsf:v h264_mp4toannexb -codec copy -hls_list_size 0 aaa.ts" , this is what I googled.


Finally tried aaa.ts and bbb.ts with "-c copy", still can't play.


My machine configuration is acceptable, convert aaa.mp4 to the same encoding as bbb.ts


If I transcode both together, I can't do it because bbb.ts is too big.


-
FFMpeg Coding in C : Encoder returns EOF at first interaction. Encoder not opened correctly ? [closed]
26 février, par Davidhoheyas I'm fairly new to FFMpeg Programming and C in general, the code looks like a mess.


I have smashed my head against a wall trying to get this code to work for about a week.


int decode_encode_pipeline(AVFormatContext *Input_Format_Context, AVFormatContext *Output_Format_Context, int *streams_list){

 const AVCodec *DECodec, *ENCodec;
 AVCodecContext *DECodecContext = NULL, *ENCodecContext = NULL;
 AVCodecParameters *CodecParameters = NULL;
 AVDictionary *opts = NULL;
 AVPacket *Packet;
 AVFrame *Frame;
 int check;

 Packet = av_packet_alloc();
 if(!Packet){
 
 printf("\nFehler bei Allocating Packet");
 
 return 0;
 
 }

 Frame = av_frame_alloc();
 if(!Frame){
 
 printf("\nFehler bei Allocating Frame");
 
 return 0;
 
 }

 CodecParameters = Input_Format_Context->streams[Packet->stream_index]->codecpar;
 if(!CodecParameters){

 printf("\nCodecParameters konnte nicht erstellt oder zugewiesen werden.");

 }

 DECodec = avcodec_find_decoder(CodecParameters->codec_id);
 if(!DECodec){
 
 printf("\nCodec nicht gefunden");
 
 return 0;
 
 }

 DECodecContext = avcodec_alloc_context3(DECodec);
 if (!DECodecContext){
 
 printf("\nFehler bei Allocating CodecContext");
 
 return 0;
 
 }

 ENCodec = avcodec_find_encoder(CodecParameters->codec_id);
 if(!DECodec){
 
 printf("\nCodec nicht gefunden");
 
 return 0;
 
 }

 ENCodecContext = avcodec_alloc_context3(ENCodec);
 if (!ENCodecContext){
 
 printf("\nFehler bei Allocating CodecContext");
 
 return 0;
 
 }

 check = avformat_write_header(Output_Format_Context, &opts);
 if(check < 0){

 printf("\nFehler beim Öffnen des Output Files.");
 
 return 1;

 }

 avcodec_parameters_to_context(DECodecContext, CodecParameters);
 avcodec_parameters_to_context(ENCodecContext, CodecParameters);

 ENCodecContext->width = DECodecContext->width;
 ENCodecContext->height = DECodecContext->height;
 ENCodecContext->bit_rate = DECodecContext->bit_rate;
 ENCodecContext->time_base = (AVRational){1, 30};
 ENCodecContext->framerate = DECodecContext->framerate;
 ENCodecContext->gop_size = DECodecContext->gop_size;
 ENCodecContext->max_b_frames = DECodecContext->max_b_frames;
 ENCodecContext->pix_fmt = DECodecContext->pix_fmt;
 if(ENCodec->id == AV_CODEC_ID_H264){

 av_opt_set(ENCodecContext->priv_data, "preset", "slow", 0);

 }

 check = avcodec_open2(DECodecContext, DECodec, NULL);
 if(check < 0){
 
 printf("\nFehler bei Öffnen von DECodec");
 
 return 1;
 
 }

 check = avcodec_open2(ENCodecContext, ENCodec, NULL);
 if(check < 0){
 
 printf("\nFehler bei Öffnen von ENCodec");
 
 return 1;
 
 }

 while(1){
 
 check = av_read_frame(Input_Format_Context, Packet);
 if(check < 0){
 
 break;
 
 }

 AVStream *in_stream, *out_stream;

 in_stream = Input_Format_Context->streams[Packet->stream_index];
 out_stream = Output_Format_Context->streams[Packet->stream_index];

 if(in_stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && Packet->stream_index == streams_list[Packet->stream_index]){

 check = avcodec_send_packet(DECodecContext, Packet);
 if(check < 0){

 printf("\nFehler bei Encoding");

 return 1;

 }

 AVPacket *EncodedPacket;
 EncodedPacket = av_packet_alloc();
 if(!EncodedPacket){
 
 printf("\nFehler bei Allocating Packet");
 
 return 1;
 
 }

 /*While Loop Decoding*/
 while(check >= 0){
 
 check = avcodec_receive_frame(DECodecContext, Frame);
 if(check == AVERROR(EAGAIN)){
 
 continue;
 
 }else if(check == AVERROR_EOF){
 
 break;
 
 }else if(check < 0){
 
 printf("\nFehler bei Decoding");
 
 return 1;
 
 }

 /*Convert Colorspace*/
 struct SwsContext *SwsContexttoRGB = sws_getContext(Frame->width, Frame->height, Frame->format, Frame->width, Frame->height, AV_PIX_FMT_RGB24, SWS_BILINEAR, NULL, NULL, NULL);
 struct SwsContext *SwsContexttoOriginal = sws_getContext(Frame->width, Frame->height, AV_PIX_FMT_RGB24, Frame->width, Frame->height, Frame->format, SWS_BILINEAR, NULL, NULL, NULL);
 if(!SwsContexttoRGB || !SwsContexttoOriginal){

 printf("\nSwsContext konnte nicht befüllt werden.");

 return 1;

 } 

 if(Frame->linesize < 0){

 printf("\nFehler: linesize ist negativ und nicht kompatibel\n");

 return 1;

 }

 AVFrame *RGBFrame;
 RGBFrame = av_frame_alloc();
 if(!RGBFrame){

 printf("\nFehler bei der Reservierung für den RGBFrame");

 return 1;

 }
 /*
 int number_bytes = av_image_get_buffer_size(AV_PIX_FMT_RGB24, Frame->width, Frame->height, 1);
 if(number_bytes < 0){

 printf("\nFehler bei der Berechnung der benoetigten Bytes fuer Konvertierung");

 return 1;

 }
 
 uint8_t *rgb_buffer = (uint8_t *)av_malloc(number_bytes*sizeof(uint8_t));
 if(rgb_buffer == NULL){

 printf("\nFehler bei der Reservierung für den RGBBuffer");

 return 1;

 }

 check = av_image_fill_arrays(RGBFrame->data, RGBFrame->linesize, rgb_buffer, AV_PIX_FMT_RGB24, Frame->width, Frame->height, 1);
 if(check < 0){

 printf("\nFehler bei der Zuweisung der RGB Daten");

 return 1;

 }*/

 //sws_scale(SwsContexttoRGB, (const uint8_t * const *)Frame->data, Frame->linesize, 0, Frame->height, RGBFrame->data, RGBFrame->linesize);
 sws_scale_frame(SwsContexttoRGB, Frame, RGBFrame);
 printf("\nIch habe die Daten zu RGB konvertiert.");

 //sws_scale(SwsContexttoOriginal, (const uint8_t * const *)RGBFrame->data, RGBFrame->linesize, 0, Frame->height, Frame->data, Frame->linesize);
 sws_scale_frame(SwsContexttoOriginal, RGBFrame, Frame);
 printf("\nIch habe die Daten zurück ins Original konvertiert.");

 Frame->format = ENCodecContext->pix_fmt;
 Frame->width = ENCodecContext->width;
 Frame->height = ENCodecContext->height;
 
 check = av_frame_get_buffer(Frame, 0);
 if(check < 0){
 
 printf("\nFehler bei Allocating Frame Buffer");
 
 return 1;
 
 }

 /* Encoding */
 check = av_frame_make_writable(Frame);
 if(check < 0){

 printf("\nFehler bei Make Frame Writable");

 return 1;

 }

 encode(ENCodecContext, Frame, EncodedPacket, Output_Format_Context);

 sws_freeContext(SwsContexttoRGB);
 sws_freeContext(SwsContexttoOriginal);
 av_frame_free(&RGBFrame);
 //av_free(rgb_buffer);

 }

 /* Flushing Encoder */
 encode(ENCodecContext, NULL, EncodedPacket, Output_Format_Context);

 //avcodec_flush_buffers(DECodecContext);
 //avcodec_flush_buffers(ENCodecContext);

 av_packet_free(&EncodedPacket);

 }else{

 av_interleaved_write_frame(Output_Format_Context, Packet);

 }

 }

 av_write_trailer(Output_Format_Context); 

 /* Memory Free */
 avcodec_free_context(&DECodecContext);
 avcodec_free_context(&ENCodecContext);
 avcodec_parameters_free(&CodecParameters);
 av_frame_free(&Frame);
 av_packet_free(&Packet);

 return 0;

}




The function encode looks as follows :


static void encode(AVCodecContext *ENCodecContext, AVFrame *Frame, AVPacket *EncodedPacket, AVFormatContext *Output_Format_Context){

 int check;



 check = avcodec_send_frame(ENCodecContext, Frame);
 if(check == AVERROR(EAGAIN)){
 printf("\nEAGAIN");
 } 
 if(check == AVERROR_EOF){
 printf("\nEOF");
 }
 if(check == AVERROR(EINVAL)){
 printf("\nEINVAL");
 }
 if(check == AVERROR(ENOMEM)){
 printf("\nENOMEM");
 }
 if(check < 0){

 printf("\nFehler bei Encoding Send Frame. Check = %d", check);

 return;

 }

 while(check >= 0){

 check = avcodec_receive_packet(ENCodecContext, EncodedPacket);
 if(check == AVERROR(EAGAIN) || check == AVERROR_EOF){

 return;

 }else if(check < 0){

 printf("\nFehler bei Encoding");

 return;

 }

 if (av_interleaved_write_frame(Output_Format_Context, EncodedPacket) < 0) {

 printf("\nFehler beim Muxen des Paketes.");
 break;

 }

 av_packet_unref(EncodedPacket);

 }

 return;

}



The program should decode a video into the individual frames convert them to RGB24, so I can work with the raw data of the frame, then convert it back to the original format and encode the frames.


The encoder doesn't play nice, as I get an EOF error at avcodec_send_frame().
But I couldn't figure it out why the encoder behaves like this.
And yes I have read the docs and example files, but either I'm massivly missing a crucial detail or I'm just ****.


Any and all help will be and is massivly appreciated.


PS. : The used libraries are libavutil, libavformat, libavcodec, libswscale. All installed with the "-dev" suffix through linux commandline. Should all be the version 7.0 libraries.


Thanks in advance.
With best regards.


- 

- Read the docs
- Shifting the encoding step out of the decoding while loop






-
Revision fcf7998a47 : Remove memcpy() in handle_inter_mode() filter selection. Encode time of first 5
8 juillet 2013, par Ronald S. BultjeChanged Paths :
Modify /vp9/encoder/vp9_rdopt.c
Remove memcpy() in handle_inter_mode() filter selection.Encode time of first 50 frames of bus (speed 0) @ 1500kbps goes from
2min4.9 to 2min3.1, i.e. a 1.4% speedup overall.Change-Id : Ibe8b08d159797504c5d0c5122de1b6da3b6595e0