Biligrab icon indicating copy to clipboard operation
Biligrab copied to clipboard

I think it should support avconv...

Open Icenowy opened this issue 11 years ago • 11 comments

As the title said.

Icenowy avatar Oct 14 '14 05:10 Icenowy

Looks nice.

Will look into this in a couple of hours, hopefully can add the support in the next version as well as a update of Flvcd source.

Beining 在 2014年10月14日,下午1:55,Icenowy Zheng [email protected] 写道:

As the title said.

— Reply to this email directly or view it on GitHub.

cnbeining avatar Oct 14 '14 06:10 cnbeining

Well…

After hours of Googling, I cannot find any good way to merge files with avconv.

The way that may work is to convert everything into .ts files, which is exactly the thing I want to get rid of.

Can you kindly provide my with an example of concating multiple files with avconv so I can look into it further?

Many thanks.

Beining

在 2014年10月14日,下午1:55,Icenowy Zheng [email protected] 写道:

As the title said.

— Reply to this email directly or view it on GitHub.

cnbeining avatar Oct 14 '14 11:10 cnbeining

fff = 'concat:'
for i in range(vid_num):
    fff = fff + '\'' + str(os.getcwd()) + '/'+ str(i) + '.flv\'\\|'
#ff = ff.encode("utf8")
f.close()
print('Concating videos... "/" will be replaced.')
filename = filename.replace('/','_')
os.system('avconv -i ' + fff + ' -strict experimental  \''+filename+'\'.mp4')
# os.system('ffmpeg -f concat -i ff.txt -c copy "'+filename+'".mp4')

Nothing more to say.

Icenowy avatar Oct 15 '14 05:10 Icenowy

According to my experiments, this would make a video with MPEG4:

>>> os.system('avconv -i ' + fff + ' -strict experimental  \''+filename+'\'.mp4')
avconv version v12_dev0-195-geabdc2a, Copyright (c) 2000-2014 the Libav developers
  built on Oct 14 2014 19:14:08 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
[flv @ 0x7fe111001200] max_analyze_duration 5000000 reached
Input #0, flv, from 'concat:/Users/Beining/Movies/flv/微博上各种不科学的图·第十四辑 (  ̄ 3 ̄)/0.flv|/Users/Beining/Movies/flv/微博上各种不科学的图·第十四辑 (  ̄ 3 ̄)/1.flv|':
  Metadata:
    creator         : you.video.sina.com.cn
    metadatacreator : Yet Another Metadata Injector for FLV - Version 1.8
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : true
    datasize        : 67277983
    videosize       : 62630090
    audiosize       : 4549309
    lasttimestamp   : 362
    lastkeyframetimestamp: 356
    lastkeyframelocation: 66443581
  Duration: 00:06:02.06, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: h264 (High)
      yuv420p, 640x480 [PAR 1:1 DAR 4:3], 882 kb/s
      25 fps, 1k tbn, 50 tbc
    Stream #0:1: Audio: aac
      44100 Hz, stereo, fltp, 96 kb/s
Output #0, mp4, to 'aa.mp4':
  Metadata:
    creator         : you.video.sina.com.cn
    metadatacreator : Yet Another Metadata Injector for FLV - Version 1.8
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : true
    datasize        : 67277983
    videosize       : 62630090
    audiosize       : 4549309
    lasttimestamp   : 362
    lastkeyframetimestamp: 356
    lastkeyframelocation: 66443581
    encoder         : Lavf56.6.0
    Stream #0:0: Video: mpeg4
      yuv420p, 640x480 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s
      25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.3.0 mpeg4
    Stream #0:1: Audio: aac
      44100 Hz, stereo, fltp, 200 kb/s
    Metadata:
      encoder         : Lavc56.3.0 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))<-------------????????????
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press ctrl-c to stop encoding
^Cframe= 6763 fps=857 q=31.0 Lsize=   14826kB time=270.48 bitrate= 449.0kbits/s    
video:7986kB audio:6623kB other streams:0kB global headers:0kB muxing overhead: 1.491390%
Received signal 2: terminating.
65280

