Alexander Meinke wrote:
> Hey Antonio,
>
> nice to hear from you. I had to think about it to get your idea and resulting benefits. The conclusion is, that I am not your man for this. Nevertheless, I have some questions.
>
> Is it right that your going to create the threads ininit, sync them viastream and send them viasend after all frames has been transocded?
Yes, this is the plan, however the _send will be called when the last stage (the encoder) has one packet to send
> Do you think it will be possible to split transcoding between the threads with ffmpeg?
> Would the architecture make it possible to pass the number of threads to ffmpeg?
It's possible and tvheadend apparently ask ffmpeg to run encoding in parallel with a number of threads equal to the CPU core detected. I have not checked if the information passed are consistent, but this is another topic. Parallelizing heavy computation stage over thread is of course good for multi core architecture, but still with the current transcoding code, every stage (decoding, deinterlacing, encoding) waits each other. With this architecture you will never get benefits from GPU accelerated capabilities
>
> So it looks like I can't imagine what is going to be done in parallel. There is the pipeline where every stage does it's own thing and outputs to its successor stage. Last stage will output the the full transcoded frame within a packet.
Let me try to be more simplier here. With the current code, as said every stage waits each other. Suppose we have a GPU that is capable to accelerate each stages, le'ts say that this acceleration won't consume any CPU power. But let's say that every stage gets 1/50 seconds for complete the job. So we would have
decoding (takes 1/50sec, no CPU) -> deinterlacing (takes 1/50sec, no CPU) -> encoding (takes 1/50sec, no CPU)
For completing a single frame trascoding we need 3/50 sec. If the source frame rate is 1/25 (which is 2/50 sec) we don't do transcoding in real time, even if we are using 0% of the CPU!!
Can you see now the difference between CPU usage and real time? ;)
With a pipelined transcoding we will have, after the third frame punt in the pipeline
1) decoding of frame 2 (takes 1/50sec, no CPU)
2) deinterlacing frame 1 (takes 1/50sec, no CPU)
3) encoding of frame 0 (takes 1/50sec, no CPU) ---> output
So we perform the entire trnascoding in 1/50 sec with no CPU usage and we run realtime :)
>
>
> Sorry for delay,
>
> Alex.
No problem. I'm done with the coding of the pipeline, debugging now. Next step is to implement specific handler for the decoding/filtering/enconding stage (trivial) and then put these handlers in task (not complicated). Stay tuned