[Libav-user] Concat MOV files without re-encoding

Gyula Hatalyák hatalyak.gyula at artklikk.hu
Tue Jul 2 17:24:38 CEST 2013


Hi,

I would like to concat MOV files without re-encoding. I want to do it on
iOS (iPhone). All the MOV files are recorded with the same settings, no
difference in dimensions or encoding profiles.
I have succeeded to do it with the command line ffmpeg:
ffmpeg -re -f concat -i files.txt -c copy ...
But I have difficulties using the libraries.
I think the demuxing part is ok, I have the h.264+AAC packets. After
demuxing I shift the PTS and DTS info of each packet to have ascending
values in the joined MOV file.
The hard part is the muxing.
I have built the ffmpeg libs with x264 lib, so it can be used if necessary,
but I am not sure whether I need the x264 codec since I don't want to
re-encode the MOV files, I just want to join them.

*Problems I have encountered:*
*
*1) In this case I do not use x264 codec, At muxing I create the stream
with NULL codec parameter. I have successful writing of header, packets and
trailer. All the function calls return with zero error code. However, the
output can be opened, but black "screen" is displayed during playback.
FFprobe report is attached. I have also examined the output with MediaInfo
tool. I have attached that report as well (MediaInfo report - without x264
codec.txt). As you can see there is no h.264 profile or pixel info found
that might be a problem.

2) In this case I use x264 codec with functions: avcodec_find_encoder,
avformat_new_stream and avcodec_open2. Again: no decode-encode! In this
case I have much more metadata in the output file like h.264 profile and
pixel info (YUV), but the av_interleaved_write_frame call simply does
nothing but returns success code (0). No packet is written to the file. :(
I don't know how this could happen. fwrite works, but results in
un-openable file.
I have also attached the MediaInfo report of this output (MediaInfo report
- with x264 codec.txt).

*Questions:*
- How should I process the demuxed packets to feed the muxer?
- What format context and codec context setting should be done including
AVOption settings?
- Should I use the x264 codec to do this? I just vant to re-mux the chunks
into a single joined file.
- The chunks have their own header/trailer. Should I somehow filter the
demuxed packets to skip them?
- The final goal is creating a network stream (RTP or RTMP) - also with
re-muxing and without re-encoding. It works with command line ffmpeg:
ffmpeg -re -f concat -i files.txt -vcodec copy -an -f rtp rtp://
127.0.0.1:20000 -vn -acodec copy -f rtp rtp://127.0.0.1:30000
Concatenating to MOV format is only an intermediate pilot. Is it
recommended to work on the network format since it is so different task
that there is no benefit of solving the MOV format muxing?

Any help, advice, suggestion is greatly appreciated.
I can reveal code to make deeper investigation possible.

Regards,
Gyula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130702/62a51fad/attachment.html>
-------------- next part --------------
imac-01s-imac:~ hatalyakgyula$ ffprobe -show_data -show_error -show_format -show_frames -show_packets -show_streams -count_frames -count_packets -show_private_data -loglevel debug ~/Desktop/output.mov
ffprobe version 1.2.1-tessus Copyright (c) 2007-2013 the FFmpeg developers
  built on May  9 2013 21:58:14 with llvm-gcc 4.2.1 (LLVM build 2336.1.00)
  configuration: --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-fontconfig --enable-libfreetype --enable-libass --enable-filters --enable-runtime-cpudetect
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] ISO: File Type Major Brand: qt  
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] File position before avformat_find_stream_info() is 1421539
[h264 @ 0x102012400] no frame!
    Last message repeated 47 times
[h264 @ 0x102012400] Unknown NAL code: 29 (2277 bits)
[h264 @ 0x102012400] no frame!
    Last message repeated 22 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] max_analyze_duration 5000000 reached at 5040811 microseconds
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] decoding for stream 0 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), 352x288, 1/38400, 850 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
rfps: 14.833333 0.014196
    Last message repeated 1 times
rfps: 14.916667 0.007099
rfps: 30.000000 0.018272
rfps: 30.083333 0.009602
    Last message repeated 1 times
rfps: 44.916667 0.004858
rfps: 45.000000 0.003956
rfps: 59.833333 0.005642
    Last message repeated 1 times
rfps: 59.916667 0.012509
rfps: 59.940060 0.019782
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x102009e00] File position after avformat_find_stream_info() is 578526
/Users/hatalyakgyula/Desktop/output.mov: Operation not permitted
[ERROR]
code=-1
string=Operation not permitted
[/ERROR]
-------------- next part --------------
General
Complete name : /Users/hatalyakgyula/Documents/Projects/Production projects/Broadcaster/2013 pilot/sandboxes/hu.artklikk.fullxsTrial 2013-07-02 14.29.56.553.xcappdata/AppData/Documents/output.mov
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt
File size : 1.36 MiB
Duration : 13s 348ms
Overall bit rate : 852 Kbps
Writing application : Lavf54.63.104

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 13s 348ms
Bit rate : 851 Kbps
Width : 352 pixels
Height : 288 pixels
Display aspect ratio : 1.222
Frame rate mode : Variable
Frame rate : 14.085 fps
Minimum frame rate : 2.812 fps
Maximum frame rate : 480.000 fps
Standard : PAL
Bits/(Pixel*Frame) : 0.596
Stream size : 1.35 MiB (100%)
Language : English
-------------- next part --------------
General
Complete name : /Users/hatalyakgyula/Documents/Projects/Production projects/Broadcaster/2013 pilot/sandboxes/hu.artklikk.fullxsTrial 2013-07-02 16.03.25.221.xcappdata/AppData/Documents/output.mov
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt
File size : 961 Bytes
Duration : 9s 925ms
Overall bit rate mode : Constant
Overall bit rate : 775 bps
Writing application : Lavf54.63.104

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline at L5.2
Format settings, CABAC : No
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 9s 925ms
Bit rate mode : Constant
Bit rate : 114 bps
Width : 352 pixels
Height : 288 pixels
Display aspect ratio : 1.222
Frame rate mode : Variable
Frame rate : 14.208 fps
Minimum frame rate : 2.798 fps
Maximum frame rate : 480.000 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.000
Stream size : 141 Bytes (15%)
Language : English


More information about the Libav-user mailing list