This would transcode the file, which is what I want to prevent.

Maybe you want to check your command...

Can you provide me with a line of working command so I can check what is going on?

Thanks.

Beining

cnbeining avatar Oct 15 '14 13:10 cnbeining

Thx. Will try on my machine, and will push if works as the code does.

Icenowy Zheng [email protected]于2014年10月15日星期三写道:

fff = 'concat:' for i in range(vid_num): fff = fff + ''' + str(os.getcwd()) + '/'+ str(i) + '.flv'|' #ff = ff.encode("utf8") f.close() print('Concating videos... "/" will be replaced.') filename = filename.replace('/','_') os.system('avconv -i ' + fff + ' -strict experimental ''+filename+''.mp4')

os.system('ffmpeg -f concat -i ff.txt -c copy "'+filename+'".mp4')

Nothing more to say.

— Reply to this email directly or view it on GitHub https://github.com/cnbeining/Biligrab/issues/5#issuecomment-59159987.

cnbeining avatar Oct 15 '14 14:10 cnbeining

According to my experiments, this would make a video with MPEG4:

Add -c copy to prevent transcoding.

m13253 avatar Nov 22 '14 11:11 m13253

@Icenowy

  1. Why were you suggesting using str1 = str1 + '|' + str2? That is slow and generates gibberish temporary objects (the same as in C++ and JavaScript). Please use str1 = '|'.join([str1, str2, str3, ...]).
  2. Is os.system safe enough to prevent injection attack? A simple asterisk would crap the filesystem. You can't prevent usage on a cloud server as "BiliPlus" does.
  3. Is there any good reason to support avconv? It's not developing actively and is abandoned. Even Debian has switched back to FFmpeg recently.
  4. Why -strict experimental and removing -c copy? You weren't going to transcode the media, were you?

m13253 avatar Nov 22 '14 11:11 m13253

@cnbeining Avconv has almost the same params with ffmpeg. Just use it like ffmpeg. @m13253 Libav is not abandoned. Latest update is on Dec 2, 2014.

swordfeng avatar Dec 17 '14 02:12 swordfeng

@swordfeng

$ avconv -f concat -i ff.txt -c copy o.mp4 avconv version v12_dev0-195-geabdc2a, Copyright (c) 2000-2014 the Libav developers built on Oct 14 2014 19:14:08 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Unknown input format: 'concat'

No success.

(BTW, your real name do looks like mine...)

cnbeining avatar Dec 17 '14 02:12 cnbeining

Well, I haven't tried -f concat even with ffmpeg. You can refer to the Libav documentation here: http://libav.org/avconv.html See the concat section (18.1). (Similar names? Sounds interesting. How does it look like? )

swordfeng avatar Dec 17 '14 03:12 swordfeng

Well, I haven't tried -f concat even with ffmpeg. You can refer to the Libav documentation here: http://libav.org/avconv.html See the concat section (18.1). (Similar names? Sounds interesting. How does it look like? )

That concat section (18.1) means "concat protocol", not "concat demuxer". "concat demuxer" is implemented in FFmpeg 1.1 and has never been merged into Libav. FFmpeg, as of version 1.1, supports three concatenation methods: concat protocol, concat filter, concat demuxer. Only concat demuxer can do perfect lossless concatenation on most situations.

Libav is not abandoned. Latest update is on Dec 2, 2014.

Libav is developing so slowly that FFmpeg has thousands more of features than Libav. FFmpeg merges from Libav constantly while Libav does not merge from FFmpeg. Also, Debian is considering switching back to FFmpeg again in the coming release. Debian stable users can switch to Deb-multimedia repository. All other distros provide FFmpeg directly. Are there any other reasons to stick to Libav?

m13253 avatar Dec 17 '14 16:12 m13253