Quantcast
Channel: MediaSPIP
Viewing all 117896 articles
Browse latest View live

Background blur on concat videos make everything more blurry

$
0
0

Hi I have a bunch of temp video files that I want to concat together, some are different aspect ratios and resolutions so I want the end video to be a 1920x1080p with the empty space on the sides to be a box blur.

I have it working how I want but the video clips in the middle become more blurry than the original temp files. Could someone let me know if I can change the code to keep original quality? It will also show it's dropping frames a few thousand in a 20 minute video which isn't terrible but I would prefer it to not drop frames.

"ffmpeg -i "concat:"+ python script adds all file locations + "" -s 1920x1080 -filter_complex [0:v]scale=ih16/9:-1,boxblur=luma_radius=min(h,w)/20:luma_power=2:chroma_radius=min(cw,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw9/16 -af aselect=concatdec_select,aresample=async=1 Rendered_Videos/output.mp4"


multiple input files with complex operations in ffmpeg

$
0
0

I have just started using ffmpeg for one of my project. I have very limited knowledge of ffmpeg.

I need a help on below problem. Thanks in advance.

I have two files:-

  1. Audio File
  2. Video File

I want to generate single file after performing below operations:-

  • trim the audio file to custom start and stop point.
  • merge audio and video file to a single file (video file is of same size)
  • apply speed filter on the generated file.

I am able to achieve the output but with three different ffmpeg commands due to which it is taking lot of time. I want to achieve the all there tasks in a single ffmpeg command.

Thanks.

ffmpeg encoded hls makes audio and video progressively out of sync

$
0
0

When trying to encoding a source .mp4 to multiple bitrates and sizes for adaptive HLSv3 playback the resulting audio and video become progressively out of sync. When scrubbing to a later point it seems to reset, and stay in sync.

I'm on the latest ffmpeg 4.2.1 via homebrew-ffmpeg, with the libfdk-aac codec. Note, this was also occurring with ffmpeg 4.1.

ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
 built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1-with-options_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages --enable-libfdk-aac --enable-nonfree
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100

The audio and video streams are marginally off, would that cause this problem?

ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 INPUT_FILE.mp4 80.480400

ffprobe -v error -select_streams a:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 INPUT_FILE.mp4 80.469333

Here is some metadata on the source file:

