Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to use ffmpeg to conver the mp3 with image to mp4 ?
24 octobre 2012, par Ellothe mp3 has image in it ,maybe some album images.when i use ffmpeg convert to mp4,it gone wrong.but if i use some mp3 without image,it succeed.
My command is like this :
ffmpeg -i input.mp3 output.mp4
error:
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg -> mpeg4) Stream #0:0 -> #0:1 (mp3 -> aac)
here is all console output:
ellodeiMac:mine ello$ ffmpeg -frames 0 -i 4.mp3 -y test.mp4 ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers built on Oct 24 2012 12:21:13 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00) configuration: --disable-yasm libavutil 51. 54.100 / 51. 54.100 libavcodec 54. 23.100 / 54. 23.100 libavformat 54. 6.100 / 54. 6.100 libavdevice 54. 0.100 / 54. 0.100 libavfilter 2. 77.100 / 2. 77.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 15.100 / 0. 15.100 [mp3 @ 0x7fa12301ae00] max_analyze_duration 5000000 reached at 5015510 Input #0, mp3, from '4.mp3': Metadata: artist : 贵族乐团 album : 美声天籁 title : 肖邦离别曲 Tagging time : 2012-09-18T08:12:10 Duration: 00:04:01.44, start: 0.000000, bitrate: 129 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s Stream #0:1: Video: mjpeg, yuvj420p, 240x240 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc Metadata: title : e comment : Cover (front) [buffer @ 0x109115780] w:240 h:240 pixfmt:yuvj420p tb:1/90000 sar:1/1 sws_param:flags=2 [buffersink @ 0x109133720] No opaque field provided [format @ 0x1091338e0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'format' [scale @ 0x109133bc0] w:240 h:240 fmt:yuvj420p sar:1/1 -> w:240 h:240 fmt:yuv420p sar:1/1 flags:0x4 [mp4 @ 0x7fa123035c00] Frame rate very high for a muxer not efficiently supporting it. Please consider specifying a lower framerate, a different muxer or -vsync 2 [aformat @ 0x109136ec0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'src' and the filter 'aformat' [aresample @ 0x1091370c0] chl:stereo fmt:s16 r:44100Hz -> chl:stereo fmt:flt r:44100Hz [mpeg4 @ 0x7fa12303be00] timebase 1/90000 not supported by MPEG 4 standard, the maximum admitted value for the timebase denominator is 65535 Output #0, mp4, to 'test.mp4': Metadata: artist : 贵族乐团 album : 美声天籁 title : 肖邦离别曲 Tagging time : 2012-09-18T08:12:10 Stream #0:0: Video: mpeg4, yuv420p, 240x240 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k tbn, 90k tbc Metadata: title : e comment : Cover (front) Stream #0:1: Audio: none, 44100 Hz, stereo, flt, 128 kb/s Stream mapping: Stream #0:1 -> #0:0 (mjpeg -> mpeg4) Stream #0:0 -> #0:1 (mp3 -> aac) Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
-
ffmpeg frame grabbing slow on mp4 files
24 octobre 2012, par user1444886The following ffmpeg frame grab command takes a long time to grab an image from the mp4 file.
ffmpeg.exe -itsoffset -200 -i C:\93844428.mp4 -vcodec mjpeg -vframes 1 -y -an -f rawvideo -s 640x360 C:\test\out1.jpg
For a 20MB file (about 2 minutes of video) it takes up to about 6 seconds to find the image depending on what offset (in seconds) you ask to grab it.
For a 100MB it can anything in many minutes if you request a large offset.
This only appears to be an issue with mp4 files.
Is there anything that can be done to improve this?
-
Cannot get libav custom IO to work for jpg image file
24 octobre 2012, par BloodwolfI am trying to create a custom input stream. However, avformat_open_input fails with a random error value. I would appreciate it if someone can tell me what is it that I am doing wrong. Here is the simplified code.
Thank you in advance for your help.
#define BUFSIZE (4 * 1024) static int ReadPacket(void* opaque, uint8_t* buf, int bufsize) { FILE* file = (FILE*) opaque; int len = fread(buf, 1, bufsize, file); return len; } int main(int argc, char* argv[]) { av_register_all(); // av_log_set_level(AV_LOG_DEBUG); const char* fileName = "/home/alan/sample.jpg"; FILE* file = fopen(fileName, "rb"); unsigned char* buffer = (unsigned char*) av_malloc(BUFSIZE); AVIOContext* avContext = avio_alloc_context(buffer, BUFSIZE, 1, file,ReadPacket, NULL, NULL); AVFormatContext* pFormatCtx = avformat_alloc_context(); pFormatCtx->pb = avContext; int val = avformat_open_input(&pFormatCtx, fileName, NULL, NULL); if (val != 0) { printf("Open input failed. Err: %d\n", val); pFormatCtx = 0; // it is already freed av_free(avContext); av_free(buffer); fclose(file); return -1; } }
But if I replace the fileName by "/home/alan/demo.avi", it works..
-
FFmpeg : Jpeg file to AVFrame
24 octobre 2012, par darjaI need to join several jpg files into video using FFmpeg library. But I have a problem with reading this files. Here is a function which reads image file and makes AVFrame:
AVFrame* OpenImage(const char* imageFileName) { AVFormatContext *pFormatCtx; if(av_open_input_file(&pFormatCtx, imageFileName, NULL, 0, NULL)!=0) { printf("Can't open image file '%s'\n", imageFileName); return NULL; } dump_format(pFormatCtx, 0, imageFileName, false); AVCodecContext *pCodecCtx; pCodecCtx = pFormatCtx->streams[0]->codec; pCodecCtx->width = W_VIDEO; pCodecCtx->height = H_VIDEO; pCodecCtx->pix_fmt = PIX_FMT_YUV420P; // Find the decoder for the video stream AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id); if (!pCodec) { printf("Codec not found\n"); return NULL; } // Open codec if(avcodec_open(pCodecCtx, pCodec)<0) { printf("Could not open codec\n"); return NULL; } // AVFrame *pFrame; pFrame = avcodec_alloc_frame(); if (!pFrame) { printf("Can't allocate memory for AVFrame\n"); return NULL; } int frameFinished; int numBytes; // Determine required buffer size and allocate buffer numBytes = avpicture_get_size(PIX_FMT_YUVJ420P, pCodecCtx->width, pCodecCtx->height); uint8_t *buffer = (uint8_t *) av_malloc(numBytes * sizeof(uint8_t)); avpicture_fill((AVPicture *) pFrame, buffer, PIX_FMT_YUVJ420P, pCodecCtx->width, pCodecCtx->height); // Read frame AVPacket packet; int framesNumber = 0; while (av_read_frame(pFormatCtx, &packet) >= 0) { if(packet.stream_index != 0) continue; int ret = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet); if (ret > 0) { printf("Frame is decoded, size %d\n", ret); pFrame->quality = 4; return pFrame; } else printf("Error [%d] while decoding frame: %s\n", ret, strerror(AVERROR(ret))); } }
This causes no error but creates only black frame, no image. What is wrong?
-
How do I subtract a word from the output in bash
23 octobre 2012, par user1768840I made a simple bash script to convert movies from .avi to .mp4 but now I want to do two more things.
- Have the output file have only *.mp4 rather than *.avi.mp4
- Delete the old file after the conversion is completed.
Here is my script.
#!/bin/bash avconv -i "$1" -c:v libx264 -c:a copy -sn -crf 24 "$1".mp4