Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to crop bottom of video followed by removing black borders ?
9 mai 2018, par pmdalyI have video where there is a static bar on the bottom 50 pixels and also a black boarder around the actual content. I want to remove the bottom 50 pixels then use cropdetect to auto trim the border.
I have the following to remove the border
dims = $(ffmpeg -i "$video$ -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/{print $NF}' | tail -n1) ffmpeg -i "$video" -vf "$dims" "$video_out"
I'm not sure how to add the step to remove the bottom 50 pixels prior to this.
-
FFMPEG : Remove packets based on PTS/DTS
9 mai 2018, par stevendesuI have a video which contains some audio packets beyond the end of the video data:
$> ffprobe -show_packets video.mp4 ... ... ... [PACKET] codec_type=video stream_index=0 pts=5653648 pts_time=235.568667 dts=5653648 dts_time=235.568667 duration=1001 duration_time=0.041708 convergence_duration=N/A convergence_duration_time=N/A size=1030 pos=25233684 flags=__ [/PACKET] [PACKET] codec_type=audio stream_index=1 pts=11310080 pts_time=235.626667 dts=11310080 dts_time=235.626667 duration=1024 duration_time=0.021333 convergence_duration=N/A convergence_duration_time=N/A size=284 pos=25234714 flags=K_ [/PACKET] [PACKET] codec_type=audio stream_index=1 pts=11311104 pts_time=235.648000 dts=11311104 dts_time=235.648000 duration=1024 duration_time=0.021333 convergence_duration=N/A convergence_duration_time=N/A size=285 pos=25234998 flags=K_ [/PACKET] [PACKET] codec_type=audio stream_index=1 pts=11312128 pts_time=235.669333 dts=11312128 dts_time=235.669333 duration=992 duration_time=0.020667 convergence_duration=N/A convergence_duration_time=N/A size=290 pos=25235283 flags=K_ [/PACKET] $>
The last video packet in the video has a PTS time of
235.568667
and a duration of0.041708
- meaning all video data ends at235.610375
. However there are audio packets beginning at235.626667
and later.Is there an easy way to strip these audio packets from the file so that the audio and video end simultaneously?
-
Twitter gives error on ffmpeg generated video “The media you tried to upload was invalid.”
9 mai 2018, par TrooPHP Developerffmpeg generated video gives error while sharing on twitter. the error is :
“Cannot read property ‘code’ of undefined”
I am generating video from audio. my sample code Example is:
ffmpeg -i audio.webm -i image.png -vcodec libx264 -pix_fmt yuv420p -strict -2 -acodec aac video.mp4
I am directly trying to upload generated video to twitter website and video size is just 6 seconds.
-
How can I record an audio from USB audio device using C++ with ffmpeg on Linux ?
9 mai 2018, par Hunter Haimin ZhangHow can I record an audio from USB audio device using C++ with ffmpeg on Linux? I have the following code. But I have no idea how to set the parameter of 'url' in the function of avformat_open_input. Could assistance be provided by anybody? Much appreciated.
27 av_register_all(); 28 avdevice_register_all(); 29 30 //pAudioInputFmt =av_find_input_format("dshow"); 31 pAudioInputFmt =av_find_input_format("alsa"); 32 //assert(pAudioInputFmt != NULL); 33 if (!(pAudioInputFmt != NULL)) 34 { 35 printf("Error %s %d\n", __FILE__, __LINE__); 36 char ch = cin.get(); 37 cout << "ch = "<< ch << endl; 38 return (-1); 39 } 40 41 // I have no idear how to set the second parameter on Linux. 42 if (!(avformat_open_input(&pFmtCtx, "=Device)", pAudioInputFmt,NULL) == 0)) 43 { 44 printf("Error %s %d\n", __FILE__, __LINE__); 45 system("pause"); 46 return (-1); 47 }
-
Concatenate audio with image and video using ffmpeg
9 mai 2018, par huynq9I have 1 image, 1 audio file and 1 video. I would like to merge all of them to make a video which will
- show the image and play audio file for the first 10s
- play the video file
here is what I was trying to do so far.
ffmpeg \ -loop 1 -framerate 24 -t 10 -i item1.jpg \ -i "https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a" \ -i item4.mp4 \ -filter_complex \ "[0]scale=432:432,setdar=1[img1]; \ [1]volume=1[aud1]; \ [2]scale=432:432,setdar=1[vid1]; \ [img1][aud1][vid1] concat=n=3:v=1:a=1" \ outputfile.mp4
I got the error:
[Parsed_setdar_4 @ 0x3063780] Media type mismatch between the 'Parsed_setdar_4' filter output pad 0 (video) and the 'Parsed_concat_6' filter input pad 1 (audio) [AVFilterGraph @ 0x30479a0] Cannot create the link setdar:0 -> concat:1 Error initializing complex filters. Invalid argument
I tried to googled but still cannot figure out what I am doing wrong?
Updated: I ran the following command:
ffmpeg \ -loop 1 -framerate 24 -t 10 -i item1.jpg \ -t 10 -i "https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a" \ -i item4.mp4 \ -f lavfi -t 1 -i anullsrc \ -filter_complex \ "[0]scale=432:432,setsar=1[img1]; \ [2]scale=432:432,setsar=1[vid1]; \ [img1][1][vid1][3] concat=n=2:v=1:a=1" \ outputfile.mp4
and got the following error:
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3) configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --disable-ffserver --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc --enable-libzimg libavutil 55. 58.100 / 55. 58.100 libavcodec 57. 89.100 / 57. 89.100 libavformat 57. 71.100 / 57. 71.100 libavdevice 57. 6.100 / 57. 6.100 libavfilter 6. 82.100 / 6. 82.100 libavresample 3. 5. 0 / 3. 5. 0 libswscale 4. 6.100 / 4. 6.100 libswresample 2. 7.100 / 2. 7.100 libpostproc 54. 5.100 / 54. 5.100 Input #0, image2, from 'item1.jpg': Duration: 00:00:00.04, start: 0.000000, bitrate: 8365 kb/s Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 432x432 [SAR 1:1 DAR 1:1], 24 fps, 24 tbr, 24 tbn, 24 tbc Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a': Metadata: major_brand : M4A minor_version : 0 compatible_brands: M4A mp42isom creation_time : 1983-06-16T23:20:44.000000Z iTunSMPB : 00000000 00000840 00000000 00000000001423C0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Duration: 00:00:29.98, start: 0.047891, bitrate: 285 kb/s Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 271 kb/s (default) Metadata: creation_time : 1983-06-16T23:20:44.000000Z Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'item4.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01T00:00:00.000000Z encoder : Lavf53.24.2 Duration: 00:00:13.70, start: 0.000000, bitrate: 615 kb/s Stream #2:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 229 kb/s, 15 fps, 15 tbr, 15360 tbn, 30 tbc (default) Metadata: creation_time : 1970-01-01T00:00:00.000000Z handler_name : VideoHandler Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 382 kb/s (default) Metadata: creation_time : 1970-01-01T00:00:00.000000Z handler_name : SoundHandler Input #3, lavfi, from 'anullsrc': Duration: N/A, start: 0.000000, bitrate: 705 kb/s Stream #3:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s [AVFilterGraph @ 0x3955e20] No such filter: ' ' Error initializing complex filters. Invalid argument