General
Complete name : INPUT_VIDEO.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (mp42/mp41)
File size : 236 MiB
Duration : 1 min 21 s
Overall bit rate mode : Variable
Overall bit rate : 24.2 Mb/s
Encoded date : UTC 2019-08-27 22:13:53
Tagged date : UTC 2019-08-27 22:15:15
TIM : 00;00;00;00
TSC : 30000
TSZ : 1001

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L4.1
Format settings : CABAC / 2 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 2 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 min 21 s
Bit rate mode : Variable
Bit rate : 23.8 Mb/s
Maximum bit rate : 768 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 (30000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.383
Stream size : 233 MiB (99%)
Language : English
Encoded date : UTC 2019-08-27 22:13:53
Tagged date : UTC 2019-08-27 22:13:53
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 1 min 21 s
Source duration : 1 min 21 s
Bit rate mode : Constant
Bit rate : 317 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 3.10 MiB (1%)
Source stream size : 3.10 MiB (1%)
Language : English
Encoded date : UTC 2019-08-27 22:13:53
Tagged date : UTC 2019-08-27 22:13:53

And the encoding command:

ffmpeg \
-i INPUT_VIDEO \
-dn \
-sn \
-filter_complex \
"[0:v]fps=fps=24000/1001, \
setpts=(PTS-STARTPTS), \
split=12[vsplit1][vsplit2][vsplit3][vsplit4][vsplit5][vsplit6][vsplit7][vsplit8][vsplit9][vsplit10][vsplit11][vsplit12]; \
[vsplit1]scale=-1:1080[video_1080_4.1]; \
[vsplit2]scale=-1:720[video_720_4.1]; \
[vsplit3]scale=-1:720[video_720_3.1]; \
[vsplit4]scale=-1:540[video_540_3.1]; \
[vsplit5]scale=-1:432[video_432_3.1]; \
[vsplit6]scale=-1:270[video_270_3.0]; \
[vsplit7]scale=-1:270[video_270_3.1]; \
[vsplit8]scale=-1:144[video_144_4.1]; \
[vsplit9]scale=-1:144[video_144_3.0]; \
[vsplit10]scale=1920:1080[base_1080]; \
[vsplit11]scale=1280:720[base_720]; \
[vsplit12]scale=640:360[base_360]" \
\
-map "[video_1080_4.1]" \
-r:v:0 "24000/1001" \
-c:v:0 "libx264" \
-x264-params:0 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:0 "slow" \
-profile:v:0 "high" \
-level:v:0 "4.1" \
-refs:v:0 "2" \
-b-pyramid:v:0 "strict" \
-tune:v:0 "film" \
-b:v:0 "4800000" \
-maxrate:v:0 "4800000" \
-bufsize:v:0 "6*4800000/8" \
-vsync:v:0 "cfr" \
-bsf:v:0 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_720_4.1]" \
-r:v:1 "24000/1001" \
-c:v:1 "libx264" \
-x264-params:1 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:1 "slow" \
-profile:v:1 "main" \
-level:v:1 "4.1" \
-refs:v:1 "2" \
-b-pyramid:v:1 "strict" \
-tune:v:1 "film" \
-b:v:1 "3200000" \
-maxrate:v:1 "3200000" \
-bufsize:v:1 "6*3200000/8" \
-vsync:v:1 "cfr" \
-bsf:v:1 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_720_3.1]" \
-r:v:2 "24000/1001" \
-c:v:2 "libx264" \
-x264-params:2 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:2 "slow" \
-profile:v:2 "main" \
-level:v:2 "3.1" \
-refs:v:2 "2" \
-b-pyramid:v:2 "strict" \
-tune:v:2 "film" \
-b:v:2 "2200000" \
-maxrate:v:2 "2200000" \
-bufsize:v:2 "6*2200000/8" \
-vsync:v:2 "cfr" \
-bsf:v:2 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_540_3.1]" \
-r:v:3 "24000/1001" \
-c:v:3 "libx264" \
-x264-params:3 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:3 "slow" \
-profile:v:3 "main" \
-level:v:3 "3.1" \
-refs:v:3 "2" \
-b-pyramid:v:3 "strict" \
-tune:v:3 "film" \
-b:v:3 "1400000" \
-maxrate:v:3 "1400000" \
-bufsize:v:3 "6*1400000/8" \
-vsync:v:3 "cfr" \
-bsf:v:3 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_432_3.1]" \
-r:v:4 "24000/1001" \
-c:v:4 "libx264" \
-x264-params:4 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:4 "slow" \
-profile:v:4 "main" \
-level:v:4 "3.1" \
-refs:v:4 "2" \
-b-pyramid:v:4 "strict" \
-tune:v:4 "film" \
-b:v:4 "900000" \
-maxrate:v:4 "900000" \
-bufsize:v:4 "6*900000/8" \
-vsync:v:4 "cfr" \
-bsf:v:4 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_270_3.0]" \
-r:v:5 "24000/1001" \
-c:v:5 "libx264" \
-x264-params:5 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:5 "slow" \
-profile:v:5 "baseline" \
-level:v:5 "3.0" \
-refs:v:5 "2" \
-b-pyramid:v:5 "strict" \
-tune:v:5 "film" \
-b:v:5 "400000" \
-maxrate:v:5 "400000" \
-bufsize:v:5 "6*400000/8" \
-vsync:v:5 "cfr" \
-bsf:v:5 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_270_3.1]" \
-r:v:6 "24000/1001" \
-c:v:6 "libx264" \
-x264-params:6 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:6 "slow" \
-profile:v:6 "main" \
-level:v:6 "3.1" \
-refs:v:6 "2" \
-b-pyramid:v:6 "strict" \
-tune:v:6 "film" \
-b:v:6 "200000" \
-maxrate:v:6 "200000" \
-bufsize:v:6 "6*200000/8" \
-vsync:v:6 "cfr" \
-bsf:v:6 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_144_4.1]" \
-r:v:7 "24000/1001" \
-c:v:7 "libx264" \
-x264-params:7 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:7 "slow" \
-profile:v:7 "high" \
-level:v:7 "4.1" \
-refs:v:7 "2" \
-b-pyramid:v:7 "strict" \
-tune:v:7 "film" \
-b:v:7 "64000" \
-maxrate:v:7 "64000" \
-bufsize:v:7 "6*64000/8" \
-vsync:v:7 "cfr" \
-bsf:v:7 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[video_144_3.0]" \
-r:v:8 "24000/1001" \
-c:v:8 "libx264" \
-x264-params:8 "keyint=144:min-keyint=144:scenecut=0:open_gop=0" \
-preset:v:8 "slow" \
-profile:v:8 "baseline" \
-level:v:8 "3.0" \
-refs:v:8 "2" \
-b-pyramid:v:8 "strict" \
-tune:v:8 "film" \
-b:v:8 "56000" \
-maxrate:v:8 "56000" \
-bufsize:v:8 "6*56000/8" \
-vsync:v:8 "cfr" \
-bsf:v:8 "h264_metadata=fixed_frame_rate_flag=1" \
\
-map "[base_1080]" \
-c:v:9 "libx264" \
-preset:v:9 "slow" \
\
-map "[base_720]" \
-c:v:10 "libx264" \
-preset:v:10 "slow" \
\
-map "[base_360]" \
-c:v:11 "libx264" \
-preset:v:11 "slow" \
\
-map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 \
-c:a "libfdk_aac" \
-ar "48000" \
-ab "128k" \
-af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" \
\
-f tee \
-flags +global_header \
"[select=\'v:0,a:0,v:1,a:1,v:2,a:2,v:3,a:3,v:4,a:4,v:5,a:5,v:6,a:6,v:7,a:7,v:8,a:8\':f=hls:hls_flags=discont_start+temp_file:hls_time=6:hls_list_size=0:var_stream_map=\'v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3 v:4,a:4 v:5,a:5 v:6,a:6 v:7,a:7 v:8,a:8\':master_pl_name=playlist.m3u8:hls_segment_filename=INPUT_VIDEO__%v_%03d.ts]INPUT_VIDEO/out_%v.m3u8|[select=\'v:9,a:9\':f=mp4:movflags=+faststart]INPUT_VIDEO/large-1920-1080.mp4|[select=\'v:10,a:10\':f=mp4:movflags=+faststart]INPUT_VIDEO/med-1280-720.mp4|[select=\'v:11,a:11\':f=mp4:movflags=+faststart]INPUT_VIDEO/sm-640-360.mp4"

Can't play mp4 video using html5 video tag

$
0
0

I am trying to present an mp4 video (h264) using html5:


analyzing video codec with ffmpeg gives the following https://termbin.com/8j3d

a possible relevant detail is that playing the video using ubuntu's default video reader (ffmpeg in the background) doesn't show any video controls

-- https://termbin.com/8j3d

Using FFMPEG library with iPhone SDK for video encoding

$
0
0

I need to encode several pictures shot by the iPhone camera into a mp4 video file and I know FFMPEG can do this (the application TimeLapser and ReelMoments do it already). I plan to use this in my app iMotion (available in the appstore).

I successfully install and compile the ffmpeg for the iphone SDK with this link: http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-October/076618.html

But now I'm stuck here in my XCode project. What should I do next to use the FFMPEG library for video encoding? The Apple documentation about external library using is very light and I just can find any tutorial on the web which explains how to do this.

-- http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-October/076618.html

Crackling noise and other audio defects when live streaming (only) on YouTube

$
0
0

I am using ffmpeg to transcode and stream a live video, using rtmp. Everything works fine BUT the audio that comes out on the YouTube end has cracks and pops, like what you would expect to hear when your sound card's buffer is saturated.

What's weird is that I am sending the exact same information to different services, and only YouTube seems to have a problem with it. For this I am using ffmpeg's tee, like this:

ffmpeg -i - -deinterlace -map 0 -flags +global_header 
 -f tee "[f=flv:onfail=ignore]rtmp://twitch/key|[f=flv:onfail=ignore]rtmp://youtube/key|out.flv"'

So, the twitch end sounds great, the output file that I'm rendering also sounds good. Only on YouTube it sounds really bad.

I thought it may be the audio codec, the audio settings I'm using are -c:a aac -b:a 128k -ar 44100; but I've tried different things (using an mp3 codec, different bitrates) and it always sounds like that. Also AAC seems to be supported according to their own (YT) guidelines.

What could it be?

Reading mp3 file using ffmpeg caues memory leaks, even after freeing it in main

$
0
0

i am continuously reading mp3 files and processing them, but the memory keeps getting build up even though i freed it.

At the bottom read_audio_mp3(), they are already freeing some variable. why do i still face a memory build up and how do i deal with it ?

following this code : https://rodic.fr/blog/libavcodec-tutorial-decode-audio-file/, i read mp3 using this function

 int read_audio_mp3(string filePath_str, const int sample_rate, 
 double** output_buffer, int &AUDIO_DURATION){
 const char* path = filePath_str.c_str();

 /* Reads the file header and stores information about the file format. */
 AVFormatContext* format = avformat_alloc_context();
 if (avformat_open_input(&format, path, NULL, NULL) != 0) {
 fprintf(stderr, "Could not open file '%s'\n", path);
 return -1;
 }

 /* Check out the stream information in the file. */
 if (avformat_find_stream_info(format, NULL) < 0) {
 fprintf(stderr, "Could not retrieve stream info from file '%s'\n", path);
 return -1;
 }

 /* find an audio stream. */
 int stream_index =- 1;
 for (unsigned i=0; inb_streams; i++) {
 if (format->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
 stream_index = i;
 break;
 }
 }
 if (stream_index == -1) {
 fprintf(stderr, "Could not retrieve audio stream from file '%s'\n", path);
 return -1;
 }
 AVStream* stream = format->streams[stream_index];

 // find & open codec
 AVCodecContext* codec = stream->codec;
 if (avcodec_open2(codec, avcodec_find_decoder(codec->codec_id), NULL) < 0) {
 fprintf(stderr, "Failed to open decoder for stream #%u in file '%s'\n", stream_index, path);
 return -1;
 }

 // prepare resampler
 struct SwrContext* swr = swr_alloc();
 av_opt_set_int(swr, "in_channel_count", codec->channels, 0);
 av_opt_set_int(swr, "out_channel_count", 1, 0);
 av_opt_set_int(swr, "in_channel_layout", codec->channel_layout, 0);
 av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);
 av_opt_set_int(swr, "in_sample_rate", codec->sample_rate, 0);
 av_opt_set_int(swr, "out_sample_rate", sample_rate, 0);
 av_opt_set_sample_fmt(swr, "in_sample_fmt", codec->sample_fmt, 0);
 av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_DBL, 0);
 swr_init(swr);
 if (!swr_is_initialized(swr)) {
 fprintf(stderr, "Resampler has not been properly initialized\n");
 return -1;
 }

 /* Allocate an audio frame. */
 AVPacket packet;
 av_init_packet(&packet);
 AVFrame* frame = av_frame_alloc();
 if (!frame) {
 fprintf(stderr, "Error allocating the frame\n");
 return -1;
 }

 // iterate through frames
 *output_buffer = NULL;
 AUDIO_DURATION = 0;
 while (av_read_frame(format, &packet) >= 0) {
 // decode one frame
 int gotFrame;
 if (avcodec_decode_audio4(codec, frame, &gotFrame, &packet) < 0) {
 break;
 }
 if (!gotFrame) {
 continue;
 }
 // resample frames
 double* buffer;
 av_samples_alloc((uint8_t**) &buffer, NULL, 1, frame->nb_samples, AV_SAMPLE_FMT_DBL, 0);
 int frame_count = swr_convert(swr, (uint8_t**) &buffer, frame->nb_samples, (const uint8_t**) frame->data, frame->nb_samples);
 // append resampled frames to output_buffer
 *output_buffer = (double*) realloc(*output_buffer,
 (AUDIO_DURATION + frame->nb_samples) * sizeof(double));
 memcpy(*output_buffer + AUDIO_DURATION, buffer, frame_count * sizeof(double));
 AUDIO_DURATION += frame_count;
 }

 // clean up
 av_frame_free(&frame);
 swr_free(&swr);
 avcodec_close(codec);
 avformat_free_context(format);

 return 0;
 }

