Bad ffmpeg parameter causes transcode failure
- Code:
1.0.1 LOG
2012-08-20 20:09:27,699 DEBUG [FFMPEGWrapper] Invoking FFmpeg to transcode video file: http://127.0.0.1:8902
2012-08-20 20:09:27,700 DEBUG [ProcessExecutor] Starting C:\Program Files\Serviio\bin\\..\lib/ffmpeg.exe -fflags +genpts -i http://127.0.0.1:8902 -y -copyts -c:v copy -vbsf h264_mp4toannexb -c:a ac3 -b:a 96k -ac 1 -map 0:1 -map 0:0 -sn -f mpegts pipe:
2012-08-20 20:09:29,293 WARN [ProcessExecutor] Process cmd has a return code of 1! This is a possible error.
2012-08-20 20:09:29,293 DEBUG [TranscodingJobListener] Transcoding finished; successful: false
2012-08-20 20:09:30,170 DEBUG [NonClosingPipedInputStream] Closing piped input stream and closing related feeder process
2012-08-20 20:09:30,170 DEBUG [ProcessExecutor] Stopping external process: Thread[Thread-71,5,main]
2012-08-20 20:09:30,170 DEBUG [ProcessUtils] Killing the Windows process: 8256
2012-08-20 20:09:30,197 DEBUG [TranscodingJobListener] Transcoding finished; successful: true
2012-08-20 20:09:31,168 WARN [PipedOutputBytesReader] Error reading bytes stream from external process: Stream closed
2012-08-20 20:09:54,203 DEBUG [StreamBasedTranscodingDeliveryStrategy] Transcoded stream is empty, connection may have been lost
2012-08-20 20:09:54,203 DEBUG [VideoDeliveryEngine] Found Format profile for transcoded file http://127.0.0.1:8902: AVC_TS_MP_SD_AC3_ISO
2012-08-20 20:09:54,203 DEBUG [ResourceDeliveryProcessor] Stream entity has length: 50000000000
2012-08-20 20:09:54,204 DEBUG [ResourceDeliveryProcessor] Sending file back
- Code:
1.0 BETA2 log
2012-08-20 17:47:39,244 DEBUG [FFMPEGWrapper] Invoking FFmpeg to transcode video file: http://localhost:8902
2012-08-20 17:47:39,244 DEBUG [ProcessExecutor] Starting C:\Program Files\Serviio\bin\\..\lib/ffmpeg.exe -i http://localhost:8902 -y -async 1 -vcodec copy -vbsf h264_mp4toannexb -copyts -acodec ac3 -ab 96k -ac 1 -map 0:1 -map 0:0 -sn -f mpegts pipe:
2012-08-20 17:47:44,747 DEBUG [VideoDeliveryEngine] Found Format profile for transcoded file http://localhost:8902: AVC_TS_MP_SD_AC3_ISO
2012-08-20 17:47:44,747 DEBUG [ResourceDeliveryProcessor] Stream entity has length: 50000000000
2012-08-20 17:47:44,747 DEBUG [ResourceDeliveryProcessor] Sending file back
2012-08-20 17:47:44,747 DEBUG [ResourceTransportRequestHandler] HTTP/1.1 200 OK, headers = [[Content-Type: video/mpeg,Content-Length: 50000000000,Date: Mon, 20 Aug 2012 21:47:44 GMT,Server: Windows 7, UPnP/1.0 DLNADOC/1.50, Serviio/1.0-SNAPSHOT,Cache-control: no-cache,contentFeatures.dlna.org: DLNA.ORG_PN=AVC_TS_MP_SD_AC3_ISO;DLNA.ORG_OP=00;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=8D500000000000000000000000000000,transferMode.dlna.org: Streaming,MediaInfo.sec: SEC_Duration=18000000;]]
2012-08-20 17:47:45,857 WARN [ProcessExecutor] Process cmd has a return code of 1! This is a possible error.
2012-08-20 17:47:45,857 DEBUG [TranscodingJobListener] Transcoding finished; successful: false
2012-08-20 17:47:48,749 DEBUG [WebServer] I/O error: Pipe broken
If I execute the ffmpeg command standalone I get the FFMPEG error in both 1.0.1 and 1.0 BETA2 as below
- Code:
1.0.1 COMMAND
C:\Users\John>ffmpeg.exe -fflags +genpts -i http://127.0.0.1:8902 -y -copyts -c:
v copy -vbsf h264_mp4toannexb -c:a ac3 -b:a 96k -ac 1 -map 0:1 -map 0:0 -sn -f m
pegts d:\tv1.mpg
ffmpeg version N-41860-g6fd0b55 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 23 2012 19:49:05 with gcc 4.6.2
configuration: --enable-static --disable-shared --disable-ffplay --disable-ffs
erver --enable-memalign-hack --enable-libmp3lame --enable-librtmp --extra-libs='
-lrtmp -lpolarssl -lws2_32 -lwinmm' --arch=x86 --enable-runtime-cpudetect --enab
le-pthreads --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --pkg-config=pk
g-config
libavutil 51. 61.100 / 51. 61.100
libavcodec 54. 29.100 / 54. 29.100
libavformat 54. 11.100 / 54. 11.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 82.100 / 2. 82.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
[mpegts @ 003ef2e0] max_analyze_duration 5000000 reached at 5016000
[mpegts @ 003ef2e0] Estimating duration from bitrate, this may be inaccurate
Input #0, mpegts, from 'http://127.0.0.1:8902':
Duration: N/A, start: 26926.604178, bitrate: 96 kb/s
Program 1
Stream #0:0[0x58](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono,
s16, 96 kb/s
Stream #0:1[0x59]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001
B), yuv420p, 646x396 [SAR 128:117 DAR 20672:11583], 34.55 fps, 25 tbr, 90k tbn,
50 tbc
[aformat @ 054bef20] auto-inserting filter 'auto-inserted resampler 0' between t
he filter 'Parsed_anull_0' and the filter 'aformat'
[auto-inserted resampler 0 @ 05544260] chl:mono fmt:s16 r:48000Hz -> chl:mono fm
t:flt r:48000Hz
[mpegts @ 05553620] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every
40 pkts
Output #0, mpegts, to 'd:\tv1.mpg':
Metadata:
encoder : Lavf54.11.100
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 646x396 [SAR 128
:117 DAR 20672:11583], q=2-31, 34.55 fps, 90k tbn, 25 tbc
Stream #0:1(eng): Audio: ac3, 48000 Hz, mono, flt, 96 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (mp2 -> ac3)
Press [q] to stop, [?] for help
[NULL @ 05566d40] Warning: SPS NALU missing or invalid. The resulting stream may
not play.
[NULL @ 05566d40] Warning: PPS NALU missing or invalid. The resulting stream may
not play.
Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: I
nvalid argument
[mpegts @ 05553620] H.264 bitstream malformed, no startcode found, use the h264_
mp4toannexb bitstream filter (-bsf h264_mp4toannexb)
av_interleaved_write_frame(): Invalid argument
- Code:
1.0 BETA2 COMMAND
C:\Users\John>"C:\Program Files\Serviio\lib\ffmpeg.exe" -i http://localhost:8902
-y -async 1 -vcodec copy -vbsf h264_mp4toannexb -copyts -acodec ac3 -ab 96k -ac
1 -map 0:1 -map 0:0 -sn -f mpegts d:tcode.ts
ffmpeg version 0.9, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 13 2011 20:46:11 with gcc 4.4.2
configuration: --enable-static --disable-shared --disable-ffplay --disable-ffs
erver --enable-memalign-hack --enable-libmp3lame --enable-librtmp --extra-libs='
-lrtmp -lpolarssl -lws2_32 -lwinmm' --arch=x86 --enable-runtime-cpudetect --enab
le-pthreads --target-os=mingw32 --cross-prefix=i686-mingw32- --pkg-config=pkg-co
nfig
libavutil 51. 32. 0 / 51. 32. 0
libavcodec 53. 42. 0 / 53. 42. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1. 0 / 2. 1. 0
[mpegts @ 019cb8c0] max_analyze_duration 5000000 reached at 5016000
[mpegts @ 019cb8c0] Estimating duration from bitrate, this may be inaccurate
Input #0, mpegts, from 'http://localhost:8902':
Duration: N/A, start: 18434.444178, bitrate: 96 kb/s
Program 1
Stream #0:0[0x58](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono,
s16, 96 kb/s
Stream #0:1[0x59]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001
B), yuv420p, 646x396 [SAR 128:117 DAR 20672:11583], 27.70 fps, 25 tbr, 90k tbn,
50 tbc
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 05fb1700] channel_layout not specified
[ac3 @ 05fb1700] No channel layout specified. The encoder will guess the layout,
but it might be incorrect.
[mpegts @ 05ecc020] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every
40 pkts
Output #0, mpegts, to 'd:tcode.ts':
Metadata:
encoder : Lavf53.24.0
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 646x396 [SAR 128
:117 DAR 20672:11583], q=2-31, 27.70 fps, 90k tbn, 25 tbc
Stream #0:1(eng): Audio: ac3, 48000 Hz, mono, flt, 96 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (mp2 -> ac3)
Press [q] to stop, [?] for help
[NULL @ 05fb10e0] Warning: SPS NALU missing or invalid. The resulting stream may
not play.
[NULL @ 05fb10e0] Warning: PPS NALU missing or invalid. The resulting stream may
not play.
h264_mp4toannexb failed for stream 0, codec copy: Invalid argument
[mpegts @ 05ecc020] h264 bitstream malformated, no startcode found, use -vbsf h2
64_mp4toannexb
av_interleaved_write_frame(): Operation not permitted
However if I remove the -vbsf h264_mp4toannexb parameter from the command line, ffmpeg converts the file correctly.
- Code:
1.0.1 Command with -VBSF H264_MP$toannexb removed
ffmpeg version N-41860-g6fd0b55 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 23 2012 19:49:05 with gcc 4.6.2
configuration: --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-memalign-hack --enable-libmp3lame --enable-librtmp --extra-libs='-lrtmp -lpolarssl -lws2_32 -lwinmm' --arch=x86 --enable-runtime-cpudetect --enable-pthreads --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --pkg-config=pkg-config
libavutil 51. 61.100 / 51. 61.100
libavcodec 54. 29.100 / 54. 29.100
libavformat 54. 11.100 / 54. 11.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 82.100 / 2. 82.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
[mpegts @ 003bf260] max_analyze_duration 5000000 reached at 5016000
[mpegts @ 003bf260] Estimating duration from bitrate, this may be inaccurate
Input #0, mpegts, from 'http://127.0.0.1:8902':
Duration: N/A, start: 27452.732178, bitrate: 96 kb/s
Program 1
Stream #0:0[0x58](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16, 96 kb/s
Stream #0:1[0x59]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 646x396 [SAR 128:117 DAR 20672:11583], 53.02 fps, 25 tbr, 90k tbn, 50 tbc
[aformat @ 05544d80] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'aformat'
[auto-inserted resampler 0 @ 02e82940] chl:mono fmt:s16 r:48000Hz -> chl:mono fmt:flt r:48000Hz
[mpegts @ 02f1b740] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'd:\tv2.mpg':
Metadata:
encoder : Lavf54.11.100
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 646x396 [SAR 128:117 DAR 20672:11583], q=2-31, 53.02 fps, 90k tbn, 25 tbc
Stream #0:1(eng): Audio: ac3, 48000 Hz, mono, flt, 96 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (mp2 -> ac3)
Press [q] to stop, [?] for help
frame= 865 fps=0.0 q=-1.0 size= 3072kB time=00:00:38.24 bitrate= 658.1kbits/
frame= 1276 fps=1001 q=-1.0 size= 4333kB time=00:00:54.68 bitrate= 649.2kbits
frame= 1297 fps=465 q=-1.0 size= 4400kB time=00:00:55.52 bitrate= 649.2kbits/
frame= 1326 fps=360 q=-1.0 size= 4499kB time=00:00:56.68 bitrate= 650.2kbits/
frame= 1353 fps=280 q=-1.0 size= 4572kB time=00:00:57.76 bitrate= 648.5kbits/
frame= 1374 fps=231 q=-1.0 size= 4632kB time=00:00:58.60 bitrate= 647.6kbits/
frame= 1402 fps=188 q=-1.0 size= 4706kB time=00:00:59.72 bitrate= 645.5kbits/
frame= 1430 fps=175 q=-1.0 size= 4774kB time=00:01:00.84 bitrate= 642.8kbits/
frame= 1479 fps=150 q=-1.0 size= 4934kB time=00:01:02.80 bitrate= 643.6kbits/
frame= 1520 fps=144 q=-1.0 size= 5039kB time=00:01:04.44 bitrate= 640.6kbits/
frame= 1528 fps=128 q=-1.0 size= 5055kB time=00:01:04.76 bitrate= 639.5kbits/
frame= 1570 fps=124 q=-1.0 size= 5187kB time=00:01:06.44 bitrate= 639.5kbits/
frame= 1594 fps=120 q=-1.0 Lsize= 5237kB time=00:01:07.40 bitrate= 636.5kbits
/s
video:3877kB audio:791kB subtitle:0 global headers:0kB muxing overhead 12.190212
%
- Code:
1.0 Beta 2 Command with -VBSF H264_MP$toannexb removed
C:\Users\John>"C:\Program Files\Serviio\lib\ffmpeg.exe" -i http://localhost:8902
-y -async 1 -vcodec copy -copyts -acodec ac3 -ab 96k -ac 1 -map 0:1 -map 0:0 -s
n -f mpegts d:\tcode.mpg
ffmpeg version 0.9, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 13 2011 20:46:11 with gcc 4.4.2
configuration: --enable-static --disable-shared --disable-ffplay --disable-ffs
erver --enable-memalign-hack --enable-libmp3lame --enable-librtmp --extra-libs='
-lrtmp -lpolarssl -lws2_32 -lwinmm' --arch=x86 --enable-runtime-cpudetect --enab
le-pthreads --target-os=mingw32 --cross-prefix=i686-mingw32- --pkg-config=pkg-co
nfig
libavutil 51. 32. 0 / 51. 32. 0
libavcodec 53. 42. 0 / 53. 42. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1. 0 / 2. 1. 0
[mpegts @ 016bb860] max_analyze_duration 5000000 reached at 5016000
[mpegts @ 016bb860] Estimating duration from bitrate, this may be inaccurate
Input #0, mpegts, from 'http://localhost:8902':
Duration: N/A, start: 18761.108178, bitrate: 96 kb/s
Program 1
Stream #0:0[0x58](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono,
s16, 96 kb/s
Stream #0:1[0x59]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001
B), yuv420p, 646x396 [SAR 128:117 DAR 20672:11583], 26.74 fps, 25 tbr, 90k tbn,
50 tbc
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 015cfe00] channel_layout not specified
[ac3 @ 015cfe00] No channel layout specified. The encoder will guess the layout,
but it might be incorrect.
[mpegts @ 01679660] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every
40 pkts
Output #0, mpegts, to 'd:\tcode.mpg':
Metadata:
encoder : Lavf53.24.0
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 646x396 [SAR 128
:117 DAR 20672:11583], q=2-31, 26.74 fps, 90k tbn, 25 tbc
Stream #0:1(eng): Audio: ac3, 48000 Hz, mono, flt, 96 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (mp2 -> ac3)
Press [q] to stop, [?] for help
frame= 962 fps=188 q=-1.0 size= 3827kB time=00:00:38.86 bitrate= 806.7kbits/
frame= 1087 fps=153 q=-1.0 size= 4586kB time=00:00:43.86 bitrate= 856.5kbits/
frame= 1150 fps=134 q=-1.0 size= 4928kB time=00:00:46.38 bitrate= 870.3kbits/
frame= 1228 fps=111 q=-1.0 size= 5280kB time=00:00:49.50 bitrate= 873.6kbits/
frame= 1242 fps=102 q=-1.0 size= 5344kB time=00:00:50.06 bitrate= 874.3kbits/
frame= 1458 fps=107 q=-1.0 size= 6445kB time=00:00:58.70 bitrate= 899.3kbits/
frame= 1486 fps=100 q=-1.0 size= 6582kB time=00:00:59.82 bitrate= 901.3kbits/
frame= 1585 fps= 90 q=-1.0 size= 7029kB time=00:01:03.78 bitrate= 902.7kbits/
frame= 1626 fps= 84 q=-1.0 size= 7219kB time=00:01:05.42 bitrate= 903.9kbits/
frame= 1661 fps= 55 q=-1.0 size= 7380kB time=00:01:06.82 bitrate= 904.7kbits/
frame= 1704 fps= 48 q=-1.0 size= 7576kB time=00:01:08.54 bitrate= 905.4kbits/
frame= 1805 fps= 50 q=-1.0 size= 8124kB time=00:01:12.58 bitrate= 916.8kbits/
frame= 1816 fps= 48 q=-1.0 size= 8188kB time=00:01:13.02 bitrate= 918.4kbits/
frame= 1983 fps= 50 q=-1.0 size= 8939kB time=00:01:19.70 bitrate= 918.7kbits/
frame= 2123 fps= 47 q=-1.0 size= 9656kB time=00:01:25.30 bitrate= 927.3kbits/
frame= 2333 fps= 47 q=-1.0 size= 10517kB time=00:01:33.70 bitrate= 919.4kbits/
frame= 2368 fps= 46 q=-1.0 size= 10733kB time=00:01:35.10 bitrate= 924.4kbits/
frame= 2459 fps= 46 q=-1.0 size= 11230kB time=00:01:38.74 bitrate= 931.6kbits/
This demonstrates that this is a legacy error undetected until now.
The Samsung C/D profile simply transcodes the mp2 audio in an mpegts file to ac3 so i do not understand why such a compex ffmpeg command is being applied which causes this error.