libavcodec, how to transcode video with different frame rates?
Tag : cpp , By : Chris Woods
Date : March 29 2020, 07:55 AM
wish helps you Most simple solution would be to use two threads. First thread would do all the things outlined in your question (decoding, scaling / color-space conversion, coding). Partially transcoded frames would be written to intermediate queue shared with second thread. Maximum length of this queue would be in this particular case (converting from lower to higher bitrate) 1 frame. Second thread would be reading in loop frames from input queue like this: void FpsConverter::ThreadProc()
{
timeBeginPeriod(1);
DWORD start_time = timeGetTime();
int frame_counter = 0;
while(!shouldFinish()) {
Frame *frame = NULL;
DWORD time_begin = timeGetTime();
ReadInputFrame(frame);
WriteToOutputQueue(frame);
DWORD time_end = timeGetTime();
DWORD next_frame_time = start_time + ++frame_counter * frame_time;
DWORD time_to_sleep = next_frame_time - time_end;
if (time_to_sleep > 0) {
Sleep(time_to_sleep);
}
}
timeEndPeriod(1);
}
|
using libvlc_video_set_format_callbacks to transcode videos frame by frame
Tag : cpp , By : user152319
Date : March 29 2020, 07:55 AM
should help you out liblv_video_set_format_callbacks second argument is of type libvlc_video_format_cb, which is the following typedef: typedef unsigned(* libvlc_video_format_cb)(void **opaque, char *chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines);
|
Transcode of H.264 to VP8 using libav* has incorrect frame rate
Tag : c , By : xie renhui
Date : March 29 2020, 07:55 AM
like below fixes the issue It appears that your problem is in your transcoding function you need to av_rescale_q between your input format PTS/DTS and output format PTS/DTS. Don't trust putting arbitrary numbers in either, continue doing what you're doing by getting it from the context and codec.
|
How to transcode a stream of data using FFMpeg (C#)
Tag : chash , By : Jody Bannon
Date : March 29 2020, 07:55 AM
To fix this issue To solve this, I have spawned a new FFMpeg process. Then I used the pipe command and sent in the data via standard input, and got the output using the standard output. I then converted the output I received to a byte array. The new byte array is the transcoded data. You can write this byte buffer to a memory stream or a file stream, you can do what you like. var startInfo = new ProcessStartInfo('path/to/ffmpeg');
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
var argumentBuilder = new List<string>();
argumentBuilder.Add("-loglevel panic"); // this makes sure only data is sent to stdout
argumentBuilder.Add("-i pipe:.mp3"); //this sets the input to stdin
// the target audio specs are as follows
argumentBuilder.Add($"-f wav");
argumentBuilder.Add("-ac 1");
argumentBuilder.Add($"-ar 44100");
argumentBuilder.Add("pipe:1"); // this sets the output to stdout
startInfo.Arguments = String.Join(" ", argumentBuilder.ToArray());
_ffMpegProcess = new Process();
_ffMpegProcess.StartInfo = startInfo;
_ffMpegProcess.Start();
_ffMpegProcess.StandardInput.BaseStream.Write(byteBuffer);
while (true)
{
var bytes = new byte[1024]
var result = await _ffMpegProcess.StandardOutput.BaseStream.ReadAsync(bytes);
if (result == 0)
{
// no data retrieved
}
else
{
// do something with the data
}
}
|
Dump last frame of video file using ffmpeg/mencoder/transcode et. al
Date : March 29 2020, 07:55 AM
|