Main Script : MemoryLeak.cpp

 // imports
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 extern "C"
 {
 #include 
 #include 
 #include 
 #include 
 }
 using namespace std;

 int main (int argc, char ** argv) {
 string wavpath = argv[1];
 printf("wavpath=%s\n", wavpath.c_str());

 printf("\n==== Params =====\n");
 // Init
 int AUDIO_DURATION;
 int sample_rate = 8000;
 av_register_all();

 printf("\n==== Reading MP3 =====\n");
 while (true) {
 // Read mp3
 double* buffer;
 if (read_audio_mp3(wavpath, sample_rate, &buffer, AUDIO_DURATION) != 0) {
 printf("Cannot read %s\n", wavpath.c_str());
 continue;
 }

 /* 
 Process the buffer for down stream tasks.
 */

 // Freeing the buffer
 free(buffer);
 }

 return 0 ;
 }

Compiling

 g++ -o ./MemoryLeak.out -Ofast -Wall -Wextra \
 -std=c++11 "./MemoryLeak.cpp" \
 -lavformat -lavcodec -lavutil -lswresample

Running, by right my input an argument wav.scp that reads text file of all the mp3s. But for easy to replicate purpose, i only read 1 file song.mp3 in and i keep re-reading it

./MemoryLeak.out song.mp3

