Am 21.11.2012 07:42, schrieb hatred:
Hi List!

I have FFMPEG 1.0 installed in my ArchLinux box, I try to write simple audio+video transcoder example using existings doc/examples/muxing.c and doc/examples/demuxing.c ones and I have trouble: I can't listen sound in resulting file.

Source example with command line to compile: http://pastebin.com/F9R5qpPz
Compile:
g++ -Wall -O2 -g -D__STDC_CONSTANT_MACROS -o video-sound-transcoding-test video-sound-transcoding-test.cpp -lm -lavdevice -lavformat -lavfilter -lavcodec -lswresample -lswscale -lavutil

run:
./video-sound-transcoding-test input_file.avi out.ts

I test only for MPEGTS output as more needed for me.

Other info:
1. If input file contain only sound stream transcoding finished successfuly and I can listen sound in resulting file well. 2. If I comment code and skip video stream in input file transcoding finished successfuly also and I can listen sound in resulting file well.
3. Video transcoded very well
4. transcoding with ffmpeg is valid: ffmpeg -i input_file.avi -f mpegts out.ts but I don't fully understand its code.

So I don't understand how to correctly I must encode/muxing audio+video and all suggestions is welcome!

Thank for every answer, List!
Hi,

it seems that you are stucked the same way that I do for several days.
I really don't want to take over your thread but I seems to me that we are both almost in front of the last barrier. I've got almost the same code as you (merged together from demuxing.c and muxing.c). So perhaps with the help of some advanced ffmpeg user/developer on the list we can figure out our problem. In my case, I'd like to manipulate video frames of the file with some image processing kernels etc. and write the file with the same codecs they have back to disc, but of cause with processed frames.
So basically I need a "transcoder" from the codec to the same codec.

What I didn't have is your code fragment:
"if (outCtx.videoCodecCtx->coded_frame->pts != AV_NOPTS_VALUE)
{
outPkt.pts = av_rescale_q(outCtx.videoCodecCtx->coded_frame->pts,
outCtx.videoCodecCtx->time_base,
outCtx.videoStream->time_base);
}"

If I put it into my code almost all or no video frames are encoded succesfully and the output is: [libx264 @ 0000000002620080] specified frame type (3) at 1314 is not compatible with keyframe interval
[mp4 @ 00000000034ff080] pts (0) < dts (1352000) in stream 0
Error while writing video frame

I looked into ffmpeg.c as well but I had no time to step threw it while transcoding, because I'm currently working on a windows machine. Perhaps you can explane to me why we have to rescale the presentation time stamp...

Ah and you've rescaled the audio too. I did not rescale the audio but for every input codec I take, audio is always fine, even withouth:

"if (frame->pts == AV_NOPTS_VALUE)
{
AVRational samplesRateInv = {1, outCtx.audioCodecCtx->sample_rate};
int64_t pts = inputAudioSamples;
frame->pts = av_rescale_q(pts, samplesRateInv, inCtx.audioCodecCtx->time_base);
}
                inputAudioSamples += frame->nb_samples;"

Why is this?
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to