So I'm one step close. I get out a .mp4 file. It has the correct duration but 
it is only black. The problem must be somewhere in the output format.
When I format dump i got the following for the input:

Input #0, mpegts, from 'input.ts':
  Duration: 00:00:03.96, start: 576.290000, bitrate: 621 kb/s
  Program 1 
    Stream #0.0[0x1002]: Video: h264, yuv420p, 720x576 [PAR 142:100 DAR 71:40], 
50 fps, 25 tbr, 90k tbn, 50 tbc

and the following for the output:
Output #0, mp4, to 
'/private/var/mobile/Applications/60B46933-02C2-4DA9-9AD7-F2F05A9574CB/tmp/-Tmp-/output.mp4':
    Stream #0.0: Video: 0x001b, 720x576, q=2-31, 90k tbn, 50 tbc

Now when I compare this to the output of "./ffmpeg -i input.ts -acodec copy 
-vcodec copy output.mp4" i see some strange diffs:
Output #0, mp4, to 'test_output.mp4':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: 0x0021, yuv420p, 720x576 [PAR 71:50 DAR 71:40], q=2-31, 
50 tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0

-> Video: 0x0021 vs 0x001b ??? what does this mean? What am I doing wrong that 
I'm getting a different output? 
-> The metadata key encoder is not required right?

My AVStream setup:

for (NSValue *stream in streams) {
        AVStream *avStream = [stream pointerValue];
        AVStream *outputStream = av_new_stream(outputContext, avStream->id);
        if (!outputStream) {
                NSLog(@"Could not init new output stream");
        }
        memcpy(outputStream->language, avStream->language, 
sizeof(avStream->language));
        switch (avStream->codec->codec_type) {
                case CODEC_TYPE_VIDEO:
                {
                        avcodec_get_context_defaults2(outputStream->codec, 
CODEC_TYPE_VIDEO);
                        outputStream->codec->codec_type = CODEC_TYPE_VIDEO;
                        outputStream->codec->width = 
720;//avStream->codec->width;
                        outputStream->codec->height = 
576;//avStream->codec->height;
                        break;
                }
                case CODEC_TYPE_AUDIO:
                {
                        avcodec_get_context_defaults2(outputStream->codec, 
CODEC_TYPE_AUDIO);
                        outputStream->codec->codec_type = CODEC_TYPE_AUDIO;
                        outputStream->codec->channels = 
avStream->codec->channels;
                        outputStream->codec->sample_rate = 
avStream->codec->sample_rate;
                        outputStream->codec->frame_size = 
avStream->codec->frame_size;
                        outputStream->codec->block_align = 
avStream->codec->block_align;
                        break;
                }
                default:
                        return;
        }
        
        outputStream->codec->codec_id = avStream->codec->codec_id;
        outputStream->codec->codec_tag = avStream->codec->codec_tag;
        outputStream->codec->bit_rate = avStream->codec->bit_rate;
        outputStream->codec->extradata = avStream->codec->extradata;
        outputStream->codec->extradata_size = avStream->codec->extradata_size;
        if (av_q2d(avStream->codec->time_base) > av_q2d(avStream->time_base) && 
av_q2d(avStream->time_base) < 1.0/1000)
                outputStream->codec->time_base = avStream->codec->time_base;
        else
                outputStream->codec->time_base = avStream->time_base;
}

On 14.07.2010, at 15:09, Thomas Post wrote:

> With some sample code I was able to come up with some code. But I still have 
> some problems with it. When calling av_write_header I get the message: "Codec 
> for stream 0 does not use global headers but container format requires global 
> headers". And the file written is not playable.
> I'm using av_read_frame and av_write_frame. But as I understand it these 
> methods will encode/decode my movie right? But I don't wan't that, I just 
> wan't to copy the encoded data from the MPEG-TS to the mp4 container. Can 
> someone please give me some advice what I'm doing wrong here ? 
> 
> On 14.07.2010, at 10:05, Thomas Post wrote:
> 
>> Hi there,
>> 
>> I'm totally new to the ffmpeg libs. So I'm a real newbie!
>> First I'd like to do soemthing like this: "ffmpeg -i input.ts -acodec copy 
>> -vcodec copy output.mp4" but programmatically. So I tried to do this:
>> - open an input file with av_open_input_file
>> - read it's content with av_read_frame
>> - write the frame to the output with av_write_frame. But here the problem 
>> starts. How can I get an AVFormatContext to a new .mp4 file?
>> 
>> Second I'd like to do this with a series of .ts files. Multiple .ts files 
>> into one .mp4 file. But I think that won't be such a problem when I got the 
>> thing above working.
>> 
> 
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> 

Thomas Post
-----------------------------------------------------------------------------------------------------------

equinux Aktiengesellschaft
Informationstechnologien
Kirschstraße 35
80999 München - Germany
Tel. +49-89-520465-339
Fax +49-89-520465-299
mailto:[email protected]
http://www.equinux.com/de
-----------------------------------------------------------------------------------------------------------
Vorstand: Till Schadde  -  Aufsichtsrat: Stefan Neuenhahn
USt-IdNr.: DE206360115  -  Sitz München  -  HRB München 129700
-----------------------------------------------------------------------------------------------------------

equinux USA, Inc.
100 Produce Ave. Suite L, South San Francisco, CA 94080 
Toll free: 1-888-equinux (1-888-3784689)
http://www.equinux.com
-----------------------------------------------------------------------------------------------------------

Stay updated what's going on at equinux
equinux Blog | equinux @ Twitter | equinux @ Facebook

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to