Why do i know i have memory leaks?

  1. I was running up 32 jobs in parallel for 14 million files, and when i wake up in the morning, they were abruptly killed.
  2. I run htop and i monitor the progress when i re-run it, and i saw that the VIRT&RES&Mem are continuously increasing.
-- https://rodic.fr/blog/libavcodec-tutorial-decode-audio-file/

What version of ffmpeg is bundled inside electron?

$
0
0

The prebuilt electron binaries for Windows include the file ffmpeg.dll. How can I determine what version of the underlying ffmpeg library is actually compiled to produce this dll? I need this information to understand what known vulnerabilities (CVE's, etc) might be in a given version of electron via ffmpeg.

As I understand it, the ffmpeg dll itself is taken from https://github.com/electron/nightlies/releases/ when I download my dependencies (I'm using electron-prebuilt-compile). But I'm not getting a clear picture of what the source for that binary is. I think it might be from https://chromium.googlesource.com/chromium/third_party/ffmpeg/ but then I'm not clear on the relationship of that repo with the original ffmpeg repo (e.g. how often are fixes merged from the ffmpeg repo to the chromium third-party repo, etc.)

I tried searching the content of the dll as per cody's suggestion, but no luck:

$ strings ffmpeg.dll | grep -i ffmp
FFmpeg video codec #1
Huffyuv FFmpeg variant
Not yet implemented in FFmpeg, patches welcome
C:\projects\libchromiumcontent\src\out-x64\static_library\ffmpeg.dll.pdb
ffmpeg.dll


$ strings ffmpeg.dll | grep -i version
H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2
MPEG-4 part 2 Microsoft variant version 1
MPEG-4 part 2 Microsoft variant version 2
MPEG-4 part 2 Microsoft variant version 3
H.263+ / H.263-1998 / H.263 version 2
On2 VP6 (Flash version)
On2 VP6 (Flash version, with alpha channel)
old standard qpel (autodetected per FOURCC/version)
direct-qpel-blocksize bug (autodetected per FOURCC/version)
edge padding bug (autodetected per FOURCC/version)
strictly conform to a older more strict version of the spec or reference software
minor_version
premiere_version
quicktime_version
Assume this x264 version if no x264 version found in any SEI
-- https://github.com/electron/nightlies/releases/, https://chromium.googlesource.com/chromium/third_party/ffmpeg/

doc/filters: update filter buffer/abuffer interface file name

$
0
0
doc/filters: update filter buffer/abuffer interface file name Update filter buffer/abuffer interface file name, from
libavfilter/{vsrc|asrc_buffer.h} to libavfilter/buffersrc.h Reviewed-by: Gyan Doshi 
Signed-off-by: Jun Zhao 
Signed-off-by: tomajsjiang 
  • [DH] doc/filters.texi

doc/fftools-common-opts: document ffmpeg -h protocol=protocol_name

$
0
0
doc/fftools-common-opts: document ffmpeg -h protocol=protocol_name document ffmpeg -h protocol=protocol_name Reviewed-by: Gyan Doshi 
Signed-off-by: Jun Zhao 
  • [DH] doc/fftools-common-opts.texi

doc/fftools-common-opts: fix typo (name => named)

$
0
0
doc/fftools-common-opts: fix typo (name => named) fix typo (name => named) Reviewed-by: Gyan Doshi 
Signed-off-by: Jun Zhao 
  • [DH] doc/fftools-common-opts.texi

avcodec/cfhdenc: compand coefficients

$
0
0
avcodec/cfhdenc: compand coefficients Also use -quality private option and add more modes.
  • [DH] libavcodec/cfhdenc.c

Video transcode and codec issue

$
0
0

I'm converting some old videos to play on my Roku via a dlna server. I'm trying to understand the MP4 container better to optimize conversions. I have an ogm video:

Duration: 01:00:38.22, start: 0.000000, bitrate: 1056 kb/s
Stream #0:0: Video: mpeg4 (XVID / 0x44495658), yuv420p, 576x324 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0:1(English): Audio: aac, 48000 Hz, stereo, fltp, 74 kb/s
Stream #0:2(Japanese): Audio: aac, 48000 Hz, stereo, fltp, 73 kb/s
Stream #0:3(English): Subtitle: text

From what I understand, MP4 container can contain MP4 video and aac audio. I used

-c:a copy -c:v copy

And it worked, but the video won't play. Obviously something's wrong. What I don't understand is why, the video looks like it's MP4 and the audio is aac. My guess is it's the Xvid but why?

Thank you. Todd

Process with symfony5, ffmpeg

$
0
0

I was using this code to execute commands with symfony3

$cl = 'ffmpeg -i "path/file.mp4" -f mp3 -ab 192000 -vn "path/file.mp3"';
$process = new Process($cl);
$process->run();

It worked perfectly on symfony3. Now i have migrated my site to symfony5. this code no longer works. I understood that "$cl" must be an array but i still don't understand the order of parameters and options with the ffmpeg command

How to concatenate two MP4 files using FFmpeg?

$
0
0

I'm trying to concatenate two mp4 files using ffmpeg. I need this to be an automatic process hence why I chose ffmpeg. I'm converting the two files into .ts files and then concatenating them and then trying to encode that concated .ts file. The files are h264 and aac encoded and I'm hoping to keep the quality the same or as close to original as possible.

ffmpeg -i part1.mp4 -vcodec copy -vbsf h264_mp4toannexb -acodec copy part1.ts
ffmpeg -i part2.mp4 -vcodec copy -vbsf h264_mp4toannexb -acodec copy part2.ts
cat part1.ts part2.ts > parts.ts
ffmpeg -y -i parts.ts -acodec copy -ar 44100 -ab 96k -coder ac -vbsf h264_mp4toannexb parts.mp4

Unfortunately I'm getting the following error message coming back from ffmpeg during encoding:

[h264 @ 0x1012600]sps_id out of range
[h264 @ 0x1012600]non-existing SPS 0 referenced in buffering period
[h264 @ 0x1012600]sps_id out of range
[h264 @ 0x1012600]non-existing SPS 0 referenced in buffering period
[NULL @ 0x101d600]error, non monotone timestamps 13779431 >= 13779431kbits/s 
av_interleaved_write_frame(): Error while opening file

This happens about half way through encoding which makes me think that you can't concat two .ts files together and have it work.


Node.js merge audio and video streams and pipe it to the client

$
0
0

I am working with ytdl-core library and it cannot download high quality videos with audio included because youtube has them in sperate files. Therefore, I need to download audio and video seperately then merge them using ffmpeg. An example of this can be seen here. However, using this way I am required to download the files prior to merging them and I was wondering is there is a way to merge audio and video streams and send the result to the client directly?

If you believe there is a more efficent way to achieve this, I would like to hear your approach.

Thanks in advance.

-- here

Build FFMpeg for converting m3u8 to mp4 only

$
0
0

I want to build a minimal version of FFMpeg for converting m3u8 to mp4 only, and the m3u8 file will be input via a https link.

I tried

./configure \
--disable-everything \
--disable-ffplay --disable-ffprobe \
--disable-asm --disable-doc --disable-devices \
--disable-pthreads --disable-w32threads --disable-hwaccels \
--disable-parsers --disable-bsfs --disable-debug \
--disable-indevs --disable-outdevs \
--enable-gpl --enable-nonfree \
--enable-openssl \
--enable-libx264 \
--enable-protocol=file,https,crypto,hls \
--enable-decoder=aac,h264 \
--enable-encoder=aac,libx264 \
--enable-demuxer=aac,h264,hls \
--enable-muxer=h264,mp4

but got errors

Error when loading first segment
Invalid data found when processing input

Does anyone know how to configure correctly in this case ? Please help.

Playing local audio discord.py bot on linux [closed]

$
0
0

I have search about it, but not found nothing useful. I wanna play from the Python3 script local audio with discord bot (on voice channel of course). I'm using Ubuntu 20.04 and PyCharm for the script/execute.

JavaCPP FFMpeg to JavaSound

$
0
0

I have a problem to be able to read audio using JavaCPP FFMpeg library. I don't know how to pass it to java sound and I don't know too if my code is correct.

Let's see the more important part of my code (video is OK so I drop this) :

The variables :

//==========================================================================
// FFMpeg 4.x - Video and Audio
//==========================================================================

private final AVFormatContext pFormatCtx = new AVFormatContext(null);
private final AVDictionary OPTIONS_DICT = null;
private AVPacket pPacket = new AVPacket();
 
//==========================================================================
// FFMpeg 4.x - Audio
//==========================================================================
 
private AVCodec pAudioCodec;
private AVCodecContext pAudioCodecCtx;
private final List audioStreams = new ArrayList<>();
private int audio_data_size;
private final BytePointer audio_data = new BytePointer(0);
private int audio_ret;
private AVFrame pAudioDecodedFrame = null;
private AVCodecParserContext pAudioParser;
private SwrContext audio_swr_ctx = null;

Then I call prepare functions in this order :

private void prepareFirst() throws Exception{
 oldFile = file;
 
 // Initialize packet and check for error
 pPacket = av_packet_alloc();
 if(pPacket == null){
 throw new Exception("ALL: Couldn't allocate packet");
 }

 // Open video file
 if (avformat_open_input(pFormatCtx, file.getPath(), null, null) != 0) {
 throw new Exception("ALL: Couldn't open file");
 }

 // Retrieve stream information
 if (avformat_find_stream_info(pFormatCtx, (PointerPointer)null) < 0) {
 throw new Exception("ALL: Couldn't find stream information");
 }

 // Dump information about file onto standard error
 av_dump_format(pFormatCtx, 0, file.getPath(), 0);

 // Find the first audio/video stream
 for (int i = 0; i < pFormatCtx.nb_streams(); i++) {
 switch(pFormatCtx.streams(i).codecpar().codec_type()){
 case AVMEDIA_TYPE_VIDEO -> videoStreams.add(new StreamInfo(i, pFormatCtx.streams(i)));
 case AVMEDIA_TYPE_AUDIO -> audioStreams.add(new StreamInfo(i, pFormatCtx.streams(i)));
 }
 }
 
 if(videoStreams.isEmpty() && type != PlayType.AudioOnly){
 throw new Exception("Didn't find an audio stream");
 }
 if(audioStreams.isEmpty() && type != PlayType.VideoOnly){
 throw new Exception("Didn't find a video stream");
 }
}

private void prepareAudio() throws Exception{
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 // AUDIO
 //------------------------------------------------------------------

 if(audioStreams.isEmpty() == false){
 //===========================
 //------------
 
// // Let's search for AVCodec
// pAudioCodec = avcodec_find_decoder(pFormatCtx.streams(audioStreams.get(0).getStreamIndex()).codecpar().codec_id());
// if (pAudioCodec == null) {
// throw new Exception("AUDIO: Unsupported codec or not found!");
// }
//
// // Let's alloc AVCodecContext
// pAudioCodecCtx = avcodec_alloc_context3(pAudioCodec);
// if (pAudioCodecCtx == null) { 
// throw new Exception("AUDIO: Unallocated codec context or not found!");
// }
 
 // Get a pointer to the codec context for the video stream
 pAudioCodecCtx = pFormatCtx.streams(audioStreams.get(0).getStreamIndex()).codec();

 // Find the decoder for the video stream
 pAudioCodec = avcodec_find_decoder(pAudioCodecCtx.codec_id());
 if (pAudioCodec == null) {
 throw new Exception("AUDIO: Unsupported codec or not found!");
 }

 //===========================
 //------------

 /* open it */
 if (avcodec_open2(pAudioCodecCtx, pAudioCodec, OPTIONS_DICT) < 0) {
 throw new Exception("AUDIO: Could not open codec");
 }

 pAudioDecodedFrame = av_frame_alloc();
 if (pAudioDecodedFrame == null){
 throw new Exception("AUDIO: DecodedFrame allocation failed");
 }

 audio_swr_ctx = swr_alloc_set_opts(
 null, // existing Swr context or NULL
 AV_CH_LAYOUT_STEREO, // output channel layout (AV_CH_LAYOUT_*)
 AV_SAMPLE_FMT_S16, // output sample format (AV_SAMPLE_FMT_*).
 44100, // output sample rate (frequency in Hz)
 pAudioCodecCtx.channels(), // input channel layout (AV_CH_LAYOUT_*)
 pAudioCodecCtx.sample_fmt(), // input sample format (AV_SAMPLE_FMT_*).
 pAudioCodecCtx.sample_rate(), // input sample rate (frequency in Hz)
 0, // logging level offset
 null // parent logging context, can be NULL
 );
 
 swr_init(audio_swr_ctx);
 
 av_samples_fill_arrays(
 pAudioDecodedFrame.data(), // audio_data,
 pAudioDecodedFrame.linesize(), // linesize
 audio_data, // buf
 (int)AV_CH_LAYOUT_STEREO, // nb_channels
 44100, // nb_samples
 AV_SAMPLE_FMT_S16, // sample_fmt
 0 // align
 );
 
 }
 
 // Audio treatment end ---------------------------------------------
 //==================================================================
}

And then when I launch the thread :

private void doPlay() throws Exception{
 av_init_packet(pPacket);

 // Read frames
 while (av_read_frame(pFormatCtx, pPacket) >= 0) {
 if (type != PlayType.AudioOnly && pPacket.stream_index() == videoStreams.get(0).getStreamIndex()) {
 // Is this a packet from the video stream?
 decodeVideo();
 renewPacket();
 }

 if (type != PlayType.VideoOnly && pPacket.stream_index() == audioStreams.get(0).getStreamIndex()) {
 // Is this a packet from the audio stream?
 if(pPacket.size() > 0){
 decodeAudio();
 renewPacket();
 }
 }
 }
}

private void renewPacket(){
 // Free the packet that was allocated by av_read_frame
 av_packet_unref(pPacket);

 pPacket.data(null);
 pPacket.size(0);
 av_init_packet(pPacket);
}

And again, this is where I don't read audio :

private void decodeAudio() throws Exception{

 do {
 audio_ret = avcodec_send_packet(pAudioCodecCtx, pPacket);
 } while(audio_ret == AVERROR_EAGAIN());
 System.out.println("packet sent return value: "+ audio_ret);

 if(audio_ret == AVERROR_EOF || audio_ret == AVERROR_EINVAL()) {
 StringBuilder sb = new StringBuilder();
 Formatter formatter = new Formatter(sb, Locale.US);
 formatter.format("AVERROR(EAGAIN): %d, AVERROR_EOF: %d, AVERROR(EINVAL): %d\n", AVERROR_EAGAIN(), AVERROR_EOF, AVERROR_EINVAL());
 formatter.format("Audio frame getting error (%d)!\n", audio_ret);
 throw new Exception(sb.toString());
 }

 audio_ret = avcodec_receive_frame(pAudioCodecCtx, pAudioDecodedFrame);
 System.out.println("frame received return value: "+ audio_ret);

 audio_data_size = av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);

 if (audio_data_size < 0) {
 /* This should not occur, checking just for paranoia */
 throw new Exception("Failed to calculate data size");
 }
 
 double frame_nb = 44100d / pAudioCodecCtx.sample_rate() * pAudioDecodedFrame.nb_samples();
 long out_count = Math.round(Math.floor(frame_nb));

 int out_samples = swr_convert(
 audio_swr_ctx,
 audio_data, 
 (int)out_count,
 pAudioDecodedFrame.data(0),
 pAudioDecodedFrame.nb_samples()
 );
 
 if (out_samples < 0) {
 throw new Exception("AUDIO: Error while converting");
 }
 
 int dst_bufsize = av_samples_get_buffer_size(
 pAudioDecodedFrame.linesize(), 
 (int)AV_CH_LAYOUT_STEREO, 
 out_samples,
 AV_SAMPLE_FMT_S16,
 1
 );
 
 AudioFormat audioFormat = new AudioFormat(
 pAudioDecodedFrame.sample_rate(),
 16,
 2, 
 true, 
 false
 );
 
 BytePointer bytePointer = pAudioDecodedFrame.data(0);
 ByteBuffer byteBuffer = bytePointer.asBuffer();

 byte[] bytes = new byte[byteBuffer.remaining()];
 byteBuffer.get(bytes);
 
 try (SourceDataLine sdl = AudioSystem.getSourceDataLine(audioFormat)) {
 sdl.open(audioFormat); 
 sdl.start();
 sdl.write(bytes, 0, bytes.length);
 sdl.drain();
 sdl.stop();
 } catch (LineUnavailableException ex) {
 Logger.getLogger(AVEntry.class.getName()).log(Level.SEVERE, null, ex);
 } 
}

Do you have an idea ?

I have pip installed pydub but still didn't work

$
0
0

After I had pip installed pydub and SpeechRecognition, I still can't make the program run successfully although I extracted the files from ffmpeg and specified the folder name bin in the corresponding directory. I tried to find solutions to solve the problem but it sill didn't work after I followed the steps clearly from the web. May I ask what is the good way to read .wav files using pydub AudioSegment?

 Warning (from warnings module):
 File "C:\Python38\lib\site-packages\pydub\utils.py", line 171
 warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
 RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
Viewing all 117896 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>