Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Combine Two Commands (Get Video from Images)
18 mai 2019, par user2401847I have 300 images and i wants to generate video from these images. i am new to FFMPEG so now i am using two commands to generate video from images. Command to generate video from images which also add Logo on video
ffmpeg -framerate 24 -i img_%d.jpg -i logo.png -filter_complex \ "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \ -vcodec libx264 -crf 25 -pix_fmt yuv420p test_video.mp4
After using above command i am getting the video to add audio to this video i am using below command
ffmpeg -i test_video.mp4 -i inputfile.mp3 -c:v libx264 -c:a libvorbis -shortest final_video.mp4
which generates video and i am getting below message
MPEG-4 AAC decoder is required to play the file
Help to combine this both command. if possible can we add sound without any decoder required
Log for command 1 https://drive.google.com/file/d/1zS7gvrPy69VK_MkyE4127FpX2kEziJHq/view?usp=sharing
and Log command 2 https://drive.google.com/file/d/1rHqVGzj7f003aWP6eISiyUjsES8_EWuw/view?usp=sharing
-
How to check (programmatically) if a video/audio file has DRM protection ?
18 mai 2019, par RRNHow to check (programmatically) if a video/audio file has DRM protection? Can FFmpeg do this?
-
Reason for write EPIPE error in my implentation ?
18 mai 2019, par Chrisl446So I currently have a small node.js express application for uploading images using sharp & thumbnails created from .mp4 videos using simple-thumbnail package/ffmpeg.
The app works perfectly when uploading an image, the file is uploaded sharp processes it, then passes it along and it ends up in my amazon s3 bucket as expected. No errors what so ever.
However, when I upload an mp4 video that I use to create and upload a thumbnail from by using simple-thumbnails genThumbnail() function, which uses ffmpeg child process, the thumbnail uploads successully to my s3 bucket, HOWEVER my app returns an EPIPE write error and NOT the url of the uploaded files url on S3.
What is causing this and how can I fix it, considering it's pretty much working aside from the EPIPE error that is being returned? Thanks ahead!
The packages of concern used are as follows:
multer-s3 <- this one with the transform option, not the standard multer-s3 package
const express = require('express'); const app = express(); const aws = require('aws-sdk'); const multer = require('multer'); const multerS3 = require('multer-s3'); //github:gmenih341/multer-s3 version of multer-s3 with transform option const sharp = require('sharp'); const genThumbnail = require('simple-thumbnail'); app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'Orgin, X-Requested-With, Content-Type, Accept, Authorization'); if (req.method === 'OPTIONS') { res.header('Access-Control-Allow-Methods', 'POST'); return res.status(200).json({}); } next(); }); let uniqueFileName; let s3BucketName = 'bucketname'; let s3 = new aws.S3({ accessKeyId: ACCESS_KEY, secretAccessKey: SECRET_KEY, Bucket: s3BucketName }); let upload = multer({ storage: multerS3({ s3: s3, bucket: s3BucketName, acl: 'public-read', cacheControl: 'max-age=31536000', contentType: multerS3.AUTO_CONTENT_TYPE, shouldTransform: true, transforms: [{ id: 'thumbnail', key: function (req, file, cb) { uniqueFileName = Date.now().toString(); cb(null, uniqueFileName + '.jpg') }, transform: function (req, file, cb) { if (file.mimetype == 'video/mp4') { //When using simple-thumbnails' getThumbnail() on an mp4 video it uploads succesfully to S3 but node returns EPIPE write error cb(null, genThumbnail(null, null, '250x?')) } else { //When using sharp to resize an image this works perfectly and retuns the JSON below with the files S3 URL cb(null, sharp().jpeg()) } } }] }) }); app.post('/upload', upload.array('theFile'), (req, res) => { res.json({ fileS3Url: 'https://s3.amazonaws.com/'+ s3BucketName +'/' + uniqueFileName }); }); app.use((req, res, next) => { const error = new Error('Not found'); error.status = 404; next(error); }); app.use((error, req, res, next) => { res.status(error.status || 500); res.json({ error: { message: error.message } }); }); module.exports = app;
-
H264 decoding using ffmpeg
18 mai 2019, par KindermannI'm trying to decode a video stream with ffmpeg library, that's how I do it basically:
void video_decode(const char *filename) { AVCodec *codec; AVCodecContext *c= NULL; int frame_count=0; FILE *f; AVFrame *frame; uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; av_init_packet(&avpkt); memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE); printf("Decoding video file...\n"); /* find the h264 video decoder */ codec = avcodec_find_decoder(AV_CODEC_ID_H264); c = avcodec_alloc_context3(codec); c->bit_rate = 400000; c->width = 1920; c->height = 1080; if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); exit(1); } frame = av_frame_alloc(); for (;;) { avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); if (avpkt.size == 0) break; avpkt.data = inbuf; while(avpkt.size > 0){ int len, got_frame; len = avcodec_decode_video2(c, frame, &got_frame, &avpkt); if (len < 0) { fprintf(stderr, "Errr while decding frame %d\n", frame_count); exit (1); } if (got_frame) { //Print out frame information.. } if (avpkt.data) { avpkt.size -= len; avpkt.data += len; } } } }
But I got the following outputs:
Decoding video file... [h264 @ 0x303c040] decode_slice_header error [h264 @ 0x303c040] decode_slice_header error [h264 @ 0x303c040] decode_slice_header error [h264 @ 0x303c040] no frame! Errr while decding frame 0
Obviously the initiation of codec was incomplete. Do you have experience with h264 api? Any help would be appreciated.
-
ffmpeg - How to auto crop Harry Potter moving newspaper style video ?
18 mai 2019, par hahahhhhhhaThe Harry Potter moving newspaper is like a video overlay on a static background. Here is an example youtube video: https://youtu.be/qQUUNmd3aco?t=1m17s the video starting from 1min, 17sec.
HOWTO crop only the video part? I have an image to show what i mean by the moving newspaper and what area does the video locate and what is the static background part. Please refer to the image. The area I draw by pink is where i mean by real video and any area except the video, is the static part.
here is an illustration image: https://imgur.com/s6vRqek
I understand if the frame size of the video does not change, I can specify the w, h, x, y to crop. But what if the frame size changes? ie. w, h, x, y changes.(w, h: width, height of the video. x, y: Coordinate system starting point ) Is there a way to autodetect the static part and only crop the real video part? like ffmpeg cropdetect for letterboxing. I tried cropdetect but failed. Any suggestion is welcome and I prefer using ffmpeg but any other softwares are welcome!